source: MotivateGetHumanHelp/doc/data/Analysis.R@ 5

Last change on this file since 5 was 5, checked in by Bart Vastenhouw, 5 years ago

Intermediate update

File size: 32.4 KB
RevLine 
[5]1library (foreign)
2library (ggplot2)
3library (nlme)
4library (lattice)
5library (MASS)
6library (Matrix)
7library (lme4)
8library (multilevel)
9library (psy)
10library(ordinal)
11library(pspearman)
12library(readxl)
13library(car)
14
15
16#REGION CRONBACH ALPHA ALLIANCE
17
18data_alliLSHM <- read_excel("PATH/Alliance dataLSHM.xlsx")
19View(data_alliLSHM)
20cronbach(data_alliLSHM)
21
22data_alliHSHM <- read_excel("PATH/Alliance dataHSHM.xlsx")
23View(data_alliHSHM)
24cronbach(data_alliHSHM)
25
26data_alliLSMM <- read_excel("PATH/Alliance dataLSMM.xlsx")
27View(data_alliLSMM)
28cronbach(data_alliLSMM)
29
30data_alliMSMM <- read_excel("PATH/Alliance dataMSMM.xlsx")
31View(data_alliMSMM)
32cronbach(data_alliMSMM)
33
34data_alliHSMM <- read_excel("PATH/Alliance dataHSMM.xlsx")
35View(data_alliHSMM)
36cronbach(data_alliHSMM)
37
38data_alliLSLM <- read_excel("PATH/Alliance dataLSLM.xlsx")
39View(data_alliLSLM)
40cronbach(data_alliLSLM)
41
42data_alliMSLM <- read_excel("PATH/Alliance dataMSLM.xlsx")
43View(data_alliMSLM)
44cronbach(data_alliMSLM)
45
46data_alliMSHM <- read_excel("PATH/Alliance dataMSHM.xlsx")
47View(data_alliMSHM)
48cronbach(data_alliMSHM)
49
50data_alliHSLM <- read_excel("PATH/Alliance dataHSLM.xlsx")
51View(data_alliHSLM)
52cronbach(data_alliHSLM)
53
54
55
56#Region Data analysis & Descriptive outcomes
57
58data <- read_excel("PATH/Datatable.xlsx")
59
60#Specify levels of MatchSys as 0 or 1
61data$MatchSys = factor(data$MatchSys,levels=c(0,1))
62#Specify levels for Route as Motiv, Accept or Refer
63data$Route = factor(data$Route,levels=c("motivate","accept","refer"))
64
65#Specify levels for SubSev as Low, Med, High
66data$SubSev = factor(data$SubSev,levels=c("Low","Med","High"))
67data$SubSev <- ordered(data$SubSev)
68#Specify levels of SubMoti as Low, Med, High
69data$SubMoti = factor(data$SubMoti,levels=c("Low","Med","High"))
70data$SubMoti <- ordered(data$SubMoti)
71
72#Specify levels for ScenSev as Low, Med, High
73data$ScenSev = factor(data$ScenSev,levels=c("Low","Med","High"))
74data$ScenSev <- ordered(data$ScenSev)
75#Specify levels of ScenMoti as Low, Med, High
76data$ScenMoti = factor(data$ScenMoti,levels=c("Low","Med","High"))
77data$ScenMoti <- ordered(data$ScenMoti)
78
79
80data$ScenSit = factor(data$ScenSit,levels=c("LsLm","MsLm","HsLm","LsMm","MsMm","HsMm","LsHm","MsHm","HsHm"))
81data$SubSit = factor(data$SubSit,levels=c("LsLm","MsLm","HsLm","LsMm","MsMm","HsMm","LsHm","MsHm","HsHm"))
82
83data$WhyTxt = factor(data$WhyTxt,levels=c("Mon","Stig","Time"))
84
85data$ppCode = factor(data$ppCode)
86
87#Display data
88View(data)
89
90
91#EXPLORATION Graphs
92### data exploration
93stem(data$FBH)
94hist(data$FBH)
95
96ggplot(data, aes(x=Help, fill=MatchSys)) + geom_density(alpha = 0.3)
97ggplot(data, aes(x=Help, fill=Route)) + geom_density(alpha = 0.3)
98
99ggplot(data, aes(x=Return, fill=MatchSys)) + geom_density(alpha = 0.3)
100ggplot(data, aes(x=Return, fill=Route)) + geom_density(alpha = 0.3)
101
102ggplot(data, aes(x=FBH, fill=MatchSys)) + geom_density(alpha = 0.3)
103ggplot(data, aes(x=FBH, fill=Route)) + geom_density(alpha = 0.3)
104ggplot(data, aes(x=FBH, fill=Gen)) + geom_density(alpha = 0.3)
105
106#MEAN, 0 Modell revealing deviation from 0 & moti + severity added to check if these have an overall effect.
107mean(data$Help)
108sd(data$Help)
109Model_null_h <- lme(fixed = Help~1, random = ~1 | ppCode, data = data, method = "ML")
110summary(Model_null_h)
111anova(Model_null_h)
112Model_scen_h <- lme(fixed = Help~ScenSit, random = ~1 | ppCode, data = data, method = "ML")
113anova(Model_null_h,Model_scen_h)
114anova(Model_scen_h)
115
116
117mean(data$Return)
118sd(data$Return)
119Model_null_r <- lme(fixed = Return~1, random = ~1 | ppCode, data = data, method = "ML")
120
121anova(Model_null_r)
122Model_scen_r <- lme(fixed = Return~ScenSit, random = ~1 | ppCode, data = data, method = "ML")
123anova(Model_null_r,Model_scen_r)
124anova(Model_scen_r)
125
126mean(data$FBH)
127sd(data$FBH)
128Model_null_a <- lme(fixed = FBH~1, random = ~1 | ppCode, data = data, method = "ML")
129anova(Model_null_a)
130Model_scen_a <- lme(fixed = FBH~ScenSit, random = ~1 | ppCode, data = data, method = "ML")
131summary(Model_scen_a)
132anova(Model_null_a,Model_scen_a)
133
134
135#REGION COMPARE ScenJECTIVE - SCENE SITUATION
136fmodelSnull <- clmm2(ScenSev~1,random = ppCode,data=data,Hess=TRUE,nAGQ = 10)
137summary(fmodelSnull)
138
139fmodelS <- clmm2(ScenSev ~ SubSev, random = ppCode, data=data, Hess=TRUE,nAGQ = 10)
140summary(fmodelS)
141anova(fmodelSnull,fmodelS)
142
143( McF.pR2 <- 1 - fmodelS$logLik/fmodelSnull$logLik )
144
145
146fmodelMnull <- clmm2(ScenMoti~1,random = ppCode,data=data,Hess=TRUE,nAGQ = 10)
147summary(fmodelMnull)
148fmodelM <- clmm2(SubMoti ~ ScenMoti , random = ppCode,data=data,Hess=TRUE,nAGQ = 10)
149summary(fmodelM)
150anova(fmodelMnull,fmodelM)
151
152( McF.pR2 <- 1 - fmodelM$logLik/fmodelMnull$logLik )
153
154
155
156
157
158
159#Covariate checks
160Model_age_h <- lme(fixed = Help~Age, random = ~1 | ppCode, data = data, method = "ML")
161anova(Model_null_h,Model_age_h)
162Model_age_r <- lme(fixed = Return~Age, random = ~1 | ppCode, data = data, method = "ML")
163anova(Model_null_r,Model_age_r)
164Model_age_a <- lme(fixed = FBH~Age, random = ~1 | ppCode, data = data, method = "ML")
165anova(Model_null_a,Model_age_a)
166
167Model_gen_h <- lme(fixed = Help~Gen, random = ~1 | ppCode, data = data, method = "ML")
168anova(Model_null_h,Model_gen_h)
169Model_gen_r <- lme(fixed = Return~Gen, random = ~1 | ppCode, data = data, method = "ML")
170anova(Model_null_r,Model_gen_r)
171Model_gen_a <- lme(fixed = FBH~Gen, random = ~1 | ppCode, data = data, method = "ML")
172summary(Model_gen_a)
173anova(Model_null_a,Model_gen_a)
174anova(Model_gen_a)
175
176Model_isi_h <- lme(fixed = Help~ISITot, random = ~1 | ppCode, data = data, method = "ML")
177anova(Model_null_h,Model_isi_h)
178Model_isi_r <- lme(fixed = Return~ISITot, random = ~1 | ppCode, data = data, method = "ML")
179anova(Model_null_r,Model_isi_r)
180Model_isi_a <- lme(fixed = FBH~ISITot, random = ~1 | ppCode, data = data, method = "ML")
181anova(Model_null_a,Model_isi_a)
182
183Model_why_h <- lme(fixed = Help~WhyTxt, random = ~1 | ppCode, data = data, method = "ML")
184anova(Model_null_h,Model_why_h)
185Model_why_r <- lme(fixed = Return~WhyTxt, random = ~1 | ppCode, data = data, method = "ML")
186anova(Model_null_r,Model_why_r)
187Model_why_a <- lme(fixed = FBH~WhyTxt, random = ~1 | ppCode, data = data, method = "ML")
188anova(Model_null_a,Model_why_a)
189
190#Best Route generally
191Model_route_h <- lme(fixed = Help~Route, random = ~1 | ppCode, data = data, method = "ML")
192summary(Model_route_h)
193anova(Model_null_h,Model_route_h)
194anova(Model_route_h)
195Model_route_r <- lme(fixed = Return~Route, random = ~1 | ppCode, data = data, method = "ML")
196summary(Model_route_r)
197anova(Model_null_r,Model_route_r)
198anova(Model_route_r)
199Model_route_a <- lme(fixed = FBH~Route, random = ~1 | ppCode, data = data, method = "ML")
200summary(Model_route_a)
201anova(Model_null_a,Model_route_a)
202anova(Model_route_a)
203
204
205ggplot(data, aes(x=Route, y=FBH)) + geom_density(alpha = 0.3)
206qplot(x=Route, y=FBH,data=data, geom="bar")
207
208
209#HYPOTHESIS1
210
211data2 <-subset(data, (Route == "accept"| Route == "refer"))
212View(data2)
213
214
215ModelH1_0 <- lme(fixed = Help~1, random = ~1 | ppCode, data = data, method = "ML")
216summary(ModelH1_0)
217
218ModelH1_1 <- lme(fixed = Help~ScenSit, random = ~1 | ppCode, data = data, method = "ML")
219summary(ModelH1_1)
220anova(ModelH1_0,ModelH1_1)
221
222ModelH1_2 <- lme(fixed = Help~Route, random = ~1 | ppCode, data = data, method = "ML")
223summary(ModelH1_2)
224anova(ModelH1_0,ModelH1_2)
225
226ModelH1_3 <- lme(fixed = Help~Route+ScenSit, random = ~1 | ppCode, data = data, method = "ML")
227ModelH1_4 <- lme(fixed = Help~Route+ScenSit+Route:ScenSit, random = ~1 | ppCode, data = data, method = "ML")
228summary(ModelH1_4)
229anova(ModelH1_3,ModelH1_4)
230
231ModelH1_3 <- lme(fixed = Help~Route+ScenSit, random = ~1 | ppCode, data = data2, method = "ML")
232ModelH1_4 <- lme(fixed = Help~Route+ScenSit+Route:ScenSit, random = ~1 | ppCode, data = data2, method = "ML")
233summary(ModelH1_4)
234anova(ModelH1_3,ModelH1_4)
235
236
237ModelH1_0 <- lme(fixed = Return~1, random = ~1 | ppCode, data = data, method = "ML")
238summary(ModelH1_0)
239
240ModelH1_1 <- lme(fixed = Return~ScenSit, random = ~1 | ppCode, data = data, method = "ML")
241summary(ModelH1_1)
242anova(ModelH1_0,ModelH1_1)
243
244ModelH1_2 <- lme(fixed = Return~Route, random = ~1 | ppCode, data = data, method = "ML")
245summary(ModelH1_2)
246anova(ModelH1_0,ModelH1_2)
247
248ModelH1_3 <- lme(fixed = Return~Route+ScenSit, random = ~1 | ppCode, data = data, method = "ML")
249ModelH1_4 <- lme(fixed = Return~Route+ScenSit+Route:ScenSit, random = ~1 | ppCode, data = data, method = "ML")
250summary(ModelH1_4)
251anova(ModelH1_3,ModelH1_4)
252
253ModelH1_3 <- lme(fixed = Return~Route+ScenSit, random = ~1 | ppCode, data = data2, method = "ML")
254ModelH1_4 <- lme(fixed = Return~Route+ScenSit+Route:ScenSit, random = ~1 | ppCode, data = data2, method = "ML")
255summary(ModelH1_4)
256anova(ModelH1_3,ModelH1_4)
257
258
259
260ModelH1_0 <- lme(fixed = FBH~1, random = ~1 | ppCode, data = data, method = "ML")
261summary(ModelH1_0)
262
263ModelH1_1 <- lme(fixed = FBH~ScenSit, random = ~1 | ppCode, data = data, method = "ML")
264summary(ModelH1_1)
265anova(ModelH1_0,ModelH1_1)
266
267ModelH1_2 <- lme(fixed = FBH~Route, random = ~1 | ppCode, data = data, method = "ML")
268summary(ModelH1_2)
269anova(ModelH1_0,ModelH1_2)
270
271ModelH1_3 <- lme(fixed = FBH~Route+ScenSit, random = ~1 | ppCode, data = data, method = "ML")
272ModelH1_4 <- lme(fixed = FBH~Route+ScenSit+Route:ScenSit, random = ~1 | ppCode, data = data, method = "ML")
273summary(ModelH1_4)
274anova(ModelH1_3,ModelH1_4)
275
276ModelH1_3 <- lme(fixed = FBH~Route+ScenSit, random = ~1 | ppCode, data = data2, method = "ML")
277ModelH1_4 <- lme(fixed = FBH~Route+ScenSit+Route:ScenSit, random = ~1 | ppCode, data = data2, method = "ML")
278summary(ModelH1_4)
279anova(ModelH1_3,ModelH1_4)
280
281
282#HYPOTHESIS2
283dataH2 <- subset(data, (Systemroute == "motivate"))
284#View(dataH2)
285
286ModelH2_0 <- lme(fixed = Help~1, random = ~1 | ppCode, data = dataH2, method = "ML")
287summary(ModelH2_0)
288
289ModelH2_1 <- lme(fixed = Help~Route, random = ~1 | ppCode, data = dataH2, method = "ML")
290summary(ModelH2_1)
291anova(ModelH2_0,ModelH2_1)
292
293dataH2B <- subset(dataH2, (Route == "motivate" | Route == "refer"))
294
295ModelH2_0B <- lme(fixed = Help~1, random = ~1 | ppCode, data = dataH2B, method = "ML")
296summary(ModelH2_0B)
297
298ModelH2_1B <- lme(fixed = Help~Route, random = ~1 | ppCode, data = dataH2B, method = "ML")
299summary(ModelH2_1B)
300anova(ModelH2_0B,ModelH2_1B)
301
302dataH2C <- subset(dataH2, (Route == "motivate" | Route == "accept"))
303
304ModelH2_0C <- lme(fixed = Help~1, random = ~1 | ppCode, data = dataH2C, method = "ML")
305summary(ModelH2_0C)
306
307ModelH2_1C <- lme(fixed = Help~Route, random = ~1 | ppCode, data = dataH2C, method = "ML")
308summary(ModelH2_1C)
309anova(ModelH2_0C,ModelH2_1C)
310
311
312#HYPOTHESIS3
313dataH3 <- subset(data, (Systemroute == "refer" | Route == "refer"))
314
315ModelH3_0 <- lme(fixed = Help~1, random = ~1 | ppCode, data = dataH3, method = "ML")
316summary(ModelH3_0)
317anova(ModelH3_0)
318
319#HYPOTHESIS4
320dataH4 <- subset(data, (Systemroute == "accept"))
321
322ModelH4_0R <- lme(fixed = Return~1, random = ~1 | ppCode, data = dataH4, method = "ML")
323summary(ModelH4_0R)
324
325ModelH4_1R <- lme(fixed = Return~Route, random = ~1 | ppCode, data = dataH4, method = "ML")
326summary(ModelH4_1R)
327anova(ModelH4_0R, ModelH4_1R)
328
329ModelH4_0A <- lme(fixed = FBH~1, random = ~1 | ppCode, data = dataH4, method = "ML")
330summary(ModelH4_0A)
331
332ModelH4_1A <- lme(fixed = FBH~Route, random = ~1 | ppCode, data = dataH4, method = "ML")
333summary(ModelH4_1A)
334anova(ModelH4_0A, ModelH4_1A)
335
336
337
338dataH4B <- subset(dataH4, (Route == "accept" | Route == "motivate"))
339
340View(dataH4B)
341
342ModelH4_0RB <- lme(fixed = Return~1, random = ~1 | ppCode, data = dataH4B, method = "ML")
343summary(ModelH4_0RB)
344
345ModelH4_1RB <- lme(fixed = Return~Route, random = ~1 | ppCode, data = dataH4B, method = "ML")
346summary(ModelH4_1RB)
347anova(ModelH4_0RB, ModelH4_1RB)
348
349ModelH4_0AB <- lme(fixed = FBH~1, random = ~1 | ppCode, data = dataH4B, method = "ML")
350summary(ModelH4_0AB)
351
352ModelH4_1AB <- lme(fixed = FBH~Route, random = ~1 | ppCode, data = dataH4B, method = "ML")
353summary(ModelH4_1AB)
354anova(ModelH4_0AB, ModelH4_1AB)
355
356
357
358dataH4C <- subset(dataH4, (Route == "accept" | Route == "refer"))
359
360
361ModelH4_0RC <- lme(fixed = Return~1, random = ~1 | ppCode, data = dataH4C, method = "ML")
362summary(ModelH4_0RC)
363
364ModelH4_1RC <- lme(fixed = Return~Route, random = ~1 | ppCode, data = dataH4C, method = "ML")
365summary(ModelH4_1RC)
366anova(ModelH4_0RC, ModelH4_1RC)
367
368ModelH4_0AC <- lme(fixed = FBH~1, random = ~1 | ppCode, data = dataH4C, method = "ML")
369summary(ModelH4_0AC)
370
371ModelH4_1AC <- lme(fixed = FBH~Route, random = ~1 | ppCode, data = dataH4C, method = "ML")
372summary(ModelH4_1AC)
373anova(ModelH4_0AC, ModelH4_1AC)
374
375
376#PRIMARY OUTCOMES
377#Comparison Motivation & System
378
379datacon <- read_excel("PATH/Data_conditionsSM.xlsx")
380#View(datacon)
381
382#Specify levels of MatchSys as 0 or 1
383datacon$MatchSys = factor(datacon$MatchSys,levels=c(0,1))
384#Specify levels for Route as Motiv, Accept or Refer
385datacon$Route = factor(datacon$Route,levels=c("motivate","accept","refer"))
386
387#Specify levels for SubSev as Low, Med, High
388datacon$SubSev = factor(datacon$SubSev,levels=c("Low","Med","High"))
389datacon$SubSev <- ordered(datacon$SubSev)
390#Specify levels of SubMoti as Low, Med, High
391datacon$SubMoti = factor(datacon$SubMoti,levels=c("Low","Med","High"))
392datacon$SubMoti <- ordered(datacon$SubMoti)
393
394#Specify levels for ScenSev as Low, Med, High
395datacon$ScenSev = factor(datacon$ScenSev,levels=c("Low","Med","High"))
396datacon$ScenSev <- ordered(datacon$ScenSev)
397#Specify levels of ScenMoti as Low, Med, High
398datacon$ScenMoti = factor(datacon$ScenMoti,levels=c("Low","Med","High"))
399datacon$ScenMoti <- ordered(datacon$ScenMoti)
400
401datacon$Condition = factor(datacon$Condition,levels=c("motivate","system"))
402datacon$ppCode = factor(datacon$ppCode)
403
404#HELP
405Modelc_h <- lme(fixed = Help~1, random = ~1 | ppCode, data = datacon, method = "ML")
406summary(Modelc_h)
407
408ggplot(datacon, aes(x=Help, fill=Condition)) + geom_density(alpha = 0.3)
409
410#Model effect of Condition on Help
411Modelc_hCon <- lme(fixed = Help~Condition, random = ~1 | ppCode, data = datacon, method = "ML")
412summary(Modelc_hCon)
413#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
414anova(Modelc_h,Modelc_hCon)
415anova(Modelc_hCon)
416
417#Return
418Modelc_r <- lme(fixed = Return~1, random = ~1 | ppCode, data = datacon, method = "ML")
419summary(Modelc_r)
420
421ggplot(datacon, aes(x=Return, fill=Condition)) + geom_density(alpha = 0.3)
422
423#Model effect of Condition on Return
424Modelc_rCon <- lme(fixed = Return~Condition, random = ~1 | ppCode, data = datacon, method = "ML")
425summary(Modelc_rCon)
426#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
427anova(Modelc_r,Modelc_rCon)
428anova(Modelc_rCon)
429
430#ALLI
431Modelc_a <- lme(fixed = FBH~1, random = ~1 | ppCode, data = datacon, method = "ML")
432summary(Modelc_a)
433
434ggplot(datacon, aes(x=FBH, fill=Condition)) + geom_density(alpha = 0.3)
435
436#Model effect of Condition on FBH
437Modelc_aCon <- lme(fixed = FBH~Condition, random = ~1 | ppCode, data = datacon, method = "ML")
438summary(Modelc_aCon)
439#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
440anova(Modelc_a,Modelc_aCon)
441anova(Modelc_aCon)
442
443#Model effect of Condition on FBH
444Modelc_aConGen <- lme(fixed = FBH~Condition+Gen, random = ~1 | ppCode, data = datacon, method = "ML")
445summary(Modelc_aConGen)
446#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
447anova(Modelc_aCon,Modelc_aConGen)
448
449
450
451#Comparison per Accept & Rever route
452#Accept
453dataconA <- read_excel("PATH/Data_conditionsSMaccept.xlsx")
454#View(datacon)
455
456#Specify levels of MatchSys as 0 or 1
457dataconA$MatchSys = factor(dataconA$MatchSys,levels=c(0,1))
458#Specify levels for Route as Motiv, Accept or Refer
459dataconA$Route = factor(dataconA$Route,levels=c("motivate","accept","refer"))
460
461#Specify levels for SubSev as Low, Med, High
462dataconA$SubSev = factor(dataconA$SubSev,levels=c("Low","Med","High"))
463dataconA$SubSev <- ordered(dataconA$SubSev)
464#Specify levels of SubMoti as Low, Med, High
465dataconA$SubMoti = factor(dataconA$SubMoti,levels=c("Low","Med","High"))
466dataconA$SubMoti <- ordered(dataconA$SubMoti)
467
468#Specify levels for ScenSev as Low, Med, High
469dataconA$ScenSev = factor(dataconA$ScenSev,levels=c("Low","Med","High"))
470dataconA$ScenSev <- ordered(dataconA$ScenSev)
471#Specify levels of ScenMoti as Low, Med, High
472dataconA$ScenMoti = factor(dataconA$ScenMoti,levels=c("Low","Med","High"))
473dataconA$ScenMoti <- ordered(dataconA$ScenMoti)
474
475dataconA$Condition = factor(dataconA$Condition,levels=c("motivate","system"))
476dataconA$ppCode = factor(dataconA$ppCode)
477
478#HELP
479Modelc_hA <- lme(fixed = Help~1, random = ~1 | ppCode, data = dataconA, method = "ML")
480summary(Modelc_hA)
481
482ggplot(dataconA, aes(x=Help, fill=Condition)) + geom_density(alpha = 0.3)
483
484#Model effect of Condition on Help
485Modelc_hConA <- lme(fixed = Help~Condition, random = ~1 | ppCode, data = dataconA, method = "ML")
486summary(Modelc_hConA)
487#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
488anova(Modelc_hA,Modelc_hConA)
489anova(Modelc_hConA)
490
491#Return
492Modelc_rA <- lme(fixed = Return~1, random = ~1 | ppCode, data = dataconA, method = "ML")
493summary(Modelc_rA)
494
495ggplot(dataconA, aes(x=Return, fill=Condition)) + geom_density(alpha = 0.3)
496
497#Model effect of Condition on Return
498Modelc_rConA <- lme(fixed = Return~Condition, random = ~1 | ppCode, data = dataconA, method = "ML")
499summary(Modelc_rConA)
500#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
501anova(Modelc_rA,Modelc_rConA)
502anova(Modelc_rConA)
503
504#ALLI
505Modelc_aA <- lme(fixed = FBH~1, random = ~1 | ppCode, data = dataconA, method = "ML")
506summary(Modelc_aA)
507
508ggplot(dataconA, aes(x=FBH, fill=Condition)) + geom_density(alpha = 0.3)
509
510#Model effect of Condition on FBH
511Modelc_aConA <- lme(fixed = FBH~Condition, random = ~1 | ppCode, data = dataconA, method = "ML")
512summary(Modelc_aConA)
513#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
514anova(Modelc_aA,Modelc_aConA)
515anova(Modelc_aConA)
516
517
518#REFER
519dataconR <- read_excel("PATH/Data_conditionsSMrefer.xlsx")
520#View(datacon)
521
522#Specify levels of MatchSys as 0 or 1
523dataconR$MatchSys = factor(dataconR$MatchSys,levels=c(0,1))
524#Specify levels for Route as Motiv, Accept or Refer
525dataconR$Route = factor(dataconR$Route,levels=c("motivate","accept","refer"))
526
527#Specify levels for SubSev as Low, Med, High
528dataconR$SubSev = factor(dataconR$SubSev,levels=c("Low","Med","High"))
529dataconR$SubSev <- ordered(dataconR$SubSev)
530#Specify levels of SubMoti as Low, Med, High
531dataconR$SubMoti = factor(dataconR$SubMoti,levels=c("Low","Med","High"))
532dataconR$SubMoti <- ordered(dataconR$SubMoti)
533
534#Specify levels for ScenSev as Low, Med, High
535dataconR$ScenSev = factor(dataconR$ScenSev,levels=c("Low","Med","High"))
536dataconR$ScenSev <- ordered(dataconR$ScenSev)
537#Specify levels of ScenMoti as Low, Med, High
538dataconR$ScenMoti = factor(dataconR$ScenMoti,levels=c("Low","Med","High"))
539dataconR$ScenMoti <- ordered(dataconR$ScenMoti)
540
541dataconR$Condition = factor(dataconR$Condition,levels=c("motivate","system"))
542dataconR$ppCode = factor(dataconR$ppCode)
543
544#HELP
545Modelc_hR <- lme(fixed = Help~1, random = ~1 | ppCode, data = dataconR, method = "ML")
546summary(Modelc_hR)
547
548ggplot(dataconR, aes(x=Help, fill=Condition)) + geom_density(alpha = 0.3)
549
550#Model effect of Condition on Help
551Modelc_hConR <- lme(fixed = Help~Condition, random = ~1 | ppCode, data = dataconR, method = "ML")
552summary(Modelc_hConR)
553#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
554anova(Modelc_hR,Modelc_hConR)
555anova(Modelc_hConR)
556
557#Return
558Modelc_rR <- lme(fixed = Return~1, random = ~1 | ppCode, data = dataconR, method = "ML")
559summary(Modelc_rR)
560
561ggplot(dataconR, aes(x=Return, fill=Condition)) + geom_density(alpha = 0.3)
562
563#Model effect of Condition on Return
564Modelc_rConR <- lme(fixed = Return~Condition, random = ~1 | ppCode, data = dataconR, method = "ML")
565summary(Modelc_rConR)
566#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
567anova(Modelc_rR,Modelc_rConR)
568anova(Modelc_rConR)
569
570#ALLI
571Modelc_aR <- lme(fixed = FBH~1, random = ~1 | ppCode, data = dataconR, method = "ML")
572summary(Modelc_aR)
573
574ggplot(dataconR, aes(x=FBH, fill=Condition)) + geom_density(alpha = 0.3)
575
576#Model effect of Condition on FBH
577Modelc_aConR <- lme(fixed = FBH~Condition, random = ~1 | ppCode, data = dataconR, method = "ML")
578summary(Modelc_aConR)
579#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
580anova(Modelc_aR,Modelc_aConR)
581anova(Modelc_aConR)
582
583
584
585
586
587
588
589
590
591
592#REGION WHY NOT
593ggplot(data, aes(x=Help, fill=WhyTxt)) + geom_density(alpha = 0.3)
594ggplot(data, aes(x=FBH, fill=WhyTxt)) + geom_density(alpha = 0.3)
595ggplot(data, aes(x=Return, fill=WhyTxt)) + geom_density(alpha = 0.3)
596
597Model_null_h <- lme(fixed = Help~1, random = ~1 | ppCode, data = data, method = "ML")
598summary(Model_null_h)
599Model_W_h<- lme(fixed = Help~WhyTxt, random = ~1 | ppCode, data = data, method = "ML")
600summary(Model_W_h)
601anova(Model_null_h,Model_W_h)
602
603Model_null_a <- lme(fixed = FBH~1, random = ~1 | ppCode, data = data, method = "ML")
604summary(Model_null_a)
605Model_W_a<- lme(fixed = FBH~WhyTxt, random = ~1 | ppCode, data = data, method = "ML")
606summary(Model_W_a)
607anova(Model_null_a,Model_W_a)
608
609Model_null_r <- lme(fixed = Return~1, random = ~1 | ppCode, data = data, method = "ML")
610summary(Model_null_r)
611Model_W_r<- lme(fixed = Return~WhyTxt, random = ~1 | ppCode, data = data, method = "ML")
612summary(Model_W_r)
613anova(Model_null_r,Model_W_r)
614
615
616
617
618#REGION ISI + age Stats
619mean(data$ISITot)
620sd(data$ISITot)
621
622mean(data$Age)
623sd(data$Age)
624
625#Correlations ISI&Gender + ISI & Age
626datapp <- read_excel("PATH/ppData.xlsx")
627View(datapp)
628datapp$Gen = factor(datapp$Gen,levels=c("F","M"))
629spearman.test(datapp$Gen,datapp$ISITot)
630spearman.test(datapp$Age,datapp$ISITot)
631
632#Correlation Return & Allia & HELP
633spearman.test(data$FBH,data$Return)
634spearman.test(data$Help,data$Return)
635spearman.test(data$FBH,data$Help)
636
637
638
639
640
641#REGION ALLIANCE
642
643#Null model for Agent Attitude
644Model_null_aa <- lme(fixed = FBH~1, random = ~1 | ppCode, data = data, method = "ML")
645summary(Model_null_aa)
646
647Model_ISI_aa<- lme(fixed = FBH~Age, random = ~1 | ppCode, data = data, method = "ML")
648summary(Model_ISI_aa)
649
650anova(Model_null_aa,Model_ISI_aa)
651
652#Model effect of MatchSys on Agent Attitude
653Model_MatchSys_aa <- lme(fixed = FBH~MatchSys, random = ~1 | ppCode, data = data, method = "ML")
654summary(Model_MatchSys_aa)
655#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
656anova(Model_null_aa,Model_MatchSys_aa)
657
658#Model effect of Route on Agent Attitude
659Model_route_aa <- lme(fixed = FBH~Route, random = ~1 | ppCode, data = data, method = "ML")
660summary(Model_route_aa)
661#Vergelijk of model route_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
662anova(Model_null_aa,Model_route_aa)
663
664#Model effect of Route & MatchSys on Agent Attitude
665Model_routeMatchSys_aa<- lme(fixed = FBH~Route+MatchSys, random = ~1 | ppCode, data = data, method = "ML")
666summary(Model_routeMatchSys_aa)
667#Vergelijk of model routeMatchSys_aa beter 'MatchSys' heeft dan model route. Lagere logLik is betere MatchSys
668anova(Model_route_aa,Model_routeMatchSys_aa)
669
670#Model effect of Route & MatchSys & ScenSev on Agent Attitude
671Model_routeMatchSyssev_aa<- lme(fixed = FBH~Route+MatchSys+ScenSev, random = ~1 | ppCode, data = data, method = "ML")
672summary(Model_routeMatchSyssev_aa)
673#Vergelijk of model routeMatchSyssev_aa beter 'MatchSys' heeft dan model routeMatchSys_aa. Lagere logLik is betere MatchSys
674anova(Model_routeMatchSys_aa,Model_routeMatchSyssev_aa)
675
676#Model effect of Route & MatchSys & ScenSev on Agent Attitude
677Model_routeMatchSevMoti_aa<- lme(fixed = FBH~Route+MatchSys+ScenSev+ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
678summary(Model_routeMatchSevMoti_aa)
679#Vergelijk of model routeMatchSyssev_aa beter 'MatchSys' heeft dan model routeMatchSys_aa. Lagere logLik is betere MatchSys
680anova(Model_routeMatchSys_aa,Model_routeMatchSevMoti_aa)
681
682
683#InterHelp effects lme (doesn't work...)
684#Model_interHelp1 <- lme(fixed = FBH~Route:ScenSev:ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
685#Model_interHelp2 <- lme(fixed = FBH~Route:ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
686
687#InterHelp effects lmer (werkt maar met waarschuwing) -
688Model_interHelp3 <- lmer(FBH~Route:ScenSev:ScenMoti +(1|ppCode), data = data)
689summary(Model_interHelp3)
690
691#Full model Route, MatchSys & ScenSev + interaction effects on Agent Attitude
692Model_full_aa <- lme(fixed = FBH~Route+ScenSev+ScenMoti+Route:ScenSev+Route:ScenMoti+ScenSev:ScenMoti+Route:ScenSev:ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
693summary(Model_full_aa)
694
695
696
697#REGION Help
698
699#Null model for Help
700Model_null_a <- lme(fixed = Help~1, random = ~1 | ppCode, data = data, method = "ML")
701summary(Model_null_a)
702
703Model_ISI_h<- lme(fixed = Help~Age, random = ~1 | ppCode, data = data, method = "ML")
704summary(Model_ISI_h)
705
706anova(Model_null_a,Model_ISI_h)
707
708#Model effect of MatchSys on Help
709Model_MatchSys_a <- lme(fixed = Help~MatchSys, random = ~1 | ppCode, data = data, method = "ML")
710summary(Model_MatchSys_a)
711#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
712anova(Model_null_a,Model_MatchSys_a)
713
714#Model effect of Route on Help
715Model_route_a <- lme(fixed = Help~Route, random = ~1 | ppCode, data = data, method = "ML")
716summary(Model_route_a)
717#Vergelijk of model route_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
718anova(Model_null_a,Model_route_a)
719
720#Model effect of Route & MatchSys on Help
721Model_routeMatchSys_a<- lme(fixed = Help~Route+MatchSys, random = ~1 | ppCode, data = data, method = "ML")
722summary(Model_routeMatchSys_a)
723#Vergelijk of model routeMatchSys_a beter 'MatchSys' heeft dan model route. Lagere logLik is betere MatchSys
724anova(Model_route_a,Model_routeMatchSys_a)
725
726#Model effect of Route & MatchSys & ScenSevon Help
727Model_routeMatchSyssev_a<- lme(fixed = Help~Route+MatchSys+ScenSev, random = ~1 | ppCode, data = data, method = "ML")
728summary(Model_routeMatchSyssev_a)
729#Vergelijk of model routeMatchSyssev_a beter 'MatchSys' heeft dan model routeMatchSys_a. Lagere logLik is betere MatchSys
730anova(Model_routeMatchSys_a,Model_routeMatchSyssev_a)
731
732#Model effect of Route & MatchSys & ScenSevon Help
733Model_routeMatchSevMoti_a<- lme(fixed = Help~Route+MatchSys+ScenSev+ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
734summary(Model_routeMatchSevMoti_a)
735#Vergelijk of model routeMatchSyssev_a beter 'MatchSys' heeft dan model routeMatchSys_a. Lagere logLik is betere MatchSys
736anova(Model_routeMatchSys_a,Model_routeMatchSevMoti_a)
737
738#InterHelp effects lme (doesn't work...)
739#Model_interHelp1 <- lme(fixed = Help~Route:ScenSev:ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
740#Model_interHelp2 <- lme(fixed = Help~Route:ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
741
742#InterHelp effects lmer (werkt maar met waarschuwing) -
743Model_interHelp3 <- lmer(Help~Route:ScenSev:ScenMoti +(1|ppCode), data = data)
744summary(Model_interHelp3)
745
746#Full model Route, MatchSys & ScenSev + interHelp effects on Help
747Model_full_a <- lme(fixed = Help~Route+ScenSev+ScenMoti+Route:ScenSev+Route:ScenMoti+ScenSev:ScenMoti+Route:ScenSev:ScenMoti, random = ~1 | ppCode, data = data, method = "ML")
748summary(Model_full_a)
749
750
751#REGION
752#Null model for Return
753Model_null_r <- lme(fixed = Return~1, random = ~1 | ppCode, data = data, method = "ML")
754summary(Model_null_r)
755
756Model_ISI_r<- lme(fixed = Return~Age, random = ~1 | ppCode, data = data, method = "ML")
757summary(Model_ISI_r)
758
759anova(Model_null_r,Model_ISI_r)
760
761#Model effect of MatchSys on Help
762Model_MatchSys_a <- lme(fixed = Help~MatchSys, random = ~1 | ppCode, data = data, method = "ML")
763summary(Model_MatchSys_a)
764#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
765anova(Model_null_a,Model_MatchSys_a)
766
767
768
769
770
771#Conditions SYSTEM VS MOTIVATION
772datacon <- read_excel("PATH/Data_conditionsSM.xlsx")
773#View(datacon)
774
775#Specify levels of MatchSys as 0 or 1
776datacon$MatchSys = factor(datacon$MatchSys,levels=c(0,1))
777#Specify levels for Route as Motiv, Accept or Refer
778datacon$Route = factor(datacon$Route,levels=c("motivate","accept","refer"))
779
780#Specify levels for SubSev as Low, Med, High
781datacon$SubSev = factor(datacon$SubSev,levels=c("Low","Med","High"))
782datacon$SubSev <- ordered(datacon$SubSev)
783#Specify levels of SubMoti as Low, Med, High
784datacon$SubMoti = factor(datacon$SubMoti,levels=c("Low","Med","High"))
785datacon$SubMoti <- ordered(datacon$SubMoti)
786
787#Specify levels for ScenSev as Low, Med, High
788datacon$ScenSev = factor(datacon$ScenSev,levels=c("Low","Med","High"))
789datacon$ScenSev <- ordered(datacon$ScenSev)
790#Specify levels of ScenMoti as Low, Med, High
791datacon$ScenMoti = factor(datacon$ScenMoti,levels=c("Low","Med","High"))
792datacon$ScenMoti <- ordered(datacon$ScenMoti)
793
794datacon$Condition = factor(datacon$Condition,levels=c("motivate","system"))
795datacon$ppCode = factor(datacon$ppCode)
796
797
798#HELP
799
800#Null
801Model_h <- lme(fixed = Help~1, random = ~1 | ppCode, data = datacon, method = "ML")
802summary(Model_h)
803
804ggplot(datacon, aes(x=Help, fill=Condition)) + geom_density(alpha = 0.3)
805
806#Model effect of Condition on Help
807Model_hCon <- lme(fixed = Help~Condition, random = ~1 | ppCode, data = datacon, method = "ML")
808summary(Model_hCon)
809#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
810anova(Model_h,Model_hCon)
811
812#Model effect of Condition on Help
813Model_hConISI <- lme(fixed = Help~Condition+Gen, random = ~1 | ppCode, data = datacon, method = "ML")
814summary(Model_hConISI)
815#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
816anova(Model_hCon,Model_hConISI)
817
818
819ggplot(datacon, aes(x=Help, fill=Systemroute)) + geom_density(alpha = 0.3)
820
821#Model effect of Condition+route on Help
822Model_hConSys <- lme(fixed = Help~Condition+Systemroute, random = ~1 | ppCode, data = datacon, method = "ML")
823summary(Model_hConSys)
824#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
825anova(Model_hCon,Model_hConSys)
826
827#Model effect of Condition+route on Help
828Model_hConSysInt <- lme(fixed = Help~Condition+Systemroute+Condition:Systemroute, random = ~1 | ppCode, data = datacon, method = "ML")
829summary(Model_hConSysInt)
830#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
831anova(Model_hConSys,Model_hConSysInt)
832
833#Model effect of Condition+route on Help
834Model_hConSysInta <- lmer(Help~ScenMoti:ScenSev:Route+ (1|ppCode), data = data)
835summary(Model_hConSysInta)
836#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
837anova(Model_hConSysInta)
838
839
840
841anova(Model_hConSysInt)
842
843
844#RETURN
845
846#Null
847Model_r <- lme(fixed = Return~1, random = ~1 | ppCode, data = datacon, method = "ML")
848summary(Model_r)
849
850ggplot(datacon, aes(x=Return, fill=Condition)) + geom_density(alpha = 0.3)
851
852#Model effect of Condition on Help
853Model_rCon <- lme(fixed = Return~Condition, random = ~1 | ppCode, data = datacon, method = "ML")
854summary(Model_rCon)
855#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
856anova(Model_r,Model_rCon)
857
858#Model effect of Condition on Help
859Model_rConISI <- lme(fixed = Return~Condition+Gen, random = ~1 | ppCode, data = datacon, method = "ML")
860summary(Model_rConISI)
861#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
862anova(Model_rCon,Model_rConISI)
863
864ggplot(datacon, aes(x=Return, fill=Systemroute)) + geom_density(alpha = 0.3)
865
866#Model effect of Condition+route on Help
867Model_rConSys <- lme(fixed = Return~Condition+Systemroute, random = ~1 | ppCode, data = datacon, method = "ML")
868summary(Model_rConSys)
869#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
870anova(Model_rCon,Model_rConSys)
871
872
873#ALLIANCE
874
875#Null
876Model_a <- lme(fixed = FBH~1, random = ~1 | ppCode, data = datacon, method = "ML")
877summary(Model_a)
878
879ggplot(datacon, aes(x=FBH, fill=Condition)) + geom_density(alpha = 0.3)
880
881#Model effect of Condition on Help
882Model_aCon <- lme(fixed = FBH~Condition, random = ~1 | ppCode, data = datacon, method = "ML")
883summary(Model_aCon)
884#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
885anova(Model_a,Model_aCon)
886
887#Model effect of Condition on Help
888Model_aConISI <- lme(fixed = FBH~Condition+Gen, random = ~1 | ppCode, data = datacon, method = "ML")
889summary(Model_aConISI)
890#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
891anova(Model_aCon,Model_aConISI)
892
893ggplot(datacon, aes(x=FBH, fill=Systemroute)) + geom_density(alpha = 0.3)
894
895#Model effect of Condition+route on Help
896Model_aConSys <- lme(fixed = FBH~Condition+Systemroute, random = ~1 | ppCode, data = datacon, method = "ML")
897summary(Model_aConSys)
898#Vergelijk of model MatchSys_aa beter 'MatchSys' heeft dan model test. Lagere logLik is betere MatchSys
899anova(Model_aCon,Model_aConSys)
900
Note: See TracBrowser for help on using the repository browser.