-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData_processing_and_assumption_checks.Rmd
179 lines (137 loc) · 5.17 KB
/
Data_processing_and_assumption_checks.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
title: "Data processing"
author: "Christoph Völtzke"
date: "2023-01-25"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(haven)
library(tidyverse)
library(car)
library(ggplot2)
```
```{r}
data <- read_sav("Data/BA_AUswertung_final.sav")
```
```{r}
data <- data %>%
mutate(NFHI = mean(Q3_1,Q3_2,Q3_3),
Customer_sat = mean(Q25_1,Q25_2,Q25_3),
Perc_cont = mean(Q26_1,Q26_2,Q26_3),
Social_pres = mean(Q27_1,Q27_2,Q27_3,Q27_4,Q27_5),
Product_inv = mean(Q31_1,Q31_2,Q31_3)) %>%
rename(Age = Alter,
Orga_perc = OP,
Behav_Int = BI,
Chat_use = CA_U,
Message_Int = HighMI,
Task_Type = HL
) %>%
mutate(Message_Int_n = as.numeric(Message_Int),
Task_Type_n = as.numeric(Task_Type),
Message_Int = case_when(
Message_Int == 0 ~ "Low_MI",
Message_Int == 1 ~ "Hi_MI"),
Task_Type = case_when(
Task_Type == 0 ~ "Comp",
Task_Type == 1 ~ "Human"),
Message_Int = as.factor(Message_Int),
Task_Type = as.factor(Task_Type),
Gender = as.factor(Geschlecht),
Degree = as.factor(Abschluss),
Q_Gruppe = case_when(
Q_Gruppe == 1 ~ "HighMI_HL",
Q_Gruppe == 2 ~ "LowMI_HL",
Q_Gruppe == 3 ~ "HighMI_CL",
Q_Gruppe == 4 ~ "LowMI_CL"),
Condition = as.factor(Q_Gruppe),
Customer_sat = as.numeric(Customer_sat),
Orga_perc = as.numeric(Orga_perc),
Behav_Int = as.numeric(Behav_Int),
Perc_cont = as.numeric(Perc_cont),
Social_pres = as.numeric(Social_pres),
Product_inv = as.numeric(Product_inv),
Chat_use = as.numeric(Chat_use),
NFHI = as.numeric(NFHI),
replace_na(Age, mean(Age))
) %>%
filter(Duration__in_seconds_ >= 120) %>%
filter(Gender == 1 | Gender == 2) %>%
select(Condition,Message_Int,Task_Type,Age,Gender,Degree,Customer_sat,Orga_perc,Behav_Int,NFHI,Perc_cont,Social_pres,Product_inv,Chat_use,Message_Int_n,Task_Type_n)
```
```{r}
write.csv(data, "Data/data.csv")
```
## Check for Assumptions
Main DV = Customer_sat
Secondary outcomes = Social_pres,Perc_cont
Main IVs = Message_Int,Task_Type (2x2 Design)
Moderator = NFHI
Mediators = Social_pres,Perc_cont
Covariates = Product_inv, Chat_use
### Homogeneity of Variances
```{r}
plot(data$Message_Int,data$Customer_sat)
leveneTest(lm(Customer_sat ~ Message_Int, data= data))
plot(data$Task_Type,data$Customer_sat)
leveneTest(lm(Customer_sat ~ Task_Type, data= data))
```
The plots show some difference in variance, but it is not too extreme. Moreover, some outliers are detected and the Levene test for Message Int is significant. However, as it is an experimental design this should be okay.
### Linearity
```{r}
plot(data$Customer_sat,data$NFHI)
plot(data$Customer_sat,data$Perc_cont)
plot(data$Customer_sat,data$Social_pres)
plot(data$Customer_sat,data$Product_inv)
plot(data$Customer_sat,data$Chat_use)
```
All relations between IV and DV look reasonably linear.
### Multicollinearity
```{r}
cor(data[c(7, 11:15)], use="pairwise.complete.obs")
model <- lm(Customer_sat ~ Message_Int + Task_Type + Perc_cont + Social_pres + NFHI + Product_inv + Chat_use, data = data)
#ask for the vif
vif(model)
```
All VIF values are smaller than 10, which indicates no problems with collinearity.
### Normality, possible outliers, and homoscedasticity of residuals
```{r}
plot(model)
```
1. The residual-fitted plot shows whether the relationship between variables is linear and whether there is equal variance (homoscedasticity) along the regression lines. Here, residual-fitted plot looks homoscedestic and linear.
2. The QQ plot looks okay although we see some deviations from the gray line in the upper right corner.
3. The scale-location plot shows if the residuals are spread equally along the predictor range (homoscedastic); this is indicates by the horizontal line with equally spread points
4. The residuals vs leverage plots help identify influential data points. Values that appear in the upper right or lower left corner behind the red Cook’s distance line are points that would be considered influential.
We could conclude that assumptions for the regression analysis are met.
### Homogeneity of regression slopes
Specific assumptions for ANCOVA, since covariates are included in the analyses.
```{r}
data %>%
ggplot(aes(y=Customer_sat, x = Product_inv, colour=(Message_Int))) +
geom_point()+
geom_smooth(method = "lm", se=FALSE) +
xlab("Product_inv") +
ylab("Customer_sat")
data %>%
ggplot(aes(y=Customer_sat, x = Chat_use, colour=(Message_Int))) +
geom_point()+
geom_smooth(method = "lm", se=FALSE) +
xlab("Chat_use") +
ylab("Customer_sat")
data %>%
ggplot(aes(y=Customer_sat, x = Product_inv, colour=(Task_Type))) +
geom_point()+
geom_smooth(method = "lm", se=FALSE) +
xlab("Product_inv") +
ylab("Customer_sat")
data %>%
ggplot(aes(y=Customer_sat, x = Chat_use, colour=(Task_Type))) +
geom_point()+
geom_smooth(method = "lm", se=FALSE) +
xlab("Chat_use") +
ylab("Customer_sat")
```
Plots look okay. Only for Task Type and Product involvement the slopes are going in different directions.