-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-Visualisations-Understanding-the-data.Rmd
215 lines (141 loc) · 10.3 KB
/
03-Visualisations-Understanding-the-data.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Understanding the Data
In the following section we will try to understand the data. To that end, we first create multiple visualisations of all important variables. We hereby restrict ourselves to visualising the data the main analyses will be based on. As stated in the pre-registration, we conduct our main analyses based on all participants who completed at least 50% of the daily surveys.
## Preparations
Now, we can create a new dataframe containing only participants who completed more than 50% of all surveys (17.5, rounded up = 18)
```{r Select18, echo = TRUE}
#select only participants with 18 or higher
df_analysis18 <- subset(df, df$Surveys.completed >= 18)
```
Next, we scale all our continuous independent variables.
```{r Scaling, echo = TRUE}
df_analysis18$StructureForSolitudeIndividualScaled <- scale(df_analysis18$StructureForSolitudeIndividual)
df_analysis18$DayLevelIntentionalitySolitudeScaled <- scale(df_analysis18$DayLevelIntentionalitySolitude)
df_analysis18$DayLevelNatureScaled <- scale(df_analysis18$DayLevelNature)
df_analysis18$DayLevelStructureSolitudeScaled <- scale(df_analysis18$DayLevelStructureSolitude)
```
## Variable Overview
Below you can find an overview and a summary over all central variables used in the analyses. More detailled descriptions of the variables can also be found in the pre-registration (https://osf.io/efn3h/). Variables with `day`in the name always code the average score of all measurements taken on the same day.
### ESM Measurements
`Alone`: Codes whether participant where alone or in a social situation at the time they completed the survey. `0` indicates that they were not alone, `1` indicates that they were alone.
```{r AloneDesc, echo = FALSE}
summary(df_analysis18$Alone)
```
`DayLevelStructureSolitude`: Codes whether participants had any goal they wanted to direct their attention to while being alone. A higher score indicates more structure. `DayLevelStructureSolitudeScaled` is the scaled version of this variable.
```{r DayStructureDesc, echo = FALSE}
summary(df_analysis18$DayLevelStructureSolitude)
```
`DayLevelIntentionalitySolitude`: Codes whether participants were purposefully alone or whether they wished they were interacting with someone. `DayLevelIntentionalitySolitudeScaled` is the scaled version of this variable.
```{r DayIntentionalityDesc, echo = FALSE}
summary(df_analysis18$DayLevelIntentionalitySolitude)
```
`DayLevelNature`: Codes whether participants were in a natural or a built environment. A higher score indicates a more natural environment. `DayLevelNatureScaled`is the scaled version of this variable.
```{r DayNatureDesc, echo = FALSE}
summary(df_analysis18$DayLevelNature)
```
`SubjDay`: This variable codes the combination of subject and day following https://psyarxiv.com/xf2pw/
`LowArousalNegativeAffectMean`: Mean score of 7 affect items. Higher scores indicate higher mean levels of this affect type. The items used to create the mean scores of all affect variables can be viewed on https://osf.io/wuqy9/.
```{r LowNegDesc, echo = FALSE}
summary(df_analysis18$LowArousalNegativeAffectMean)
```
`HighArousalNegativeAffectMean`: Mean score of 9 affect items. Higher scores indicate higher mean levels of this affect type.
```{r HighNegDesc, echo = FALSE}
summary(df_analysis18$HighArousalNegativeAffectMean)
```
`LowArousalPositiveAffectMean`: Means score of 7 affect items. Higher scores indicate higher mean levels of this affect type.
```{r LowPosDesc, echo = FALSE}
summary(df_analysis18$LowArousalPositiveAffectMean)
```
`HighArousalPositiveAffectMean`: Mean score of 9 affect items. Higher scores indicate higher mean levels of this affect type.
```{r HighPosDesc, echo = FALSE}
summary(df_analysis18$HighArousalPositiveAffectMean)
```
### Person-level Measurements
`StructureForSolitudeIndividual`: Summaryscore of 5-item questionnaire about structure for solitude. One measurement per individual. `StructureForSolitudeIndividualScaled` is the scaled version of this variable.
```{r PersonStructureDesc}
summary(df_analysis18$StructureForSolitudeIndividual)
```
## Visualisations
First, we begin to look at the data by looking at the densityplots for each dependent variable by level of ` Alone`.
```{r Qplots, warning=FALSE}
qplot (LowArousalNegativeAffectMean, data = df_analysis18, geom = "density", color = Alone)
qplot (LowArousalPositiveAffectMean, data = df_analysis18, geom = "density", color = Alone)
qplot (HighArousalNegativeAffectMean, data = df_analysis18, geom = "density", color = Alone)
qplot (HighArousalPositiveAffectMean, data = df_analysis18, geom = "density", color = Alone)
```
Next, we visualise some individual differences among our participants using xyplots.
```{r XYplots}
#visualise individual differences among participants
lattice::xyplot(LowArousalNegativeAffectMean ~ Alone | Participant.ID, strip = FALSE, data = df_analysis18, na.rm = TRUE)
lattice::xyplot(LowArousalPositiveAffectMean ~ Alone | Participant.ID, strip = FALSE, data = df_analysis18, na.rm = TRUE)
lattice::xyplot(HighArousalNegativeAffectMean ~ Alone | Participant.ID, strip = FALSE, data = df_analysis18, na.rm = TRUE)
lattice::xyplot(HighArousalPositiveAffectMean ~ Alone | Participant.ID, strip = FALSE, data = df_analysis18, na.rm = TRUE)
```
Afterwards, we check the correlations of each dependent variable with the moderator day-level exposure to nature.
```{r NaturePlots}
#Correlation of Nature with Each Outcome Variable for each level of alone
ggplot(data = df_analysis18, aes(LowArousalNegativeAffectMean, DayLevelNatureScaled, colour = Alone, na.rm = TRUE)) + geom_point(na.rm = TRUE) + geom_smooth(method = "lm", na.rm = TRUE)
ggplot(data = df_analysis18, aes(LowArousalPositiveAffectMean, DayLevelNatureScaled, colour = Alone, na.rm = TRUE)) + geom_point(na.rm = TRUE) + geom_smooth(method = "lm", na.rm = TRUE)
ggplot(data = df_analysis18, aes(HighArousalNegativeAffectMean, DayLevelNatureScaled, colour = Alone, na.rm = TRUE)) + geom_point(na.rm = TRUE) + geom_smooth(method = "lm", na.rm = TRUE)
ggplot(data = df_analysis18, aes(HighArousalPositiveAffectMean, DayLevelNatureScaled, colour = Alone, na.rm = TRUE)) + geom_point(na.rm = TRUE) + geom_smooth(method = "lm", na.rm = TRUE)
```
And now for day-level intentionality.
```{r Intentionalityplots}
#Correlation of DayLevelIntentionality with Outcome (we only calculate these for alone anyway, so the above graphs would not make sense)
ggscatter(df_analysis18, x = "LowArousalNegativeAffectMean", y = "DayLevelIntentionalitySolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "LowArousalNegativeAffectMean", ylab = "DayLevelIntentionalitySolitudeScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "LowArousalPositiveAffectMean", y = "DayLevelIntentionalitySolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "LowArousalPositiveAffectMean", ylab = "DayLevelIntentionalitySolitudeScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "HighArousalNegativeAffectMean", y = "DayLevelIntentionalitySolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "HighArousalNegativeAffectMean", ylab = "DayLevelIntentionalitySolitudeScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "HighArousalPositiveAffectMean", y = "DayLevelIntentionalitySolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "HighArousalPositiveAffectMean", ylab = "DayLevelIntentionalitySolitudeScaled", na.rm = TRUE)
```
And for day-level structure.
```{r DayStructurePlots}
#Correlation of DayLevelStructureSolitude with Outcome
ggscatter(df_analysis18, x = "LowArousalNegativeAffectMean", y = "DayLevelStructureSolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "LowArousalNegativeAffectMean", ylab = "DayLevelStructureSolitudeScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "LowArousalPositiveAffectMean", y = "DayLevelStructureSolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "LowArousalPositiveAffectMean", ylab = "DayLevelStructureSolitudeScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "HighArousalNegativeAffectMean", y = "DayLevelStructureSolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "HighArousalNegativeAffectMean", ylab = "DayLevelStructureSolitudeScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "HighArousalPositiveAffectMean", y = "DayLevelStructureSolitudeScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "HighArousalPositiveAffectMean", ylab = "DayLevelStructureSolitudeScaled", na.rm = TRUE)
```
And for individual-level structure.
```{r IndividualStructurePlots}
#Correlation of IndividualLevelStructure
#Note: This has much more data than the two above, because there are not many alone periods.
ggscatter(df_analysis18, x = "LowArousalNegativeAffectMean", y = "StructureForSolitudeIndividualScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "LowArousalNegativeAffectMean", ylab = "StructureForSolitudeIndividualScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "LowArousalPositiveAffectMean", y = "StructureForSolitudeIndividualScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "LowArousalPositiveAffectMean", ylab = "StructureForSolitudeIndividualScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "HighArousalNegativeAffectMean", y = "StructureForSolitudeIndividualScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "HighArousalNegativeAffectMean", ylab = "StructureForSolitudeIndividualScaled", na.rm = TRUE)
ggscatter(df_analysis18, x = "HighArousalPositiveAffectMean", y = "StructureForSolitudeIndividualScaled",
add = "reg.line", conf.int = TRUE,
cor.coef = TRUE, cor.method = "pearson",
xlab = "HighArousalPositiveAffectMean", ylab = "StructureForSolitudeIndividualScaled", na.rm = TRUE)
```