-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
243 lines (184 loc) · 10.7 KB
/
README.Rmd
File metadata and controls
243 lines (184 loc) · 10.7 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
---
title: "EMAeval Description"
author: "Noah Kraus"
date: "11/03/2020"
output: rmarkdown::github_document
always_allow_html: TRUE
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# EMAeval R Markdown
The R package EMAeval contains functions created to help researchers identify careless responses as well as responders ine EMA data. An example dataset is included in the package to help the user better understand the uses of each function. This dataset "EMAeval_Data" is used in the example code below.
There are 4 "participants," each having 50 assessments. Each was asked 8 questions per assessment.
```{r message=FALSE, warning=FALSE,echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
knitr::opts_chunk$set(opts.label="kill_prefix")
EMAeval_Data <- EMAeval::EMAeval_Data
kable(EMAeval_Data[c(1,56,111,172),], caption = "EMAeval_Data Example", row.names = TRUE) %>%
kable_styling()
```
# Functions
Below are the functions in the R package EMAeval. The functions are:
* flagging_df
* flagging_plots
* TPI_cutoff
* SD_cutoff
* Perc_Mode_cutoff
* Combined_cutoff
* Combined_cutoff_percent
Each section will be dedicated to a particular function, giving an example of the usage with the EMAeval_Data and showing the output.
## flagging_df
*This function creates a dataframe that reports Time to Complete (TTC), Time per Item (TPI), Item Standard Deviation (SD), and Longstring. If the Longstring returns NA, then there was no longstring response because all item responses were different. The partial results of the flagging_df function are based from the EMAeval_Data Example above. *
``` {r eval = FALSE}
flaggingDF <- flagging_df(EMAeval_Data,
ttc.colnames = c("StartDate", "EndDate"),
item.colnames = colnames(EMAeval_Data[,4:11]))
```
```{r message=FALSE, warning=FALSE, echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
flaggingDF <- flagging_df(EMAeval_Data, ttc.colnames = c("StartDate", "EndDate"), item.colnames = colnames(EMAeval_Data[,4:11]))
kable(flaggingDF[c(1,56,111,172),], caption = "Flagging Dataframe Example", row.names = TRUE) %>%
kable_styling()
```
## flagging_plots
*This function creates a histograms of each of the calculations reported in the flagging_df function. This can be used to help users identify the cutoff values for TPI and SD.*
``` {r eval = FALSE}
flagging_plots(EMAeval_Data,
ttc.colnames = c("StartDate", "EndDate"),
item.colnames = colnames(EMAeval_Data[,4:11]),
number.items = 8)
```
```{r message=FALSE, warning=FALSE, fig.align="center", fig.width=6, fig.height=6, echo=FALSE}
library(EMAeval)
library(ggplot2)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
flagging_plots(EMAeval_Data, ttc.colnames = c("StartDate", "EndDate"), item.colnames = colnames(EMAeval_Data[,4:11]),number.items = 8)
```
*Note: the Longstring histogram has a much smaller scale for the Count. This is due to the lack of longstring values because many assessments do not have a Longstring value because all item responses differ.*
## TPI_cutoff
*This function creates a dataframe of ID and data indices in which the assessment met the cutoff criterion for Time per Item. The user inputs their own cutoff for TPI. The user can also specify what type of comparison they would like to complete with the cutoff value using __condition =...__ If responses to all items are mandatory, then the following response should be included:*
```
mandatory.response = TRUE
```
*Below is the code for the function.*
``` {r eval = FALSE}
TPI_cutoff(EMAeval_Data,
cutoff = 1,
condition = "<=",
ttc.colnames = c("StartDate", "EndDate"),
number.items = 8,
mandatory.response = TRUE,
item.colnames = colnames(EMAeval_Data[,4:11]),
ID.colname = "ID")
```
```{r message=FALSE, warning=FALSE, fig.align="center", fig.width=6, fig.height=6, max.height = "400px", echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
TPI_cutoff_DF <- TPI_cutoff(EMAeval_Data, cutoff = 1, condition = "<=", ttc.colnames = c("StartDate", "EndDate"), number.items = 8, mandatory.response = TRUE, item.colnames = colnames(EMAeval_Data[,4:11]), ID.colname = "ID")
kable(TPI_cutoff_DF, caption = "Assessments Flagged by TPI Cutoff", row.names = FALSE) %>%
kable_styling() %>%
scroll_box(width = "100%" , height = "400px")
```
## SD_cutoff
*This function creates a dataframe of ID and data indices in which the assessment met the cutoff criterion for Item Score Standard Deviation. The user inputs their own cutoff for SD. The user can also specify what type of comparison they would like to complete with the cutoff value using __condition =...__*
*Below is the code for the function.*
``` {r eval = FALSE}
SD_cutoff(EMAeval_Data,
cutoff = 5,
condition = "<=",
item.colnames = colnames(EMAeval_Data[,4:11]),
ID.colname = "ID")
```
```{r message=FALSE, warning=FALSE, fig.align="center", fig.width=6, fig.height=6, max.height = "400px", echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
SD_cutoff_DF <- SD_cutoff(EMAeval_Data, cutoff = 5, condition = "<=", item.colnames = colnames(EMAeval_Data[,4:11]), ID.colname = "ID")
kable(SD_cutoff_DF, caption = "Assessments Flagged by SD Cutoff", row.names = FALSE) %>%
kable_styling() %>%
scroll_box(width = "100%" , height = "400px")
```
## Perc_Mode_cutoff
*This function creates a dataframe of ID and data indices in which the assessment met the cutoff criterion for the Percent of Items at Mode. The user inputs their own cutoff for Percent of Items at Mode. The user can also specify what type of comparison they would like to complete with the cutoff value using __condition =...__*
*Below is the code for the function.*
``` {r eval = FALSE}
Perc_Mode_cutoff(EMAeval_Data,
cutoff = 0.7,
condition = ">=",
item.colnames = colnames(EMAeval_Data[,4:11]),
ID.colname = "ID")
```
```{r message=FALSE, warning=FALSE, fig.align="center", fig.width=6, fig.height=6, max.height = "400px", echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
Perc_Mode_cutoff_DF <- Perc_Mode_cutoff(EMAeval_Data, cutoff = 0.7, condition = ">=", item.colnames = colnames(EMAeval_Data[,4:11]), ID.colname = "ID")
kable(Perc_Mode_cutoff_DF, caption = "Assessments Flagged by PErcent of Items at Mode Cutoff", row.names = FALSE) %>%
kable_styling() %>%
scroll_box(width = "100%" , height = "400px")
```
## Combined_cutoff
*This function creates a dataframe of ID and data indices in which the assessment met the cutoff criteria for Time per Item OR Item Score Standard Deviation OR Percent of Items at Mode. The user inputs their own cutoff for TPI, SD and Percent of Items at Mode. The user can also specify what type of comparison they would like to complete with each cutoff value using either __SD.condition =...__ and __TPI.condition=...__ and __Perc.Mode.condition=...__ Users can also specify the logical component for the criteria, specifying with __Combined.logic = ...__ If responses to all items are mandatory, then the following response should be included:*
```
mandatory.response = TRUE
```
*Below is the code for the function.*
``` {r eval = FALSE}
Combined_cutoff(EMAeval_Data,
SD.cutoff = 5, SD.condition = "<=",
TPI.cutoff = 1, TPI.condition = "<=",
Perc.Mode.cutoff = 0.7, Perc.Mode.condition = ">=",
Combined.logic = "or",
ttc.colnames = c("StartDate", "EndDate"),
number.items = 8, mandatory.response = TRUE,
item.colnames = colnames(EMAeval_Data[,4:11]),
ID.colname = "ID")
```
```{r message=FALSE, warning=FALSE, fig.align="center", fig.width=6, fig.height=6, max.height = "400px", echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
Combined_cutoff_DF <- Combined_cutoff(EMAeval_Data,SD.cutoff = 5, SD.condition = "<=", TPI.cutoff = 1, TPI.condition = "<=", Perc.Mode.cutoff = 0.7, Perc.Mode.condition = ">=", Combined.logic = "or", ttc.colnames = c("StartDate", "EndDate"), number.items = 8, mandatory.response = TRUE, item.colnames = colnames(EMAeval_Data[,4:11]), ID.colname = "ID")
kable(Combined_cutoff_DF, caption = "Assessments Flagged by TPI, SD or Percent of Items at Mode Cutoffs", row.names = FALSE) %>%
kable_styling() %>%
scroll_box(width = "100%" , height = "400px")
```
## Combined_cutoff_percent
*This function creates a dataframe of ID and percent of responses in which assessments met the cutoff criteria for Time per Item OR Item Score Standard Deviation OR Percent of Items at Mode. The user inputs their own cutoff for TPI, SD and Percent of Items at Mode. The user can also specify what type of comparison they would like to complete with each cutoff value using either __SD.condition =...__ and __TPI.condition=...__ and __Perc.Mode.condition=...__ Users can also specify the logical component for the criteria, specifying with __Combined.logic = ...__ If responses to all items are mandatory, then the following response should be included:*
```
mandatory.response = TRUE
```
*Below is the code for the function.*
``` {r eval = FALSE}
Combined_cutoff_percent(EMAeval_Data,
SD.cutoff = 5, SD.condition = "<=",
TPI.cutoff = 1, TPI.condition = "<=",
Perc.Mode.cutoff = 0.7, Perc.Mode.condition = ">=",
Combined.logic = "or",
ttc.colnames = c("StartDate", "EndDate"),
number.items = 8, mandatory.response = TRUE,
item.colnames = colnames(EMAeval_Data[,4:11]),
ID.colname = "ID")
```
```{r message=FALSE, warning=FALSE, fig.align="center", fig.width=6, fig.height=6, max.height = "400px", echo=FALSE}
library(EMAeval)
library(knitr)
library(kableExtra)
EMAeval_Data <- EMAeval::EMAeval_Data
Combined_cutoff_percent_DF <- Combined_cutoff_percent(EMAeval_Data, SD.cutoff = 5, SD.condition = "<=", TPI.cutoff = 1, TPI.condition = "<=", Perc.Mode.cutoff = 0.7, Perc.Mode.condition = ">=", Combined.logic = "or", ttc.colnames = c("StartDate", "EndDate"), number.items = 8, mandatory.response = TRUE, item.colnames = colnames(EMAeval_Data[,4:11]), ID.colname = "ID")
kable(Combined_cutoff_percent_DF, caption = "Percentage of Assessments Flagged by TPI, SD or Percent of Items at Mode Cutoffs", row.names = FALSE) %>%
kable_styling()
```