spatial_demographics = readxl::read_xlsx("data/Data - All time points and measures/QT_T0dataPull_TABLE_T0data.xlsx",
sheet = "QT_T0dataPull_TABLE_T0data")
spatial_demographics$PRLSubjectID=spatial_demographics$`PK_SubjectID`
spatial_demographics$PRLSubjectID = as.factor(as.character(spatial_demographics$PRLSubjectID))
spatial_demographics = subset(spatial_demographics, T0SY1Y2G_StartGrade!= -711)
spatial_demographics = subset(spatial_demographics, T0SY1Y2G_StartGrade!= -888)
spatial_demographics$repeated = ifelse(spatial_demographics$T0SY1Y2G_StartGrade == spatial_demographics$T0SY1Y2G_Y2Grade, 1,0)
#View(spatial_demographics[c("PK_SubjectID","T0SY1Y2G_Y1Grade","T0SY1Y2G_Y2Grade","repeated")])
spatial_demographics_repeated = subset(spatial_demographics, repeated== 1)
rawdata = read_sav("/Volumes/BL-PSY-gunderson_lab/Main/Studies/SF_Person Oriented Approach/data/AccessDB_T0T4Merge_7.12.19.1.sav")
names(rawdata)[1] = "SubjectID"
D <- rawdata
###check the number of participants at each timepoint
D <- D %>%
filter(T0SY1Y2C_T1C == 1 |T0SY1Y2C_T2C == 1 | T0SY1Y2C_T3C == 1 | T0SY1Y2C_T4C == 1) ### participants attend at least 1 timepionts
a <- nrow(D)
focal.var = c(
"T1PKC_PA", "T2PKC_PA", "T3PKC_PA", "T4PKC_PA",
"T1WJCW", "T2WJCW", "T3WJCW", "T4WJCW",
"T1ASWmac", "T2ASWmac", "T3ASWmac", "T4ASWmac",
"T1LWIDWS", "T2LWIDWS", "T3LWIDWS", "T4LWIDWS")
D = D[rowSums(is.na(D[,focal.var])) != length(focal.var),]
D <- D %>%
dplyr::select("SubjectID", "T0SY1Y2G_Y1Grade", "T0SY1Y2G_Y2Grade",
"T0SY1Y2G_StartGrade", "T0SGENGender", "T0PDEMOMaxParentEducation",
"T0PDEMOIncomeCode", "T0PDEMOIncomeMid","T0PDEMORaceHispanic",
"T1PKC_PA", "T2PKC_PA", "T3PKC_PA", "T4PKC_PA",
"T1WJCW", "T2WJCW", "T3WJCW", "T4WJCW",
"T1ASWmac", "T2ASWmac", "T3ASWmac", "T4ASWmac",
"T1LWIDWS", "T2LWIDWS", "T3LWIDWS", "T4LWIDWS")
D[D>=(-999) & D<=(-50)] <- NA
##drop participants who repeated a grade
D1_dummy = D[c("SubjectID", "T0SY1Y2G_Y1Grade", "T0SY1Y2G_Y2Grade",
"T0SY1Y2G_StartGrade")]
D1_dummy$repeated = ifelse(D1_dummy$T0SY1Y2G_Y1Grade == D1_dummy$T0SY1Y2G_Y2Grade, 1,0)
repeatgrade = D1_dummy[which(D1_dummy$repeated==1),"SubjectID"]
D1 = D[which(D$SubjectID %!in% repeatgrade$SubjectID),] ##exclude 3 children who repeat grade
#CREATES ONE SINGLE FILE
spatial_proportional_data_nona_importantcols_names_alltimes = rbind(spatial_proportional_data_t1_nona_importantcols_names,
spatial_proportional_data_t2_nona_importantcols_names,
spatial_proportional_data_t3_nona_importantcols_names,
spatial_proportional_data_t4_nona_importantcols_names)
#REMOVES ITEM 20
spatial_proportional_data_nona_importantcols_names_alltimes_no20 = subset(spatial_proportional_data_nona_importantcols_names_alltimes, PRLItem !=20)
#REMOVES SHORT RTs
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20, PRLShortRT !=1)
#REMOVES 90%
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt, PRL10ex_15 !=1)
length(unique(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt$PRLSubjectID))
## [1] 603
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt$PRLSubjectID = as.factor(as.character(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt$PRLSubjectID))
| t1 | t2 | t3 | t4 | |
|---|---|---|---|---|
| 100 | 15 | 15 | 15 | 0 |
| 1002 | 0 | 0 | 15 | 15 |
| 1004 | 0 | 0 | 15 | 15 |
| 1005 | 0 | 0 | 15 | 15 |
| 101 | 15 | 15 | 15 | 0 |
| 1012 | 0 | 0 | 15 | 0 |
| 1013 | 0 | 0 | 15 | 0 |
| 1014 | 0 | 0 | 15 | 0 |
| 1016 | 0 | 0 | 15 | 15 |
| 1017 | 0 | 0 | 15 | 15 |
| 1018 | 0 | 0 | 15 | 15 |
| 1019 | 0 | 0 | 15 | 15 |
| 102 | 15 | 15 | 0 | 0 |
| 1020 | 0 | 0 | 15 | 15 |
| 1021 | 0 | 0 | 15 | 15 |
| 1022 | 0 | 0 | 15 | 15 |
| 1024 | 0 | 0 | 0 | 15 |
| 1027 | 0 | 0 | 15 | 15 |
| 103 | 15 | 15 | 0 | 0 |
| 1031 | 0 | 0 | 15 | 0 |
| 1033 | 0 | 0 | 15 | 0 |
| 1034 | 0 | 0 | 15 | 0 |
| 1035 | 0 | 0 | 15 | 15 |
| 1036 | 0 | 0 | 15 | 15 |
| 1037 | 0 | 0 | 15 | 0 |
| 1038 | 0 | 0 | 15 | 15 |
| 1039 | 0 | 0 | 15 | 0 |
| 104 | 15 | 0 | 15 | 0 |
| 1041 | 0 | 0 | 15 | 0 |
| 1042 | 0 | 0 | 15 | 0 |
| 1043 | 0 | 0 | 15 | 15 |
| 1047 | 0 | 0 | 15 | 15 |
| 1048 | 0 | 0 | 15 | 15 |
| 1049 | 0 | 0 | 15 | 0 |
| 105 | 15 | 15 | 15 | 15 |
| 1050 | 0 | 0 | 15 | 15 |
| 1051 | 0 | 0 | 15 | 15 |
| 1053 | 0 | 0 | 15 | 15 |
| 1055 | 0 | 0 | 15 | 15 |
| 1056 | 0 | 0 | 15 | 15 |
| 1058 | 0 | 0 | 15 | 0 |
| 106 | 15 | 15 | 0 | 15 |
| 107 | 15 | 0 | 0 | 15 |
| 108 | 15 | 15 | 0 | 0 |
| 110 | 15 | 15 | 15 | 15 |
| 112 | 0 | 0 | 15 | 15 |
| 113 | 15 | 15 | 15 | 15 |
| 114 | 15 | 15 | 15 | 15 |
| 115 | 15 | 0 | 0 | 0 |
| 116 | 15 | 15 | 0 | 0 |
| 117 | 15 | 15 | 0 | 15 |
| 118 | 15 | 0 | 0 | 0 |
| 119 | 15 | 15 | 15 | 15 |
| 120 | 15 | 15 | 15 | 15 |
| 1200 | 0 | 0 | 15 | 0 |
| 121 | 15 | 15 | 0 | 0 |
| 122 | 15 | 0 | 15 | 15 |
| 123 | 0 | 15 | 15 | 15 |
| 124 | 15 | 15 | 15 | 15 |
| 126 | 15 | 15 | 15 | 15 |
| 127 | 15 | 15 | 0 | 0 |
| 128 | 0 | 15 | 15 | 15 |
| 129 | 15 | 15 | 0 | 0 |
| 130 | 15 | 0 | 0 | 0 |
| 131 | 15 | 15 | 15 | 15 |
| 132 | 15 | 15 | 0 | 0 |
| 133 | 15 | 15 | 15 | 14 |
| 134 | 15 | 15 | 15 | 15 |
| 135 | 15 | 15 | 15 | 15 |
| 136 | 15 | 15 | 0 | 0 |
| 137 | 15 | 0 | 0 | 0 |
| 138 | 15 | 0 | 0 | 0 |
| 139 | 15 | 15 | 0 | 0 |
| 140 | 15 | 15 | 15 | 15 |
| 141 | 15 | 15 | 0 | 0 |
| 142 | 15 | 15 | 15 | 0 |
| 143 | 0 | 15 | 15 | 0 |
| 144 | 15 | 15 | 0 | 0 |
| 145 | 15 | 4 | 0 | 0 |
| 146 | 14 | 0 | 15 | 0 |
| 147 | 15 | 15 | 0 | 0 |
| 148 | 15 | 15 | 0 | 0 |
| 149 | 0 | 15 | 15 | 15 |
| 150 | 15 | 15 | 0 | 0 |
| 151 | 15 | 15 | 15 | 0 |
| 152 | 0 | 15 | 15 | 15 |
| 153 | 15 | 15 | 0 | 0 |
| 154 | 15 | 15 | 0 | 0 |
| 155 | 15 | 15 | 15 | 15 |
| 156 | 15 | 15 | 15 | 15 |
| 157 | 15 | 15 | 15 | 15 |
| 158 | 0 | 15 | 15 | 15 |
| 159 | 0 | 15 | 15 | 0 |
| 160 | 0 | 15 | 15 | 15 |
| 161 | 15 | 15 | 15 | 15 |
| 162 | 0 | 0 | 15 | 6 |
| 163 | 15 | 15 | 0 | 0 |
| 164 | 15 | 0 | 15 | 0 |
| 165 | 0 | 0 | 15 | 0 |
| 166 | 0 | 15 | 0 | 0 |
| 167 | 0 | 15 | 15 | 15 |
| 168 | 0 | 0 | 15 | 0 |
| 169 | 0 | 0 | 0 | 15 |
| 170 | 0 | 7 | 15 | 15 |
| 171 | 0 | 15 | 15 | 15 |
| 172 | 0 | 15 | 15 | 15 |
| 173 | 0 | 15 | 15 | 15 |
| 174 | 0 | 15 | 15 | 15 |
| 177 | 0 | 15 | 15 | 15 |
| 180 | 15 | 0 | 15 | 15 |
| 181 | 15 | 0 | 15 | 15 |
| 182 | 15 | 15 | 0 | 0 |
| 183 | 15 | 0 | 0 | 0 |
| 184 | 15 | 15 | 15 | 15 |
| 185 | 15 | 15 | 15 | 15 |
| 186 | 15 | 15 | 15 | 15 |
| 188 | 15 | 15 | 15 | 15 |
| 189 | 15 | 15 | 15 | 15 |
| 190 | 15 | 0 | 15 | 15 |
| 191 | 15 | 0 | 0 | 0 |
| 192 | 0 | 15 | 0 | 0 |
| 193 | 15 | 15 | 15 | 15 |
| 194 | 15 | 15 | 0 | 0 |
| 195 | 0 | 15 | 14 | 15 |
| 196 | 15 | 15 | 15 | 15 |
| 197 | 15 | 15 | 0 | 0 |
| 198 | 15 | 15 | 15 | 15 |
| 199 | 3 | 15 | 0 | 0 |
| 200 | 0 | 15 | 0 | 0 |
| 201 | 15 | 14 | 0 | 0 |
| 202 | 15 | 15 | 14 | 15 |
| 203 | 15 | 15 | 15 | 15 |
| 204 | 15 | 15 | 15 | 15 |
| 205 | 15 | 15 | 15 | 15 |
| 206 | 15 | 15 | 0 | 0 |
| 207 | 0 | 15 | 0 | 0 |
| 208 | 15 | 15 | 15 | 15 |
| 209 | 15 | 15 | 15 | 15 |
| 210 | 15 | 15 | 15 | 15 |
| 211 | 0 | 15 | 15 | 15 |
| 212 | 15 | 15 | 15 | 15 |
| 213 | 15 | 15 | 0 | 0 |
| 214 | 15 | 15 | 15 | 15 |
| 215 | 15 | 0 | 0 | 0 |
| 216 | 0 | 8 | 0 | 0 |
| 217 | 15 | 0 | 15 | 15 |
| 219 | 15 | 0 | 0 | 0 |
| 220 | 15 | 15 | 15 | 15 |
| 221 | 15 | 15 | 0 | 0 |
| 222 | 15 | 15 | 0 | 0 |
| 223 | 15 | 15 | 0 | 0 |
| 224 | 15 | 15 | 15 | 15 |
| 225 | 15 | 15 | 0 | 0 |
| 226 | 15 | 15 | 15 | 15 |
| 227 | 15 | 15 | 15 | 15 |
| 228 | 15 | 15 | 15 | 15 |
| 229 | 15 | 15 | 15 | 15 |
| 230 | 15 | 15 | 0 | 0 |
| 232 | 15 | 0 | 0 | 0 |
| 233 | 15 | 15 | 0 | 0 |
| 234 | 15 | 0 | 15 | 15 |
| 235 | 15 | 15 | 15 | 15 |
| 241 | 15 | 15 | 15 | 15 |
| 242 | 14 | 15 | 15 | 15 |
| 243 | 15 | 15 | 15 | 15 |
| 244 | 15 | 15 | 14 | 15 |
| 245 | 15 | 15 | 15 | 15 |
| 246 | 15 | 15 | 15 | 15 |
| 247 | 15 | 15 | 15 | 15 |
| 248 | 15 | 15 | 15 | 15 |
| 249 | 15 | 15 | 15 | 0 |
| 250 | 15 | 15 | 15 | 15 |
| 251 | 14 | 15 | 0 | 0 |
| 252 | 15 | 15 | 15 | 15 |
| 253 | 15 | 15 | 0 | 0 |
| 254 | 15 | 15 | 0 | 0 |
| 255 | 15 | 15 | 15 | 15 |
| 256 | 15 | 15 | 15 | 15 |
| 257 | 15 | 0 | 0 | 0 |
| 258 | 15 | 15 | 15 | 15 |
| 259 | 15 | 15 | 15 | 15 |
| 260 | 15 | 15 | 15 | 14 |
| 261 | 15 | 15 | 15 | 15 |
| 262 | 15 | 15 | 15 | 15 |
| 263 | 15 | 15 | 14 | 15 |
| 264 | 15 | 15 | 0 | 0 |
| 265 | 14 | 15 | 15 | 15 |
| 266 | 15 | 15 | 15 | 15 |
| 267 | 15 | 15 | 0 | 0 |
| 268 | 15 | 15 | 15 | 15 |
| 269 | 15 | 15 | 15 | 15 |
| 270 | 15 | 15 | 15 | 15 |
| 271 | 15 | 15 | 15 | 15 |
| 272 | 0 | 15 | 0 | 0 |
| 274 | 14 | 15 | 15 | 15 |
| 275 | 15 | 0 | 0 | 0 |
| 276 | 14 | 15 | 15 | 15 |
| 277 | 15 | 15 | 15 | 15 |
| 278 | 15 | 15 | 15 | 15 |
| 279 | 15 | 15 | 15 | 14 |
| 280 | 0 | 15 | 15 | 15 |
| 281 | 15 | 15 | 15 | 15 |
| 282 | 15 | 15 | 15 | 15 |
| 283 | 15 | 15 | 15 | 15 |
| 284 | 15 | 0 | 15 | 0 |
| 285 | 0 | 15 | 15 | 15 |
| 287 | 0 | 15 | 15 | 15 |
| 288 | 15 | 15 | 0 | 0 |
| 289 | 15 | 15 | 15 | 15 |
| 290 | 15 | 15 | 15 | 15 |
| 291 | 15 | 15 | 15 | 15 |
| 292 | 15 | 15 | 15 | 15 |
| 293 | 0 | 0 | 15 | 15 |
| 294 | 15 | 15 | 15 | 15 |
| 295 | 15 | 15 | 15 | 15 |
| 296 | 15 | 15 | 15 | 15 |
| 297 | 15 | 0 | 15 | 15 |
| 298 | 15 | 15 | 15 | 15 |
| 299 | 15 | 15 | 15 | 0 |
| 300 | 15 | 15 | 15 | 15 |
| 301 | 15 | 15 | 0 | 15 |
| 302 | 0 | 15 | 15 | 15 |
| 303 | 15 | 15 | 0 | 0 |
| 304 | 15 | 15 | 15 | 15 |
| 305 | 15 | 0 | 15 | 15 |
| 306 | 15 | 15 | 15 | 15 |
| 307 | 15 | 15 | 15 | 15 |
| 308 | 15 | 15 | 15 | 15 |
| 309 | 15 | 15 | 15 | 0 |
| 310 | 15 | 15 | 15 | 15 |
| 311 | 15 | 15 | 15 | 0 |
| 312 | 0 | 15 | 15 | 15 |
| 313 | 15 | 15 | 15 | 15 |
| 314 | 15 | 15 | 15 | 15 |
| 315 | 0 | 15 | 15 | 15 |
| 316 | 15 | 14 | 15 | 15 |
| 317 | 15 | 15 | 15 | 15 |
| 318 | 15 | 15 | 15 | 15 |
| 319 | 0 | 15 | 15 | 15 |
| 320 | 15 | 15 | 15 | 15 |
| 321 | 0 | 15 | 15 | 15 |
| 322 | 0 | 15 | 15 | 0 |
| 323 | 0 | 15 | 15 | 15 |
| 324 | 0 | 15 | 15 | 15 |
| 325 | 0 | 15 | 15 | 15 |
| 326 | 0 | 15 | 0 | 15 |
| 328 | 0 | 15 | 15 | 15 |
| 329 | 0 | 0 | 15 | 0 |
| 330 | 0 | 0 | 15 | 15 |
| 331 | 0 | 15 | 15 | 15 |
| 332 | 0 | 15 | 15 | 15 |
| 333 | 0 | 15 | 15 | 7 |
| 334 | 0 | 15 | 15 | 15 |
| 335 | 0 | 15 | 0 | 15 |
| 336 | 15 | 15 | 15 | 15 |
| 337 | 15 | 15 | 15 | 15 |
| 338 | 15 | 15 | 15 | 15 |
| 339 | 15 | 0 | 15 | 15 |
| 340 | 0 | 15 | 15 | 15 |
| 341 | 15 | 15 | 15 | 0 |
| 342 | 15 | 15 | 15 | 15 |
| 343 | 15 | 0 | 15 | 15 |
| 344 | 0 | 15 | 15 | 15 |
| 345 | 15 | 15 | 15 | 15 |
| 346 | 15 | 15 | 15 | 15 |
| 347 | 15 | 15 | 15 | 15 |
| 348 | 15 | 15 | 15 | 0 |
| 349 | 15 | 0 | 15 | 12 |
| 350 | 15 | 9 | 15 | 0 |
| 351 | 15 | 15 | 15 | 15 |
| 352 | 15 | 12 | 0 | 0 |
| 353 | 15 | 15 | 0 | 15 |
| 354 | 15 | 15 | 15 | 15 |
| 355 | 15 | 15 | 15 | 15 |
| 356 | 0 | 15 | 15 | 15 |
| 357 | 15 | 15 | 15 | 15 |
| 358 | 15 | 15 | 15 | 15 |
| 359 | 15 | 15 | 15 | 15 |
| 360 | 15 | 0 | 15 | 15 |
| 361 | 15 | 15 | 15 | 15 |
| 400 | 15 | 15 | 15 | 15 |
| 401 | 0 | 15 | 15 | 15 |
| 402 | 15 | 15 | 0 | 0 |
| 403 | 15 | 0 | 15 | 15 |
| 404 | 13 | 14 | 15 | 15 |
| 405 | 15 | 15 | 15 | 0 |
| 406 | 15 | 15 | 15 | 15 |
| 409 | 15 | 15 | 0 | 0 |
| 410 | 15 | 15 | 15 | 15 |
| 411 | 15 | 15 | 15 | 15 |
| 412 | 15 | 15 | 15 | 15 |
| 413 | 15 | 5 | 15 | 15 |
| 414 | 15 | 15 | 15 | 15 |
| 415 | 15 | 15 | 0 | 0 |
| 416 | 15 | 14 | 15 | 15 |
| 417 | 15 | 15 | 15 | 15 |
| 418 | 15 | 15 | 15 | 15 |
| 419 | 15 | 15 | 0 | 0 |
| 420 | 15 | 15 | 0 | 0 |
| 421 | 15 | 15 | 0 | 0 |
| 422 | 15 | 15 | 15 | 15 |
| 423 | 15 | 0 | 15 | 15 |
| 424 | 15 | 15 | 15 | 0 |
| 425 | 15 | 15 | 15 | 15 |
| 426 | 15 | 15 | 15 | 15 |
| 427 | 15 | 15 | 15 | 15 |
| 428 | 15 | 15 | 15 | 15 |
| 429 | 15 | 15 | 15 | 0 |
| 430 | 15 | 15 | 15 | 15 |
| 431 | 15 | 15 | 15 | 15 |
| 432 | 15 | 15 | 0 | 0 |
| 433 | 15 | 15 | 15 | 15 |
| 434 | 15 | 15 | 15 | 15 |
| 435 | 0 | 15 | 15 | 15 |
| 436 | 15 | 15 | 0 | 0 |
| 437 | 15 | 15 | 0 | 15 |
| 438 | 15 | 15 | 15 | 15 |
| 440 | 15 | 15 | 15 | 15 |
| 441 | 15 | 15 | 15 | 15 |
| 442 | 15 | 15 | 0 | 0 |
| 443 | 0 | 15 | 0 | 0 |
| 444 | 15 | 15 | 0 | 0 |
| 445 | 15 | 15 | 15 | 15 |
| 446 | 15 | 15 | 15 | 15 |
| 447 | 15 | 15 | 15 | 15 |
| 448 | 15 | 15 | 15 | 0 |
| 449 | 15 | 15 | 15 | 15 |
| 450 | 15 | 15 | 15 | 15 |
| 451 | 15 | 15 | 0 | 15 |
| 452 | 15 | 15 | 15 | 15 |
| 453 | 15 | 15 | 15 | 15 |
| 454 | 15 | 15 | 0 | 15 |
| 455 | 15 | 15 | 15 | 15 |
| 456 | 15 | 15 | 15 | 15 |
| 457 | 15 | 15 | 15 | 15 |
| 458 | 15 | 15 | 15 | 15 |
| 459 | 15 | 15 | 15 | 15 |
| 460 | 15 | 15 | 15 | 15 |
| 461 | 15 | 15 | 15 | 15 |
| 462 | 15 | 15 | 15 | 15 |
| 463 | 15 | 15 | 15 | 0 |
| 464 | 15 | 15 | 15 | 15 |
| 465 | 15 | 0 | 0 | 0 |
| 466 | 15 | 15 | 15 | 15 |
| 467 | 15 | 15 | 15 | 15 |
| 468 | 15 | 15 | 0 | 0 |
| 469 | 14 | 15 | 15 | 15 |
| 470 | 15 | 15 | 15 | 15 |
| 471 | 15 | 15 | 15 | 15 |
| 472 | 15 | 15 | 15 | 15 |
| 473 | 15 | 15 | 15 | 15 |
| 474 | 15 | 15 | 0 | 0 |
| 475 | 15 | 15 | 0 | 15 |
| 476 | 15 | 15 | 15 | 15 |
| 477 | 15 | 15 | 0 | 15 |
| 478 | 15 | 15 | 15 | 15 |
| 479 | 15 | 15 | 15 | 15 |
| 480 | 15 | 15 | 15 | 14 |
| 481 | 15 | 15 | 15 | 15 |
| 482 | 15 | 14 | 15 | 15 |
| 483 | 15 | 15 | 15 | 15 |
| 484 | 15 | 15 | 15 | 15 |
| 485 | 15 | 15 | 0 | 0 |
| 486 | 0 | 15 | 15 | 15 |
| 487 | 15 | 15 | 0 | 0 |
| 488 | 15 | 15 | 15 | 15 |
| 489 | 15 | 15 | 15 | 15 |
| 490 | 15 | 15 | 0 | 0 |
| 491 | 15 | 15 | 15 | 15 |
| 492 | 15 | 15 | 15 | 15 |
| 493 | 15 | 15 | 15 | 15 |
| 494 | 15 | 15 | 15 | 14 |
| 495 | 15 | 15 | 15 | 15 |
| 496 | 15 | 15 | 15 | 15 |
| 497 | 15 | 0 | 0 | 0 |
| 498 | 0 | 15 | 15 | 15 |
| 499 | 0 | 15 | 15 | 15 |
| 500 | 15 | 15 | 0 | 0 |
| 501 | 15 | 15 | 0 | 0 |
| 502 | 15 | 15 | 0 | 0 |
| 506 | 0 | 0 | 15 | 15 |
| 508 | 15 | 0 | 15 | 0 |
| 509 | 0 | 15 | 15 | 0 |
| 510 | 0 | 0 | 15 | 15 |
| 511 | 15 | 15 | 0 | 0 |
| 513 | 15 | 15 | 14 | 15 |
| 514 | 15 | 15 | 15 | 15 |
| 516 | 15 | 15 | 15 | 15 |
| 517 | 0 | 15 | 15 | 15 |
| 518 | 0 | 15 | 15 | 0 |
| 519 | 15 | 0 | 0 | 0 |
| 525 | 15 | 15 | 15 | 0 |
| 526 | 15 | 15 | 0 | 15 |
| 527 | 15 | 15 | 15 | 15 |
| 528 | 15 | 15 | 0 | 0 |
| 539 | 15 | 0 | 15 | 15 |
| 540 | 15 | 15 | 15 | 0 |
| 541 | 15 | 15 | 15 | 15 |
| 542 | 15 | 15 | 15 | 15 |
| 543 | 15 | 15 | 15 | 15 |
| 544 | 15 | 0 | 15 | 15 |
| 545 | 15 | 0 | 15 | 15 |
| 546 | 15 | 0 | 15 | 15 |
| 547 | 15 | 0 | 0 | 0 |
| 548 | 15 | 0 | 15 | 15 |
| 549 | 15 | 0 | 14 | 15 |
| 550 | 15 | 0 | 15 | 15 |
| 551 | 15 | 0 | 15 | 15 |
| 552 | 15 | 0 | 0 | 0 |
| 553 | 15 | 0 | 15 | 15 |
| 554 | 15 | 0 | 0 | 15 |
| 555 | 15 | 15 | 15 | 15 |
| 556 | 15 | 0 | 0 | 15 |
| 557 | 15 | 15 | 15 | 14 |
| 558 | 15 | 15 | 0 | 0 |
| 559 | 15 | 15 | 15 | 15 |
| 560 | 15 | 15 | 14 | 15 |
| 561 | 15 | 15 | 15 | 15 |
| 562 | 15 | 14 | 0 | 0 |
| 563 | 15 | 15 | 15 | 15 |
| 564 | 15 | 0 | 15 | 15 |
| 565 | 14 | 15 | 0 | 0 |
| 566 | 14 | 15 | 14 | 14 |
| 567 | 14 | 15 | 15 | 14 |
| 568 | 15 | 0 | 15 | 15 |
| 570 | 15 | 15 | 15 | 15 |
| 572 | 15 | 15 | 0 | 0 |
| 573 | 15 | 15 | 15 | 15 |
| 574 | 15 | 15 | 15 | 15 |
| 575 | 0 | 15 | 0 | 0 |
| 576 | 15 | 15 | 15 | 15 |
| 577 | 15 | 15 | 15 | 15 |
| 578 | 15 | 15 | 0 | 0 |
| 579 | 15 | 15 | 0 | 0 |
| 580 | 15 | 15 | 0 | 15 |
| 581 | 15 | 15 | 15 | 15 |
| 582 | 15 | 15 | 15 | 15 |
| 583 | 15 | 15 | 0 | 0 |
| 584 | 15 | 15 | 0 | 0 |
| 585 | 15 | 0 | 0 | 0 |
| 586 | 15 | 15 | 0 | 0 |
| 587 | 15 | 15 | 0 | 0 |
| 588 | 15 | 15 | 15 | 15 |
| 589 | 0 | 15 | 15 | 15 |
| 590 | 15 | 10 | 15 | 15 |
| 591 | 0 | 15 | 0 | 0 |
| 592 | 0 | 0 | 15 | 15 |
| 593 | 0 | 15 | 0 | 0 |
| 594 | 15 | 15 | 0 | 0 |
| 595 | 15 | 15 | 15 | 0 |
| 596 | 15 | 12 | 15 | 15 |
| 597 | 15 | 15 | 15 | 15 |
| 598 | 15 | 15 | 15 | 15 |
| 599 | 15 | 0 | 15 | 15 |
| 600 | 15 | 15 | 15 | 15 |
| 601 | 14 | 15 | 0 | 0 |
| 603 | 0 | 15 | 0 | 0 |
| 604 | 12 | 15 | 14 | 15 |
| 605 | 15 | 15 | 0 | 0 |
| 606 | 0 | 14 | 0 | 0 |
| 607 | 15 | 15 | 15 | 15 |
| 608 | 15 | 15 | 15 | 15 |
| 609 | 15 | 15 | 15 | 15 |
| 610 | 0 | 15 | 15 | 15 |
| 611 | 15 | 15 | 14 | 15 |
| 612 | 15 | 15 | 0 | 0 |
| 613 | 0 | 15 | 15 | 15 |
| 614 | 15 | 15 | 15 | 0 |
| 615 | 15 | 0 | 14 | 15 |
| 616 | 15 | 15 | 15 | 15 |
| 617 | 15 | 15 | 15 | 15 |
| 618 | 15 | 0 | 0 | 0 |
| 619 | 15 | 15 | 15 | 15 |
| 620 | 15 | 15 | 15 | 15 |
| 621 | 15 | 15 | 15 | 15 |
| 622 | 15 | 15 | 15 | 15 |
| 623 | 15 | 15 | 14 | 15 |
| 624 | 0 | 15 | 0 | 15 |
| 625 | 15 | 15 | 15 | 15 |
| 626 | 0 | 15 | 0 | 0 |
| 627 | 15 | 15 | 14 | 15 |
| 628 | 15 | 15 | 15 | 15 |
| 629 | 15 | 15 | 0 | 0 |
| 630 | 15 | 0 | 15 | 0 |
| 631 | 15 | 15 | 15 | 15 |
| 632 | 15 | 15 | 15 | 15 |
| 633 | 15 | 15 | 15 | 15 |
| 634 | 15 | 15 | 0 | 0 |
| 635 | 0 | 15 | 15 | 15 |
| 636 | 15 | 15 | 15 | 15 |
| 637 | 15 | 15 | 15 | 15 |
| 638 | 15 | 0 | 15 | 0 |
| 639 | 15 | 15 | 15 | 15 |
| 640 | 15 | 15 | 15 | 15 |
| 642 | 15 | 15 | 15 | 15 |
| 643 | 15 | 0 | 15 | 15 |
| 644 | 15 | 15 | 15 | 15 |
| 645 | 0 | 15 | 15 | 15 |
| 646 | 15 | 15 | 15 | 15 |
| 647 | 15 | 15 | 15 | 15 |
| 648 | 0 | 15 | 15 | 15 |
| 649 | 0 | 15 | 15 | 15 |
| 650 | 15 | 15 | 15 | 15 |
| 651 | 15 | 15 | 15 | 15 |
| 652 | 15 | 15 | 15 | 0 |
| 653 | 15 | 15 | 15 | 15 |
| 654 | 15 | 15 | 15 | 15 |
| 655 | 15 | 15 | 15 | 15 |
| 656 | 15 | 0 | 15 | 0 |
| 657 | 15 | 0 | 0 | 0 |
| 658 | 0 | 14 | 15 | 15 |
| 659 | 15 | 15 | 15 | 0 |
| 660 | 15 | 15 | 15 | 15 |
| 661 | 15 | 15 | 15 | 15 |
| 662 | 15 | 15 | 15 | 15 |
| 663 | 15 | 15 | 15 | 15 |
| 665 | 15 | 15 | 15 | 15 |
| 666 | 15 | 15 | 15 | 0 |
| 667 | 15 | 15 | 15 | 15 |
| 668 | 0 | 0 | 15 | 15 |
| 669 | 0 | 0 | 15 | 15 |
| 670 | 15 | 15 | 15 | 15 |
| 671 | 15 | 0 | 15 | 15 |
| 672 | 15 | 15 | 15 | 15 |
| 673 | 14 | 0 | 15 | 15 |
| 674 | 15 | 15 | 15 | 15 |
| 675 | 15 | 15 | 0 | 15 |
| 676 | 15 | 15 | 15 | 15 |
| 677 | 0 | 15 | 15 | 15 |
| 678 | 15 | 15 | 0 | 0 |
| 679 | 15 | 15 | 15 | 14 |
| 681 | 15 | 15 | 15 | 15 |
| 682 | 15 | 15 | 15 | 15 |
| 683 | 15 | 15 | 0 | 0 |
| 685 | 15 | 15 | 15 | 15 |
| 686 | 15 | 15 | 15 | 15 |
| 687 | 15 | 15 | 15 | 15 |
| 688 | 15 | 15 | 15 | 0 |
| 689 | 15 | 15 | 0 | 0 |
| 690 | 15 | 15 | 15 | 15 |
| 691 | 14 | 15 | 15 | 15 |
| 692 | 15 | 15 | 15 | 0 |
| 693 | 15 | 15 | 15 | 15 |
| 694 | 15 | 15 | 15 | 15 |
| 695 | 15 | 0 | 15 | 15 |
| 696 | 15 | 15 | 15 | 15 |
| 697 | 15 | 15 | 15 | 15 |
| 698 | 15 | 15 | 15 | 14 |
| 699 | 15 | 15 | 15 | 15 |
| 700 | 14 | 15 | 15 | 15 |
| 701 | 15 | 15 | 15 | 15 |
| 702 | 15 | 15 | 15 | 15 |
| 703 | 15 | 15 | 15 | 0 |
| 704 | 15 | 15 | 15 | 15 |
| 705 | 15 | 15 | 15 | 15 |
| 706 | 15 | 15 | 15 | 15 |
| 707 | 13 | 15 | 15 | 9 |
| 708 | 0 | 15 | 0 | 0 |
| 709 | 15 | 0 | 0 | 15 |
| 710 | 0 | 15 | 15 | 15 |
| 711 | 15 | 15 | 15 | 15 |
| 712 | 15 | 0 | 0 | 0 |
| 713 | 15 | 14 | 0 | 0 |
| 714 | 15 | 15 | 15 | 15 |
| 715 | 15 | 14 | 0 | 15 |
| 717 | 0 | 15 | 15 | 0 |
| 718 | 15 | 0 | 15 | 15 |
| 719 | 15 | 15 | 15 | 15 |
| 720 | 15 | 15 | 15 | 15 |
| 721 | 0 | 15 | 15 | 15 |
| 722 | 15 | 15 | 0 | 0 |
| 723 | 15 | 15 | 0 | 0 |
| 724 | 15 | 15 | 0 | 0 |
| 725 | 15 | 0 | 15 | 15 |
| 727 | 15 | 15 | 0 | 15 |
| 728 | 14 | 15 | 15 | 5 |
| 733 | 0 | 0 | 15 | 15 |
| 734 | 15 | 15 | 15 | 0 |
| 735 | 15 | 15 | 0 | 0 |
| 736 | 15 | 15 | 15 | 15 |
| 737 | 15 | 15 | 15 | 15 |
| 738 | 15 | 15 | 15 | 15 |
| 739 | 15 | 15 | 15 | 15 |
| 740 | 15 | 0 | 0 | 0 |
| 741 | 15 | 15 | 0 | 15 |
| 742 | 15 | 0 | 15 | 15 |
| 743 | 15 | 15 | 15 | 15 |
| 746 | 15 | 0 | 15 | 15 |
| 852 | 15 | 15 | 15 | 15 |
| 853 | 15 | 15 | 15 | 15 |
| 854 | 15 | 15 | 0 | 0 |
| 855 | 0 | 15 | 15 | 15 |
| 856 | 15 | 15 | 14 | 15 |
| 857 | 0 | 15 | 15 | 15 |
| 950 | 0 | 15 | 15 | 15 |
| 951 | 0 | 15 | 15 | 15 |
| 952 | 15 | 15 | 15 | 15 |
| 953 | 15 | 15 | 0 | 15 |
| 954 | 15 | 15 | 15 | 15 |
| 955 | 0 | 15 | 15 | 15 |
| 956 | 15 | 15 | 15 | 15 |
| 957 | 15 | 0 | 15 | 15 |
| 958 | 0 | 15 | 15 | 15 |
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread = spread(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary, Var2, Freq)
names(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread)[1] = "PRLSubjectID"
##Converts 0 to 10 as NAs
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2 = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread %>%
dplyr::mutate(
dplyr::across(
where(is.numeric),
~if_else(. %in% seq(0,10,1), NA_real_, .)
)
)
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread3 =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2
##Sums NAs
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread3$total = apply(X = is.na(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread3[c(2:5)]), MARGIN = 1, FUN = sum)
##Removes participants who don't have any datapoints
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread3 = subset(
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread3, total !=4
)
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2 = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread3
spatial_participant_list_t1 =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2[which(
!is.na(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2$t1)
),"PRLSubjectID"]
length(spatial_participant_list_t1)
## [1] 472
spatial_participant_list_t2 =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2[which(
!is.na(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2$t2)
),"PRLSubjectID"]
spatial_participant_list_t3 =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2[which(
!is.na(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2$t3)
),"PRLSubjectID"]
spatial_participant_list_t4 =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2[which(
!is.na(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2$t4)
),"PRLSubjectID"]
x <- list(
T1_n472 = as.character(spatial_participant_list_t1),
T2_n477 = as.character(spatial_participant_list_t2),
T3_n457 = as.character(spatial_participant_list_t3),
T4_n421 = as.character(spatial_participant_list_t4)
)
ggvenn(
x,
fill_color = c("#0073C2FF", "#EFC000FF", "#868686FF", "#CD534CFF"),
stroke_size = .5, set_name_size = 5,
text_size = 3.5,
fill_alpha = 0.4
)
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt[which(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt$PRLSubjectID %in% spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_summary_spread2$PRLSubjectID),]
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt[which(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt$PRLSubjectID %!in% spatial_demographics_repeated$`PK_SubjectID`),]
length(unique(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt$PRLSubjectID))
## [1] 602
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_grade = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt
names(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_grade)[1] = "PRLSubjectID"
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_grade = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_grade %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade","T0SY1Y2G_Y2Grade","repeated")], by ="PRLSubjectID")
distinct(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_grade[c("PRLSubjectID","T0SY1Y2G_StartGrade")]) %>%
{table(.$T0SY1Y2G_StartGrade)}
##
## -1 0 1 2 3
## 100 147 129 127 99
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt
nrow(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete)
## [1] 27405
length(unique(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLSubjectID))
## [1] 602
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete[
-which(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLSubjectID %!in% as.character(spatial_participant_list_t1) &
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$time == "t1"),]
nrow(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete)
## [1] 27402
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete[
-which(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLSubjectID %!in% as.character(spatial_participant_list_t2) &
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$time == "t2"),]
nrow(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete)
## [1] 27367
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete[
-which(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLSubjectID %!in% as.character(spatial_participant_list_t4) &
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$time == "t4"),]
nrow(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete)
## [1] 27340
length(unique(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLSubjectID))
## [1] 602
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete = spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete %>%
left_join(spatial_proportional_stimuli, by ="PRLItem")
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLCResp = as.numeric(as.character(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLCResp))
participant_list = unique(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete$PRLSubjectID)
length(participant_list)
## [1] 602
spatial_demographics_finalsample = spatial_demographics[which(spatial_demographics$`PK_SubjectID` %in% participant_list),]
# age_stats <- spatial_demographics_finalsample %>%
# subset(!is.na(T0SAGE_T1S1Age)) %>%
# #group_by(T0SY1Y2G_Y1Grade) %>%
# summarise(mean_age = mean(T0SAGE_T1S1Age, na.rm = T),
# sd_age = sd(T0SAGE_T1S1Age, na.rm = T),
# n_values = n()) %>%
# ungroup()
# age_stats
#
# ed_stats <- spatial_demographics_finalsample %>%
# subset(!is.na(T0PDEMOMaxParentEducation)) %>%
# subset(T0PDEMOMaxParentEducation>-999) %>%
# summarise(mean_ed = mean(T0PDEMOMaxParentEducation, na.rm = T),
# sd_age = sd(T0PDEMOMaxParentEducation, na.rm = T),
# n_values = n())
# ed_stats
# age_stats
table(spatial_demographics_finalsample$T0SGENGender)
##
## -999 1 2
## 1 333 268
table(spatial_demographics_finalsample$T0PDEMORaceHispanic)
##
## -999 1 2 3 4 5 6 7 10
## 18 2 23 275 2 109 1 64 61
table(spatial_demographics_finalsample$T0PDEMOMaxParentEducation)
##
## -999 10 12 13 14 16 17 18
## 16 22 89 109 82 79 51 107
table(spatial_demographics_finalsample$T0PDEMOIncomeCode)
##
## -999 1 2 3 4 5 6
## 40 78 143 87 80 45 82
spatial_profiles_database = D1
spatial_profiles_database$SubjectID = as.factor(as.character(spatial_profiles_database$SubjectID))
spatial_proportional_math_data = spatial_profiles_database[which(spatial_profiles_database$SubjectID %in% participant_list),]
var_zy1 = c(
"T1WJCW", "T2WJCW",
"T1PKC_PA", "T2PKC_PA",
"T1ASWmac", "T2ASWmac",
"T1LWIDWS", "T2LWIDWS")
var_zy2 = c(
"T3WJCW", "T4WJCW",
"T3PKC_PA", "T4PKC_PA",
"T3ASWmac", "T4ASWmac",
"T3LWIDWS", "T4LWIDWS")
for (v in var_zy1) {
vs <- str_c(v, ".s")
spatial_proportional_math_data[[vs]] <- ave(spatial_proportional_math_data[[v]], spatial_proportional_math_data$T0SY1Y2G_StartGrade, FUN=scale)
}
for (v in var_zy2) {
vs <- str_c(v, ".s")
spatial_proportional_math_data[[vs]] <- ave(spatial_proportional_math_data[[v]], spatial_proportional_math_data$T0SY1Y2G_Y2Grade, FUN=scale)
}
spatial_proportional_math_data$T1EC.s = ifelse(spatial_proportional_math_data$T0SY1Y2G_StartGrade <1, spatial_proportional_math_data$T1PKC_PA.s,spatial_proportional_math_data$T1WJCW.s)
spatial_proportional_math_data$T2EC.s = ifelse(spatial_proportional_math_data$T0SY1Y2G_StartGrade <1, spatial_proportional_math_data$T2PKC_PA.s,spatial_proportional_math_data$T2WJCW.s)
spatial_proportional_math_data$T3EC.s = ifelse(spatial_proportional_math_data$T0SY1Y2G_Y2Grade <1, spatial_proportional_math_data$T3PKC_PA.s,spatial_proportional_math_data$T3WJCW.s)
spatial_proportional_math_data$T4EC.s = ifelse(spatial_proportional_math_data$T0SY1Y2G_Y2Grade <1, spatial_proportional_math_data$T4PKC_PA.s,spatial_proportional_math_data$T4WJCW.s)
spatial_proportional_math_data$PRLSubjectID= as.character(spatial_proportional_math_data$SubjectID)
summarySE(spatial_proportional_math_data, "T1EC.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T1EC.s sd se ci
## 1 -1 60 0.0000000000000001077842 1 0.12909944 0.2583274
## 2 0 122 -0.0000000000000003276068 1 0.09053575 0.1792394
## 3 1 113 0.0000000000000005944114 1 0.09407209 0.1863918
## 4 2 90 -0.0000000000000010485440 1 0.10540926 0.2094459
## 5 3 77 0.0000000000000006834360 1 0.11396058 0.2269722
summarySE(spatial_proportional_math_data, "T2EC.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T2EC.s sd se ci
## 1 -1 74 0.00000000000000009151838 1 0.11624764 0.2316812
## 2 0 127 0.00000000000000019232210 1 0.08873565 0.1756052
## 3 1 90 0.00000000000000033553407 1 0.10540926 0.2094459
## 4 2 79 0.00000000000000051154580 1 0.11250879 0.2239878
## 5 3 78 -0.00000000000000099635400 1 0.11322770 0.2254652
summarySE(spatial_proportional_math_data, "T3EC.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T3EC.s sd se ci
## 1 -1 65 0.00000000000000008710981 1 0.1240347 0.2477879
## 2 0 98 -0.00000000000000031947234 1 0.1010153 0.2004873
## 3 1 86 0.00000000000000118768044 1 0.1078328 0.2144004
## 4 2 89 -0.00000000000000029938598 1 0.1059998 0.2106523
## 5 3 65 -0.00000000000000158505687 1 0.1240347 0.2477879
summarySE(spatial_proportional_math_data, "T4EC.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T4EC.s sd se ci
## 1 -1 71 -0.0000000000000001000764 1 0.1186782 0.2366961
## 2 0 88 -0.0000000000000015152021 1 0.1066004 0.2118798
## 3 1 83 -0.0000000000000008426994 1 0.1097643 0.2183561
## 4 2 93 -0.0000000000000009526430 1 0.1036952 0.2059476
## 5 3 63 0.0000000000000000000000 1 0.1259882 0.2518467
summarySE(spatial_proportional_math_data, "T1ASWmac.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T1ASWmac.s sd se ci
## 1 -1 44 -0.0000000000000005752974 1 0.15075567 0.3040278
## 2 0 112 -0.0000000000000012945993 1 0.09449112 0.1872405
## 3 1 110 -0.0000000000000001271710 1 0.09534626 0.1889732
## 4 2 105 0.0000000000000007359193 1 0.09759001 0.1935246
## 5 3 74 -0.0000000000000019863990 1 0.11624764 0.2316812
summarySE(spatial_proportional_math_data, "T2ASWmac.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T2ASWmac.s sd se ci
## 1 -1 64 -0.0000000000000001318390 1 0.12500000 0.2497926
## 2 0 123 -0.0000000000000002905873 1 0.09016696 0.1784945
## 3 1 102 0.0000000000000006585146 1 0.09901475 0.1964186
## 4 2 89 0.0000000000000019285447 1 0.10599979 0.2106523
## 5 3 80 -0.0000000000000017985613 1 0.11180340 0.2225391
summarySE(spatial_proportional_math_data, "T3ASWmac.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T3ASWmac.s sd se ci
## 1 -1 67 -0.00000000000000001822754 1 0.12216944 0.2439192
## 2 0 102 0.00000000000000086205553 1 0.09901475 0.1964186
## 3 1 94 0.00000000000000138895987 1 0.10314212 0.2048198
## 4 2 93 0.00000000000000132629869 1 0.10369517 0.2059476
## 5 3 74 0.00000000000000136227366 1 0.11624764 0.2316812
summarySE(spatial_proportional_math_data, "T4ASWmac.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T4ASWmac.s sd se ci
## 1 -1 63 0.0000000000000003418782 1 0.1259882 0.2518467
## 2 0 85 -0.0000000000000007209919 1 0.1084652 0.2156950
## 3 1 83 0.0000000000000005521437 1 0.1097643 0.2183561
## 4 2 93 -0.0000000000000007571602 1 0.1036952 0.2059476
## 5 3 66 -0.0000000000000009016357 1 0.1230915 0.2458307
summarySE(spatial_proportional_math_data, "T1LWIDWS.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T1LWIDWS.s sd se ci
## 1 -1 62 0.0000000000000002327887 1 0.12700013 0.2539524
## 2 0 118 0.0000000000000006209722 1 0.09205746 0.1823150
## 3 1 106 -0.0000000000000004713211 1 0.09712859 0.1925880
## 4 2 96 0.0000000000000007285839 1 0.10206207 0.2026188
## 5 3 75 -0.0000000000000010450899 1 0.11547005 0.2300791
summarySE(spatial_proportional_math_data, "T2LWIDWS.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T2LWIDWS.s sd se ci
## 1 -1 67 -0.0000000000000003102825 1 0.12216944 0.2439192
## 2 0 126 0.0000000000000002467162 1 0.08908708 0.1763144
## 3 1 100 -0.0000000000000003042011 1 0.10000000 0.1984217
## 4 2 86 0.0000000000000005060551 1 0.10783277 0.2144004
## 5 3 78 -0.0000000000000008974303 1 0.11322770 0.2254652
summarySE(spatial_proportional_math_data, "T3LWIDWS.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T3LWIDWS.s sd se ci
## 1 -1 62 -0.00000000000000125705897 1 0.12700013 0.2539524
## 2 0 104 0.00000000000000058500213 1 0.09805807 0.1944750
## 3 1 96 0.00000000000000068926346 1 0.10206207 0.2026188
## 4 2 95 0.00000000000000047681157 1 0.10259784 0.2037104
## 5 3 64 -0.00000000000000002775558 1 0.12500000 0.2497926
summarySE(spatial_proportional_math_data, "T4LWIDWS.s", "T0SY1Y2G_StartGrade", na.rm = T)
## T0SY1Y2G_StartGrade N T4LWIDWS.s sd se ci
## 1 -1 69 -0.00000000000000065215546 1 0.1203859 0.2402262
## 2 0 94 0.00000000000000005787333 1 0.1031421 0.2048198
## 3 1 86 0.00000000000000093465287 1 0.1078328 0.2144004
## 4 2 91 0.00000000000000068077412 1 0.1048285 0.2082601
## 5 3 65 0.00000000000000076413235 1 0.1240347 0.2477879
spatial_proportional_data_t1_complete_grade = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete, time == "t1")
spatial_proportional_data_t1_complete_grade = spatial_proportional_data_t1_complete_grade %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade")], by = "PRLSubjectID")
spatial_proportional_data_t1_complete_grade$size2 = as.factor(as.numeric(spatial_proportional_data_t1_complete_grade$size2))
# spatial_proportional_data_t1_complete_grade$size2=fct_rev(spatial_proportional_data_t1_complete_grade$size2)
spatial_proportional_data_t1_complete_grade$red...11 = as.factor(as.numeric(spatial_proportional_data_t1_complete_grade$red...11))
spatial_proportional_data_t1_complete_grade$red =
spatial_proportional_data_t1_complete_grade$red...11
spatial_proportional_data_t1_complete_grade$correct =as.numeric(as.character(spatial_proportional_data_t1_complete_grade$correct))
spatial_proportional_data_t1_complete_grade$dir_error =
spatial_proportional_data_t1_complete_grade$PRLCResp - (spatial_proportional_data_t1_complete_grade$correct)
spatial_proportional_data_t1_complete_grade$size_num=
as.numeric(as.character(spatial_proportional_data_t1_complete_grade$size2))
spatial_proportional_data_t1_complete_grade$red_num =
as.numeric(as.character(spatial_proportional_data_t1_complete_grade$red...11))
spatial_proportional_data_t1_complete_grade$pae = abs(spatial_proportional_data_t1_complete_grade$PRLCResp - spatial_proportional_data_t1_complete_grade$correct)
spatial_proportional_data_t1_complete_grade$size_red = spatial_proportional_data_t1_complete_grade$size_num * spatial_proportional_data_t1_complete_grade$red_num
nl_grade_size_num2 <- lmer(PRLCResp ~ size_num*T0SY1Y2G_StartGrade + red_num*T0SY1Y2G_StartGrade + size_red*T0SY1Y2G_StartGrade +
(1 |PRLSubjectID),
data = spatial_proportional_data_t1_complete_grade,
control = lmerControl(optimizer = "bobyqa"))
summary(nl_grade_size_num2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## PRLCResp ~ size_num * T0SY1Y2G_StartGrade + red_num * T0SY1Y2G_StartGrade +
## size_red * T0SY1Y2G_StartGrade + (1 | PRLSubjectID)
## Data: spatial_proportional_data_t1_complete_grade
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 2564.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.0523 -0.6568 -0.1570 0.6706 3.4017
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.01302 0.1141
## Residual 0.07644 0.2765
## Number of obs: 7058, groups: PRLSubjectID, 472
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.1894072 0.0442442 6938.5782634 4.281
## size_num -0.0005882 0.0026402 6580.8085685 -0.223
## T0SY1Y2G_StartGrade -0.0918406 0.0256750 6938.7226748 -3.577
## red_num 0.0865201 0.0093644 6580.8739500 9.239
## size_red -0.0025375 0.0005684 6580.9274688 -4.464
## size_num:T0SY1Y2G_StartGrade 0.0018178 0.0015332 6581.3706600 1.186
## T0SY1Y2G_StartGrade:red_num 0.0287270 0.0054346 6580.9284934 5.286
## T0SY1Y2G_StartGrade:size_red -0.0013375 0.0003300 6581.3581680 -4.053
## Pr(>|t|)
## (Intercept) 0.000018861 ***
## size_num 0.82370
## T0SY1Y2G_StartGrade 0.00035 ***
## red_num < 0.0000000000000002 ***
## size_red 0.000008161 ***
## size_num:T0SY1Y2G_StartGrade 0.23581
## T0SY1Y2G_StartGrade:red_num 0.000000129 ***
## T0SY1Y2G_StartGrade:size_red 0.000051211 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm T0SY1Y2G_StG red_nm siz_rd s_:T0S
## size_num -0.900
## T0SY1Y2G_StG -0.663 0.597
## red_num -0.958 0.887 0.635
## size_red 0.872 -0.970 -0.578 -0.912
## s_:T0SY1Y2G 0.597 -0.663 -0.900 -0.588 0.643
## T0SY1Y2G_StrtGrd:r_ 0.635 -0.588 -0.958 -0.663 0.605 0.887
## T0SY1Y2G_StrtGrd:s_ -0.578 0.643 0.872 0.605 -0.663 -0.970
## T0SY1Y2G_StrtGrd:r_
## size_num
## T0SY1Y2G_StG
## red_num
## size_red
## s_:T0SY1Y2G
## T0SY1Y2G_StrtGrd:r_
## T0SY1Y2G_StrtGrd:s_ -0.912
Anova(nl_grade_size_num2, test.statistic = 'F', type = "III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 18.3265 1 6938.5 0.0000188606 ***
## size_num 0.0496 1 6580.4 0.8236962
## T0SY1Y2G_StartGrade 12.7952 1 6938.6 0.0003499 ***
## red_num 85.3646 1 6580.5 < 0.00000000000000022 ***
## size_red 19.9313 1 6580.6 0.0000081613 ***
## size_num:T0SY1Y2G_StartGrade 1.4057 1 6581.0 0.2358074
## T0SY1Y2G_StartGrade:red_num 27.9406 1 6580.6 0.0000001291 ***
## T0SY1Y2G_StartGrade:size_red 16.4244 1 6581.0 0.0000512118 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em=emtrends(nl_grade_size_num2, pairwise ~ T0SY1Y2G_StartGrade, var="size_red", at=list(T0SY1Y2G_StartGrade=c(-1,0,1,2,4)))
summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
## $emtrends
## T0SY1Y2G_StartGrade size_red.trend SE df asymp.LCL asymp.UCL z.ratio
## -1 -0.00120 0.000825 Inf -0.00282 0.000417 -1.454
## 0 -0.00254 0.000568 Inf -0.00365 -0.001424 -4.464
## 1 -0.00388 0.000428 Inf -0.00471 -0.003036 -9.053
## 2 -0.00521 0.000511 Inf -0.00621 -0.004211 -10.198
## 4 -0.00789 0.001035 Inf -0.00992 -0.005859 -7.622
## p.value
## 0.1458
## <.0001
## <.0001
## <.0001
## <.0001
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df asymp.LCL
## (T0SY1Y2G_StartGrade-1) - T0SY1Y2G_StartGrade0 0.00134 0.00033 Inf 0.000437
## (T0SY1Y2G_StartGrade-1) - T0SY1Y2G_StartGrade1 0.00268 0.00066 Inf 0.000875
## (T0SY1Y2G_StartGrade-1) - T0SY1Y2G_StartGrade2 0.00401 0.00099 Inf 0.001312
## (T0SY1Y2G_StartGrade-1) - T0SY1Y2G_StartGrade4 0.00669 0.00165 Inf 0.002186
## T0SY1Y2G_StartGrade0 - T0SY1Y2G_StartGrade1 0.00134 0.00033 Inf 0.000437
## T0SY1Y2G_StartGrade0 - T0SY1Y2G_StartGrade2 0.00268 0.00066 Inf 0.000875
## T0SY1Y2G_StartGrade0 - T0SY1Y2G_StartGrade4 0.00535 0.00132 Inf 0.001749
## T0SY1Y2G_StartGrade1 - T0SY1Y2G_StartGrade2 0.00134 0.00033 Inf 0.000437
## T0SY1Y2G_StartGrade1 - T0SY1Y2G_StartGrade4 0.00401 0.00099 Inf 0.001312
## T0SY1Y2G_StartGrade2 - T0SY1Y2G_StartGrade4 0.00268 0.00066 Inf 0.000875
## asymp.UCL z.ratio p.value
## 0.00224 4.053 0.0005
## 0.00448 4.053 0.0005
## 0.00671 4.053 0.0005
## 0.01119 4.053 0.0005
## 0.00224 4.053 0.0005
## 0.00448 4.053 0.0005
## 0.00895 4.053 0.0005
## 0.00224 4.053 0.0005
## 0.00671 4.053 0.0005
## 0.00448 4.053 0.0005
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
## Conf-level adjustment: tukey method for comparing a family of 5 estimates
## P value adjustment: tukey method for comparing a family of 5 estimates
# nl_grade_size_num <- lmer(PRLCResp ~ size_num * red_num * T0SY1Y2G_StartGrade +
# (1 |PRLSubjectID),
# data = spatial_proportional_data_t1_complete_grade,
# control = lmerControl(optimizer = "bobyqa"))
# summary(nl_grade_size_num)
# Anova(nl_grade_size_num, test.statistic = 'F')
# em=emtrends(nl_grade_size_num, pairwise ~ red_num, var="size_num", at=list(T0SY1Y2G_StartGrade=c(-1), red_num=c(3,4,5,6)))
# summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
nl_grade_size_num_prek <- lmer(PRLCResp ~ size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade == -1),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_grade_size_num_prek)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data:
## subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade ==
## -1)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 594.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1362 -0.7509 -0.1143 0.9086 2.1195
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.02056 0.1434
## Residual 0.10755 0.3280
## Number of obs: 806, groups: PRLSubjectID, 54
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.4934179 0.1163143 791.9283480 4.242 0.0000248 ***
## size_num -0.0095459 0.0069330 749.1455995 -1.377 0.169
## red_num 0.0098829 0.0245827 749.1087665 0.402 0.688
## size_num:red_num 0.0009378 0.0014933 749.1740164 0.628 0.530
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.899
## red_num -0.956 0.887
## sz_nm:rd_nm 0.870 -0.970 -0.912
Anova(nl_grade_size_num_prek, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 17.9954 1 791.92 0.00002476 ***
## size_num 1.8958 1 749.10 0.1690
## red_num 0.1616 1 749.06 0.6878
## size_num:red_num 0.3943 1 749.13 0.5302
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_grade_size_num_k <- lmer(PRLCResp ~ size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade == 0),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_grade_size_num_k)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data:
## subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade ==
## 0)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 1047.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3330 -0.6944 -0.2243 0.8253 2.5129
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.01799 0.1341
## Residual 0.09806 0.3131
## Number of obs: 1677, groups: PRLSubjectID, 112
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.0632423 0.0771550 1649.8228003 0.820
## size_num 0.0042158 0.0045990 1562.0773979 0.917
## red_num 0.1165702 0.0163106 1562.1730254 7.147
## size_num:red_num -0.0040082 0.0009896 1562.0904310 -4.050
## Pr(>|t|)
## (Intercept) 0.413
## size_num 0.359
## red_num 0.00000000000136 ***
## size_num:red_num 0.00005366308181 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.900
## red_num -0.957 0.887
## sz_nm:rd_nm 0.871 -0.970 -0.913
Anova(nl_grade_size_num_k, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 0.6719 1 1649.8 0.4125
## size_num 0.8403 1 1562.0 0.3594
## red_num 51.0783 1 1562.1 0.000000000001357 ***
## size_num:red_num 16.4049 1 1562.0 0.000053663288412 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_grade_size_num_g1 <- lmer(PRLCResp ~ size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade == 1),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_grade_size_num_g1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data:
## subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade ==
## 1)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 729.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9483 -0.6510 -0.2012 0.7105 2.8709
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.01267 0.1126
## Residual 0.08279 0.2877
## Number of obs: 1630, groups: PRLSubjectID, 109
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.0561137 0.0715958 1596.6337617 0.784
## size_num 0.0016256 0.0042752 1518.1771701 0.380
## red_num 0.1236576 0.0151766 1518.2239470 8.148
## size_num:red_num -0.0039534 0.0009203 1518.1585755 -4.296
## Pr(>|t|)
## (Intercept) 0.433
## size_num 0.704
## red_num 0.000000000000000766 ***
## size_num:red_num 0.000018527209654952 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.901
## red_num -0.959 0.887
## sz_nm:rd_nm 0.873 -0.970 -0.912
Anova(nl_grade_size_num_g1, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 0.6143 1 1596.6 0.4333
## size_num 0.1446 1 1518.0 0.7038
## red_num 66.3882 1 1518.1 0.0000000000000007658 ***
## size_num:red_num 18.4523 1 1518.0 0.0000185273715112455 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_grade_size_num_g2 <- lmer(PRLCResp ~ size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade == 2),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_grade_size_num_g2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data:
## subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade ==
## 2)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 180.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.3633 -0.6402 -0.1353 0.5069 3.1834
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.01064 0.1032
## Residual 0.05869 0.2423
## Number of obs: 1598, groups: PRLSubjectID, 107
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.0582807 0.0610118 1571.4553006 0.955
## size_num 0.0015004 0.0036353 1488.1803019 0.413
## red_num 0.1290943 0.0129122 1488.2775541 9.998
## size_num:red_num -0.0047321 0.0007829 1488.2205143 -6.044
## Pr(>|t|)
## (Intercept) 0.34
## size_num 0.68
## red_num < 0.0000000000000002 ***
## size_num:red_num 0.0000000019 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.900
## red_num -0.957 0.887
## sz_nm:rd_nm 0.871 -0.970 -0.913
Anova(nl_grade_size_num_g2, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 0.9125 1 1571.4 0.3396
## size_num 0.1704 1 1488.1 0.6799
## red_num 99.9567 1 1488.2 < 0.00000000000000022 ***
## size_num:red_num 36.5318 1 1488.2 0.000000001895 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_grade_size_num_g3 <- lmer(PRLCResp ~ size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade == 3),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_grade_size_num_g3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data:
## subset(spatial_proportional_data_t1_complete_grade, T0SY1Y2G_StartGrade ==
## 3)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: -272.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.0852 -0.6162 -0.1114 0.5596 4.4427
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.00497 0.0705
## Residual 0.04354 0.2087
## Number of obs: 1347, groups: PRLSubjectID, 90
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) -0.068601 0.056987 1310.377189 -1.204
## size_num 0.004513 0.003421 1254.418355 1.319
## red_num 0.171502 0.012113 1254.139384 14.159
## size_num:red_num -0.006473 0.000736 1254.340306 -8.795
## Pr(>|t|)
## (Intercept) 0.229
## size_num 0.187
## red_num <0.0000000000000002 ***
## size_num:red_num <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.904
## red_num -0.962 0.886
## sz_nm:rd_nm 0.876 -0.970 -0.912
Anova(nl_grade_size_num_g3, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 1.4491 1 1310.4 0.2289
## size_num 1.7405 1 1254.4 0.1873
## red_num 200.4805 1 1254.1 <0.0000000000000002 ***
## size_num:red_num 77.3508 1 1254.3 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
agg_spatial_proportional_data_t1_complete_grade_pae = aggregate(pae ~ PRLSubjectID*T0SY1Y2G_StartGrade, spatial_proportional_data_t1_complete_grade, mean )
ezANOVA(agg_spatial_proportional_data_t1_complete_grade_pae, dv = pae, between = T0SY1Y2G_StartGrade, wid = PRLSubjectID)
## $ANOVA
## Effect DFn DFd F p
## 1 T0SY1Y2G_StartGrade 1 470 140.9734 0.0000000000000000000000000001284825
## p<.05 ges
## 1 * 0.2307357
summarySE(agg_spatial_proportional_data_t1_complete_grade_pae, "pae","T0SY1Y2G_StartGrade")
## T0SY1Y2G_StartGrade N pae sd se ci
## 1 -1 54 0.3301094 0.12631504 0.017189300 0.03447737
## 2 0 112 0.2728368 0.11293251 0.010671119 0.02114553
## 3 1 109 0.2357620 0.12384613 0.011862307 0.02351315
## 4 2 107 0.1883900 0.09663632 0.009342186 0.01852179
## 5 3 90 0.1438095 0.06694919 0.007057064 0.01402224
pairwise.t.test(agg_spatial_proportional_data_t1_complete_grade_pae$pae, agg_spatial_proportional_data_t1_complete_grade_pae$T0SY1Y2G_StartGrade,
paired = FALSE,
alternative = c("two.sided"))
##
## Pairwise comparisons using t tests with pooled SD
##
## data: agg_spatial_proportional_data_t1_complete_grade_pae$pae and agg_spatial_proportional_data_t1_complete_grade_pae$T0SY1Y2G_StartGrade
##
## -1 0 1 2
## 0 0.0047 - - -
## 1 0.0000008125133504 0.0100 - -
## 2 0.0000000000001021 0.0000000524514700 0.0047 -
## 3 < 0.0000000000000002 0.0000000000000016 0.0000000200464796 0.0072
##
## P value adjustment method: holm
spatial_proportional_data_t1_complete = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete, time == "t1")
spatial_proportional_data_t1_all = subset(spatial_proportional_data_t1_complete, select = c("PRLSubjectID","PRLCResp", "image"))
spatial_proportional_data_t1_all_spread = spread(spatial_proportional_data_t1_all, image, PRLCResp)
set.seed(777)
vLPA_nl = spatial_proportional_data_t1_all_spread %>%
dplyr::select(-c(PRLSubjectID)) %>%
single_imputation(method = "missForest") %>%
scale() %>%
estimate_profiles(1:10)
vLPA_nl
## tidyLPA analysis using mclust:
##
## Model Classes AIC BIC Entropy prob_min prob_max n_min n_max BLRT_p
## 1 1 20137.15 20261.86 1.00 1.00 1.00 1.00 1.00
## 1 2 18750.44 18941.66 0.94 0.97 0.99 0.24 0.76 0.01
## 1 3 18509.88 18767.61 0.88 0.91 0.97 0.22 0.53 0.01
## 1 4 18003.54 18327.79 0.97 0.96 0.99 0.09 0.56 0.01
## 1 5 17961.17 18351.93 0.93 0.89 0.99 0.11 0.44 0.01
## 1 6 17912.71 18369.98 0.95 0.91 0.99 0.06 0.41 0.01
## 1 7 17920.62 18444.40 0.93 0.76 0.99 0.04 0.38 0.39
## 1 8 17875.80 18466.10 0.92 0.75 0.99 0.04 0.36 0.01
## 1 9 17687.89 18344.69 0.92 0.78 0.99 0.04 0.32 0.01
## 1 10 17707.31 18430.62 0.90 0.65 0.99 0.03 0.30 0.98
compare_solutions(vLPA_nl, statistics = c("AIC","BIC"))
## Compare tidyLPA solutions:
##
## Model Classes AIC BIC
## 1 1 20137.154 20261.863
## 1 2 18750.442 18941.663
## 1 3 18509.880 18767.613
## 1 4 18003.543 18327.788
## 1 5 17961.175 18351.931
## 1 6 17912.713 18369.980
## 1 7 17920.618 18444.397
## 1 8 17875.804 18466.095
## 1 9 17687.892 18344.695
## 1 10 17707.310 18430.625
##
## Best model according to AIC is Model 1 with 9 classes.
## Best model according to BIC is Model 1 with 4 classes.
##
## An analytic hierarchy process, based on the fit indices AIC, AWE, BIC, CLC, and KIC (Akogul & Erisoglu, 2017), suggests the best solution is Model 1 with 9 classes.
set.seed(777)
vLPA_nl_4 = spatial_proportional_data_t1_all_spread %>%
dplyr::select(-c(PRLSubjectID)) %>%
single_imputation(method = "missForest") %>%
scale() %>%
estimate_profiles(4)
vLPA_nl_4
## tidyLPA analysis using mclust:
##
## Model Classes AIC BIC Entropy prob_min prob_max n_min n_max BLRT_p
## 1 4 18003.54 18327.79 0.97 0.96 0.99 0.09 0.56 0.01
clusters_nl = as.data.frame(get_data(vLPA_nl_4))
clusters_nl = cbind(spatial_proportional_data_t1_all_spread$PRLSubjectID, clusters_nl)
names(clusters_nl)[1] = "PRLSubjectID"
clusters_nl$PRLSubjectID = as.character(clusters_nl$PRLSubjectID)
spatial_proportional_data_t1_all_class = spatial_proportional_data_t1_complete %>%
left_join(clusters_nl[c("PRLSubjectID","Class")], by = "PRLSubjectID")
distinct(spatial_proportional_data_t1_all_class[c("PRLSubjectID","Class")]) %>%
{table(.$Class)}
##
## 1 2 3 4
## 41 266 97 68
spatial_proportional_data_t1_complete_class_grade = spatial_proportional_data_t1_all_class %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade")], by = "PRLSubjectID")
distinct(spatial_proportional_data_t1_complete_class_grade[c("PRLSubjectID","Class","T0SY1Y2G_StartGrade")]) %>%
{table(.$Class,.$T0SY1Y2G_StartGrade)}
##
## -1 0 1 2 3
## 1 15 10 12 4 0
## 2 13 46 66 70 71
## 3 11 29 19 23 15
## 4 15 27 12 10 4
distinct(spatial_proportional_data_t1_complete_class_grade[c("PRLSubjectID","Class","T0SY1Y2G_StartGrade")]) %>%
{with(., table(Class, T0SY1Y2G_StartGrade)) %>% prop.table(margin = 2)}
## T0SY1Y2G_StartGrade
## Class -1 0 1 2 3
## 1 0.27777778 0.08928571 0.11009174 0.03738318 0.00000000
## 2 0.24074074 0.41071429 0.60550459 0.65420561 0.78888889
## 3 0.20370370 0.25892857 0.17431193 0.21495327 0.16666667
## 4 0.27777778 0.24107143 0.11009174 0.09345794 0.04444444
spatial_proportional_data_t1_all_class$size_num=
as.numeric(as.character(spatial_proportional_data_t1_all_class$size2))
spatial_proportional_data_t1_all_class$red_num =
as.numeric(as.character(spatial_proportional_data_t1_all_class$red...11))
spatial_proportional_data_t1_all_class = spatial_proportional_data_t1_all_class %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade")], by = "PRLSubjectID")
spatial_proportional_data_t1_all_class$Class = as.factor(spatial_proportional_data_t1_all_class$Class)
spatial_proportional_data_t1_all_class$size_red = spatial_proportional_data_t1_all_class$size_num * spatial_proportional_data_t1_all_class$red_num
nl_class_size_num2 <- lmer(PRLCResp ~ Class * size_red + Class * size_num + Class * red_num + T0SY1Y2G_StartGrade +
(1 |PRLSubjectID),
data = spatial_proportional_data_t1_all_class,
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_size_num2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ Class * size_red + Class * size_num + Class * red_num +
## T0SY1Y2G_StartGrade + (1 | PRLSubjectID)
## Data: spatial_proportional_data_t1_all_class
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 1216.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.0583 -0.5924 -0.0737 0.6052 3.3881
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.002456 0.04956
## Residual 0.066082 0.25706
## Number of obs: 7058, groups: PRLSubjectID, 472
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) -0.0271226 0.0409112 6893.0896035 -0.663
## Class3 0.0937880 0.0785405 6766.2539801 1.194
## Class4 0.4267029 0.0901801 6778.5596880 4.732
## Class1 0.3885242 0.1112296 6779.1203359 3.493
## size_red -0.0068642 0.0005268 6574.9685206 -13.030
## size_num 0.0022725 0.0024477 6575.0104756 0.928
## red_num 0.1764828 0.0086818 6575.0347098 20.328
## T0SY1Y2G_StartGrade -0.0019285 0.0032106 467.4836413 -0.601
## Class3:size_red 0.0061399 0.0010192 6575.6286755 6.024
## Class4:size_red 0.0063893 0.0011698 6577.5574222 5.462
## Class1:size_red 0.0072071 0.0014403 6574.6848484 5.004
## Class3:size_num -0.0036531 0.0047357 6575.9219387 -0.771
## Class4:size_num -0.0072323 0.0054299 6576.8303658 -1.332
## Class1:size_num 0.0112220 0.0066909 6574.7964474 1.677
## Class3:red_num -0.1195795 0.0167874 6574.8893582 -7.123
## Class4:red_num -0.1106327 0.0192819 6577.7611185 -5.738
## Class1:red_num -0.1934227 0.0237554 6575.3866632 -8.142
## Pr(>|t|)
## (Intercept) 0.507376
## Class3 0.232467
## Class4 0.00000227191179232 ***
## Class1 0.000481 ***
## size_red < 0.0000000000000002 ***
## size_num 0.353227
## red_num < 0.0000000000000002 ***
## T0SY1Y2G_StartGrade 0.548357
## Class3:size_red 0.00000000179082031 ***
## Class4:size_red 0.00000004881258034 ***
## Class1:size_red 0.00000057626091243 ***
## Class3:size_num 0.440507
## Class4:size_num 0.182929
## Class1:size_num 0.093549 .
## Class3:red_num 0.00000000000116699 ***
## Class4:red_num 0.00000001002751824 ***
## Class1:red_num 0.00000000000000046 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(nl_class_size_num2, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 0.4395 1 6893.0 0.5074
## Class 10.0154 3 6771.6 0.00000139215681412 ***
## size_red 169.7713 1 6574.7 < 0.00000000000000022 ***
## size_num 0.8620 1 6574.8 0.3532
## red_num 413.2230 1 6574.8 < 0.00000000000000022 ***
## T0SY1Y2G_StartGrade 0.3608 1 467.3 0.5484
## Class:size_red 21.8404 3 6575.8 0.00000000000004541 ***
## Class:size_num 2.0301 3 6575.7 0.1074
## Class:red_num 36.6136 3 6575.8 < 0.00000000000000022 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em=emtrends(nl_class_size_num2, pairwise ~ Class, var="size_red")
summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
## $emtrends
## Class size_red.trend SE df asymp.LCL asymp.UCL z.ratio p.value
## 2 -0.006864 0.000527 Inf -0.00790 -0.005832 -13.030 <.0001
## 3 -0.000724 0.000872 Inf -0.00243 0.000986 -0.830 0.4064
## 4 -0.000475 0.001044 Inf -0.00252 0.001572 -0.455 0.6493
## 1 0.000343 0.001340 Inf -0.00228 0.002970 0.256 0.7981
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df asymp.LCL asymp.UCL z.ratio p.value
## Class2 - Class3 -0.006140 0.00102 Inf -0.00876 -0.00352 -6.024 <.0001
## Class2 - Class4 -0.006389 0.00117 Inf -0.00939 -0.00338 -5.462 <.0001
## Class2 - Class1 -0.007207 0.00144 Inf -0.01091 -0.00351 -5.004 <.0001
## Class3 - Class4 -0.000249 0.00136 Inf -0.00375 0.00325 -0.183 0.9978
## Class3 - Class1 -0.001067 0.00160 Inf -0.00518 0.00304 -0.667 0.9094
## Class4 - Class1 -0.000818 0.00170 Inf -0.00518 0.00355 -0.481 0.9633
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
## Conf-level adjustment: tukey method for comparing a family of 4 estimates
## P value adjustment: tukey method for comparing a family of 4 estimates
# nl_class_size_num <- lmer(PRLCResp ~ Class * size_num * red_num + T0SY1Y2G_StartGrade +
# (1 |PRLSubjectID),
# data = spatial_proportional_data_t1_all_class,
# control = lmerControl(optimizer = "bobyqa"))
# summary(nl_class_size_num)
# Anova(nl_class_size_num, test.statistic = 'F')
# em=emtrends(nl_class_size_num, pairwise ~ red_num|Class, var="size_num", mult.name = "red_num", at=list( red_num=c(3,4,5,6)))
# summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
nl_class_size_num_c2 <- lmer(PRLCResp ~size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_all_class, Class == 2),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_size_num_c2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data: subset(spatial_proportional_data_t1_all_class, Class == 2)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: -330.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4383 -0.6151 -0.0440 0.5600 3.8096
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.001208 0.03476
## Residual 0.052282 0.22865
## Number of obs: 3981, groups: PRLSubjectID, 266
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) -0.0300710 0.0360872 3805.0655015 -0.833
## size_num 0.0022726 0.0021772 3712.2592107 1.044
## red_num 0.1764835 0.0077222 3712.2683978 22.854
## size_num:red_num -0.0068643 0.0004686 3712.2311214 -14.649
## Pr(>|t|)
## (Intercept) 0.405
## size_num 0.297
## red_num <0.0000000000000002 ***
## size_num:red_num <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.910
## red_num -0.968 0.887
## sz_nm:rd_nm 0.882 -0.970 -0.912
Anova(nl_class_size_num_c2, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 0.6944 1 3805.2 0.4047
## size_num 1.0896 1 3712.5 0.2966
## red_num 522.3024 1 3712.5 <0.0000000000000002 ***
## size_num:red_num 214.5873 1 3712.5 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_class_size_num_c3 <- lmer(PRLCResp ~size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_all_class, Class == 3),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_size_num_c3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data: subset(spatial_proportional_data_t1_all_class, Class == 3)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: -74.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7955 -0.5309 -0.2168 0.1714 3.4951
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.003384 0.05817
## Residual 0.051776 0.22754
## Number of obs: 1449, groups: PRLSubjectID, 97
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.0646780 0.0596142 1396.4777396 1.085 0.278
## size_num -0.0013781 0.0035886 1349.7008611 -0.384 0.701
## red_num 0.0569075 0.0127182 1349.4669842 4.474 0.0000083 ***
## size_num:red_num -0.0007248 0.0007723 1349.6373565 -0.939 0.348
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.907
## red_num -0.965 0.886
## sz_nm:rd_nm 0.879 -0.970 -0.912
Anova(nl_class_size_num_c3, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 1.1771 1 1396.3 0.2781
## size_num 0.1475 1 1349.3 0.7010
## red_num 20.0211 1 1349.1 0.000008304 ***
## size_num:red_num 0.8809 1 1349.3 0.3481
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_class_size_num_c4 <- lmer(PRLCResp ~size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_all_class, Class == 4),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_size_num_c4)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data: subset(spatial_proportional_data_t1_all_class, Class == 4)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 748.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.3278 -0.9619 0.3604 0.8162 1.5991
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.006011 0.07753
## Residual 0.114110 0.33780
## Number of obs: 1014, groups: PRLSubjectID, 68
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.3987539 0.1058341 973.5882032 3.768 0.000175 ***
## size_num -0.0049578 0.0063693 943.5258313 -0.778 0.436533
## red_num 0.0658463 0.0226247 943.6724048 2.910 0.003695 **
## size_num:red_num -0.0004757 0.0013725 943.6423335 -0.347 0.728972
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.909
## red_num -0.966 0.887
## sz_nm:rd_nm 0.880 -0.970 -0.913
Anova(nl_class_size_num_c4, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 14.1956 1 973.51 0.0001747 ***
## size_num 0.6059 1 943.39 0.4365360
## red_num 8.4702 1 943.54 0.0036951 **
## size_num:red_num 0.1201 1 943.51 0.7289738
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nl_class_size_num_c1 <- lmer(PRLCResp ~size_num * red_num +
(1 |PRLSubjectID),
data = subset(spatial_proportional_data_t1_all_class, Class == 1),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_size_num_c1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: PRLCResp ~ size_num * red_num + (1 | PRLSubjectID)
## Data: subset(spatial_proportional_data_t1_all_class, Class == 1)
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 432.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9157 -0.8800 0.0123 0.8721 1.8837
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.002509 0.05009
## Residual 0.110352 0.33219
## Number of obs: 614, groups: PRLSubjectID, 41
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.3614657 0.1335357 584.2429553 2.707 0.00699 **
## size_num 0.0134845 0.0080469 569.9810135 1.676 0.09434 .
## red_num -0.0169952 0.0285743 570.0484965 -0.595 0.55223
## size_num:red_num 0.0003447 0.0017322 569.9688196 0.199 0.84234
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) siz_nm red_nm
## size_num -0.910
## red_num -0.968 0.887
## sz_nm:rd_nm 0.881 -0.970 -0.912
Anova(nl_class_size_num_c1, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: PRLCResp
## F Df Df.res Pr(>F)
## (Intercept) 7.3271 1 584.29 0.006991 **
## size_num 2.8081 1 570.05 0.094339 .
## red_num 0.3538 1 570.12 0.552233
## size_num:red_num 0.0396 1 570.04 0.842342
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# em=emtrends(nl_class_size_num_c3, pairwise ~ red_num, var="size_num", mult.name = "red_num", at=list( red_num=c(3,4,5,6)))
# summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae =
spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete
spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae =
spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae %>% left_join(clusters_nl[c("PRLSubjectID","Class")], by = "PRLSubjectID")
spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae$pae =
abs(as.numeric(spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae$correct) -
as.numeric(spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae$PRLCResp))
spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae$dir =
(as.numeric(spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae$correct) -
as.numeric(spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae$PRLCResp))
# agg_pae_tall = aggregate(pae ~ PRLSubjectID*Class*time, spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae, mean)
agg_pae_tall = spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae
agg_pae_tall$time_num = as.numeric(as.factor(agg_pae_tall$time))
agg_pae_tall = agg_pae_tall %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade")], by = "PRLSubjectID")
agg_pae_tall$Class = factor(agg_pae_tall$Class, levels = c("2","3","4","1"))
nl_class_pae <- lmer(pae ~ time_num * Class +
T0SY1Y2G_StartGrade +
(1|PRLSubjectID),
data = subset(agg_pae_tall, !is.na(Class)),
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_pae)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pae ~ time_num * Class + T0SY1Y2G_StartGrade + (1 | PRLSubjectID)
## Data: subset(agg_pae_tall, !is.na(Class))
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: -14878.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.9766 -0.5904 -0.2399 0.3421 5.1213
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.002915 0.05399
## Residual 0.029596 0.17204
## Number of obs: 23113, groups: PRLSubjectID, 472
##
## Fixed effects:
## Estimate Std. Error df t value
## (Intercept) 0.203737 0.005989 876.120478 34.020
## time_num -0.015309 0.001399 23061.057893 -10.946
## Class3 0.089714 0.009361 1310.989869 9.584
## Class4 0.198318 0.011090 1305.585388 17.883
## Class1 0.278112 0.013841 1334.575572 20.093
## T0SY1Y2G_StartGrade -0.019855 0.002314 458.495106 -8.581
## time_num:Class3 -0.014678 0.002598 23103.420865 -5.649
## time_num:Class4 -0.043000 0.003209 22959.641965 -13.401
## time_num:Class1 -0.065233 0.004131 22616.387373 -15.790
## Pr(>|t|)
## (Intercept) < 0.0000000000000002 ***
## time_num < 0.0000000000000002 ***
## Class3 < 0.0000000000000002 ***
## Class4 < 0.0000000000000002 ***
## Class1 < 0.0000000000000002 ***
## T0SY1Y2G_StartGrade < 0.0000000000000002 ***
## time_num:Class3 0.0000000163 ***
## time_num:Class4 < 0.0000000000000002 ***
## time_num:Class1 < 0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) tim_nm Class3 Class4 Class1 T0SY1Y tm_:C3 tm_:C4
## time_num -0.525
## Class3 -0.493 0.337
## Class4 -0.489 0.284 0.255
## Class1 -0.422 0.227 0.211 0.207
## T0SY1Y2G_SG -0.589 -0.004 0.127 0.231 0.236
## tm_nm:Clss3 0.286 -0.538 -0.645 -0.154 -0.124 -0.003
## tm_nm:Clss4 0.232 -0.436 -0.147 -0.637 -0.100 -0.004 0.235
## tm_nm:Clss1 0.179 -0.339 -0.114 -0.096 -0.638 0.000 0.182 0.148
Anova(nl_class_pae, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: pae
## F Df Df.res Pr(>F)
## (Intercept) 1157.299 1 882.0 < 0.00000000000000022 ***
## time_num 119.788 1 23061.4 < 0.00000000000000022 ***
## Class 202.087 3 1346.3 < 0.00000000000000022 ***
## T0SY1Y2G_StartGrade 73.628 1 461.6 < 0.00000000000000022 ***
## time_num:Class 124.908 3 22938.0 < 0.00000000000000022 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
em=emtrends(nl_class_pae, pairwise ~ Class, var="time_num", mult.name = "Class")
summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
## $emtrends
## Class time_num.trend SE df asymp.LCL asymp.UCL z.ratio p.value
## 2 -0.0153 0.00140 Inf -0.0181 -0.0126 -10.946 <.0001
## 3 -0.0300 0.00219 Inf -0.0343 -0.0257 -13.694 <.0001
## 4 -0.0583 0.00289 Inf -0.0640 -0.0526 -20.192 <.0001
## 1 -0.0805 0.00389 Inf -0.0882 -0.0729 -20.719 <.0001
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df asymp.LCL asymp.UCL z.ratio p.value
## Class2 - Class3 0.0147 0.00260 Inf 0.00800 0.0214 5.649 <.0001
## Class2 - Class4 0.0430 0.00321 Inf 0.03476 0.0512 13.401 <.0001
## Class2 - Class1 0.0652 0.00413 Inf 0.05462 0.0758 15.790 <.0001
## Class3 - Class4 0.0283 0.00362 Inf 0.01901 0.0376 7.815 <.0001
## Class3 - Class1 0.0506 0.00446 Inf 0.03909 0.0620 11.331 <.0001
## Class4 - Class1 0.0222 0.00484 Inf 0.00979 0.0347 4.591 <.0001
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
## Conf-level adjustment: tukey method for comparing a family of 4 estimates
## P value adjustment: tukey method for comparing a family of 4 estimates
emeans=emmeans(nl_class_pae, pairwise ~ Class|time_num, mult.name = "Class", at=list(time_num=c(1,2,3,4)))
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## time_num = 1:
## Class emmean SE df asymp.LCL asymp.UCL z.ratio p.value
## 2 0.165 0.00416 Inf 0.157 0.173 39.781 <.0001
## 3 0.240 0.00672 Inf 0.227 0.254 35.774 <.0001
## 4 0.321 0.00823 Inf 0.305 0.337 38.938 <.0001
## 1 0.378 0.01070 Inf 0.357 0.399 35.363 <.0001
##
## time_num = 2:
## Class emmean SE df asymp.LCL asymp.UCL z.ratio p.value
## 2 0.150 0.00378 Inf 0.143 0.157 39.642 <.0001
## 3 0.210 0.00608 Inf 0.198 0.222 34.596 <.0001
## 4 0.262 0.00751 Inf 0.248 0.277 34.951 <.0001
## 1 0.298 0.00978 Inf 0.279 0.317 30.445 <.0001
##
## time_num = 3:
## Class emmean SE df asymp.LCL asymp.UCL z.ratio p.value
## 2 0.135 0.00391 Inf 0.127 0.142 34.459 <.0001
## 3 0.180 0.00620 Inf 0.168 0.193 29.109 <.0001
## 4 0.204 0.00784 Inf 0.189 0.219 26.008 <.0001
## 1 0.217 0.01035 Inf 0.197 0.237 20.987 <.0001
##
## time_num = 4:
## Class emmean SE df asymp.LCL asymp.UCL z.ratio p.value
## 2 0.119 0.00449 Inf 0.111 0.128 26.596 <.0001
## 3 0.150 0.00703 Inf 0.137 0.164 21.396 <.0001
## 4 0.146 0.00913 Inf 0.128 0.164 15.954 <.0001
## 1 0.137 0.01219 Inf 0.113 0.160 11.201 <.0001
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
##
## $contrasts
## time_num = 1:
## contrast estimate SE df asymp.LCL asymp.UCL z.ratio p.value
## Class2 - Class3 -0.07504 0.00794 Inf -0.0906 -0.05948 -9.454 <.0001
## Class2 - Class4 -0.15532 0.00938 Inf -0.1737 -0.13694 -16.561 <.0001
## Class2 - Class1 -0.21288 0.01165 Inf -0.2357 -0.19005 -18.273 <.0001
## Class3 - Class4 -0.08028 0.01057 Inf -0.1010 -0.05956 -7.593 <.0001
## Class3 - Class1 -0.13784 0.01256 Inf -0.1625 -0.11322 -10.971 <.0001
## Class4 - Class1 -0.05756 0.01319 Inf -0.0834 -0.03172 -4.365 <.0001
##
## time_num = 2:
## contrast estimate SE df asymp.LCL asymp.UCL z.ratio p.value
## Class2 - Class3 -0.06036 0.00720 Inf -0.0745 -0.04624 -8.382 <.0001
## Class2 - Class4 -0.11232 0.00857 Inf -0.1291 -0.09551 -13.099 <.0001
## Class2 - Class1 -0.14765 0.01068 Inf -0.1686 -0.12672 -13.828 <.0001
## Class3 - Class4 -0.05196 0.00960 Inf -0.0708 -0.03314 -5.411 <.0001
## Class3 - Class1 -0.08729 0.01144 Inf -0.1097 -0.06486 -7.627 <.0001
## Class4 - Class1 -0.03533 0.01199 Inf -0.0588 -0.01183 -2.947 0.0032
##
## time_num = 3:
## contrast estimate SE df asymp.LCL asymp.UCL z.ratio p.value
## Class2 - Class3 -0.04568 0.00736 Inf -0.0601 -0.03125 -6.204 <.0001
## Class2 - Class4 -0.06932 0.00893 Inf -0.0868 -0.05182 -7.766 <.0001
## Class2 - Class1 -0.08241 0.01124 Inf -0.1044 -0.06038 -7.330 <.0001
## Class3 - Class4 -0.02364 0.00994 Inf -0.0431 -0.00415 -2.377 0.0175
## Class3 - Class1 -0.03673 0.01200 Inf -0.0602 -0.01322 -3.062 0.0022
## Class4 - Class1 -0.01310 0.01267 Inf -0.0379 0.01173 -1.034 0.3013
##
## time_num = 4:
## contrast estimate SE df asymp.LCL asymp.UCL z.ratio p.value
## Class2 - Class3 -0.03100 0.00837 Inf -0.0474 -0.01460 -3.703 0.0002
## Class2 - Class4 -0.02632 0.01032 Inf -0.0465 -0.00610 -2.551 0.0107
## Class2 - Class1 -0.01718 0.01315 Inf -0.0430 0.00860 -1.306 0.1914
## Class3 - Class4 0.00469 0.01148 Inf -0.0178 0.02719 0.408 0.6831
## Class3 - Class1 0.01382 0.01402 Inf -0.0137 0.04131 0.986 0.3242
## Class4 - Class1 0.00914 0.01497 Inf -0.0202 0.03848 0.610 0.5416
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
plot(ggpredict(nl_class_pae, terms=c("time_num","Class")))
agg_pae_tall = aggregate(pae ~ PRLSubjectID*Class*time, spatial_proportional_data_t1_nona_importantcols_names_no20_noshortrt_complete_pae, mean)
agg_pae_tall$time_num = as.numeric(as.factor(agg_pae_tall$time))
graph_pae <- ggplot(summarySE(agg_pae_tall, "pae",c("Class","time_num"), na.rm =T), aes(x=Class, y=pae, fill=Class)) +
geom_hline(yintercept = 0, linetype = "dashed") +
geom_bar(stat="identity", position=position_dodge(), color = "black") +
geom_errorbar(aes(ymin=pae-se, ymax=pae+se), width=.2,
position=position_dodge(.9))+
facet_grid(.~time_num)+
#scale_fill_manual(values = c("#4575b4","#abd9e9","#ffffbf","#f7f7f7"))+
#scale_y_continuous(breaks=seq(0, .4, .1), limits=c(0,.45), expand = c(0, 0))+
theme_bw()+
ylab("PAE")+
theme(legend.position="none",
axis.title.x=element_blank(),
axis.text.x = element_text(size=size_textb),
#axis.title.x = element_text(size = size_text),
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "white", colour = "grey50"),
strip.background =element_rect(fill="#f0f0f0"),
strip.text = element_text(size = size_text),
axis.text.y = element_text(size=size_textb),
axis.title.y = element_text(size=size_text),
legend.text=element_text(size=size_text))
graph_pae
spatial_proportional_data_t1_spread_class = clusters_nl[c("PRLSubjectID","Class")]
spatial_proportional_data_t1_spread_class = spatial_proportional_data_t1_spread_class %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade","T0PDEMOMaxParentEducation",
"T0SGENGender","T0SAGE_T1S1Age")], by = "PRLSubjectID")
spatial_proportional_data_t1_spread_class = spatial_proportional_data_t1_spread_class %>%
left_join(spatial_proportional_math_data[c("PRLSubjectID","T1LWIDWS.s")],
by = "PRLSubjectID")
spatial_proportional_data_t1_spread_class$Class = as.factor(as.character(spatial_proportional_data_t1_spread_class$Class))
spatial_proportional_data_t1_spread_class = spatial_proportional_data_t1_spread_class %>%
dplyr::mutate(
dplyr::across(
where(is.numeric),
~if_else(. %in% c(-999), NA_real_, .)
)
)
distinct(spatial_proportional_data_t1_spread_class[c("PRLSubjectID","Class","T0SY1Y2G_StartGrade")]) %>%
{table(.$T0SY1Y2G_StartGrade, .$Class)}
##
## 1 2 3 4
## -1 15 13 11 15
## 0 10 46 29 27
## 1 12 66 19 12
## 2 4 70 23 10
## 3 0 71 15 4
distinct(spatial_proportional_data_t1_spread_class[c("PRLSubjectID","Class","T0SGENGender")]) %>%
{table(.$T0SGENGender, .$Class)}
##
## 1 2 3 4
## 1 21 151 50 36
## 2 20 114 47 32
distinct(spatial_proportional_data_t1_spread_class[c("PRLSubjectID","Class","T0PDEMOMaxParentEducation")]) %>%
{table(.$T0PDEMOMaxParentEducation, .$Class)}
##
## 1 2 3 4
## 10 1 8 5 2
## 12 3 36 12 10
## 13 9 49 16 13
## 14 5 39 11 10
## 16 11 31 14 8
## 17 4 19 9 7
## 18 4 64 16 10
spatial_proportional_data_t1_spread_class$Class = relevel(spatial_proportional_data_t1_spread_class$Class, ref = "2")
fit_ref2 = multinom(Class ~ T0PDEMOMaxParentEducation
+ as.factor(T0SGENGender)
+ T0SY1Y2G_StartGrade
+ T1LWIDWS.s,
data = spatial_proportional_data_t1_spread_class)
## # weights: 24 (15 variable)
## initial value 512.928914
## iter 10 value 399.766495
## iter 20 value 377.867794
## final value 377.866256
## converged
# Print the model summary
#summary(fit_ref2)
stargazer(fit_ref2, header=FALSE, type='text')
##
## =======================================================
## Dependent variable:
## -----------------------------
## 1 3 4
## (1) (2) (3)
## -------------------------------------------------------
## T0PDEMOMaxParentEducation -0.144 -0.063 -0.132*
## (0.090) (0.061) (0.073)
##
## as.factor(T0SGENGender)2 0.254 0.184 0.120
## (0.414) (0.276) (0.331)
##
## T0SY1Y2G_StartGrade -1.229*** -0.367*** -0.954***
## (0.214) (0.117) (0.156)
##
## T1LWIDWS.s -0.096 -0.112 -0.406**
## (0.215) (0.143) (0.177)
##
## Constant 0.988 0.305 1.358
## (1.386) (0.943) (1.119)
##
## -------------------------------------------------------
## Akaike Inf. Crit. 785.733 785.733 785.733
## =======================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
spatial_proportional_data_t1_spread_class$Class = relevel(spatial_proportional_data_t1_spread_class$Class, ref = "1")
fit_ref4 = multinom(Class ~ T0PDEMOMaxParentEducation
+ as.factor(T0SGENGender)
+ T0SY1Y2G_StartGrade
+ T1LWIDWS.s,
data = spatial_proportional_data_t1_spread_class)
## # weights: 24 (15 variable)
## initial value 512.928914
## iter 10 value 383.758159
## iter 20 value 377.866821
## final value 377.866256
## converged
# Print the model summary
#summary(fit_ref4)
stargazer(fit_ref4, header=FALSE, type='text')
##
## =======================================================
## Dependent variable:
## -----------------------------
## 2 3 4
## (1) (2) (3)
## -------------------------------------------------------
## T0PDEMOMaxParentEducation 0.144 0.081 0.012
## (0.090) (0.096) (0.098)
##
## as.factor(T0SGENGender)2 -0.254 -0.070 -0.134
## (0.414) (0.441) (0.453)
##
## T0SY1Y2G_StartGrade 1.229*** 0.862*** 0.275
## (0.214) (0.222) (0.231)
##
## T1LWIDWS.s 0.097 -0.015 -0.310
## (0.215) (0.230) (0.238)
##
## Constant -0.988 -0.684 0.370
## (1.386) (1.468) (1.481)
##
## -------------------------------------------------------
## Akaike Inf. Crit. 785.733 785.733 785.733
## =======================================================
## Note: *p<0.1; **p<0.05; ***p<0.01
spatial_proportional_data_ecs = spatial_proportional_data_t1_spread_class %>%
left_join(spatial_proportional_math_data[c("PRLSubjectID","T1EC.s","T2EC.s","T3EC.s","T4EC.s")],
by = "PRLSubjectID")
spatial_proportional_data_ecs2 = spatial_proportional_data_ecs[c("PRLSubjectID", "Class","T1EC.s","T2EC.s","T3EC.s","T4EC.s")]
spatial_proportional_data_ecs2_gather = gather(spatial_proportional_data_ecs2, "time","ec", -c(PRLSubjectID, Class))
spatial_proportional_data_ecs2_gather$time = as.numeric(as.factor(spatial_proportional_data_ecs2_gather$time))
spatial_proportional_data_ecs2_gather = spatial_proportional_data_ecs2_gather %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_Y1Grade","T0PDEMOMaxParentEducation",
"T0SGENGender","T0SAGE_T1S1Age")], by = "PRLSubjectID")
spatial_proportional_data_ecs2_gather$Class = factor(spatial_proportional_data_ecs2_gather$Class, levels = c("2","3","4","1"))
spatial_proportional_data_ecs2_gather$Class = relevel(spatial_proportional_data_ecs2_gather$Class, ref = "2")
nl_class_ecs_time <- lmer(ec ~ Class * time + T0SY1Y2G_Y1Grade+
(1 |PRLSubjectID) ,
data = spatial_proportional_data_ecs2_gather,
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_ecs_time)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ec ~ Class * time + T0SY1Y2G_Y1Grade + (1 | PRLSubjectID)
## Data: spatial_proportional_data_ecs2_gather
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 3555
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -5.5567 -0.4980 0.0358 0.5424 3.0660
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.5200 0.7211
## Residual 0.4427 0.6654
## Number of obs: 1405, groups: PRLSubjectID, 463
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.30659 0.08659 887.31847 3.541 0.00042 ***
## Class3 -0.21149 0.13759 1167.59220 -1.537 0.12453
## Class4 -0.69774 0.16377 1151.91477 -4.260 0.0000221 ***
## Class1 -0.55926 0.20905 1138.89922 -2.675 0.00757 **
## time -0.02188 0.02217 1013.52905 -0.987 0.32400
## T0SY1Y2G_Y1Grade -0.08138 0.03235 435.88897 -2.515 0.01226 *
## Class3:time -0.01575 0.04106 987.66475 -0.384 0.70135
## Class4:time 0.03055 0.05096 1009.60548 0.599 0.54899
## Class1:time 0.06767 0.06451 1036.12839 1.049 0.29448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Class3 Class4 Class1 time T0SY1Y Clss3: Clss4:
## Class3 -0.501
## Class4 -0.484 0.255
## Class1 -0.415 0.208 0.201
## time -0.576 0.366 0.306 0.239
## T0SY1Y2G_Y1 -0.557 0.120 0.215 0.231 -0.015
## Class3:time 0.317 -0.695 -0.167 -0.131 -0.540 -0.002
## Class4:time 0.250 -0.159 -0.682 -0.103 -0.435 0.009 0.235
## Class1:time 0.201 -0.127 -0.106 -0.686 -0.344 -0.001 0.185 0.149
Anova(nl_class_ecs_time, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: ec
## F Df Df.res Pr(>F)
## (Intercept) 12.5351 1 902.01 0.0004198 ***
## Class 7.2076 3 1169.33 0.00008552 ***
## time 0.9732 1 1026.10 0.3241145
## T0SY1Y2G_Y1Grade 6.3255 1 449.72 0.0122491 *
## Class:time 0.5965 3 1023.08 0.6173609
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(ggpredict(nl_class_ecs_time, terms=c("time","Class")))
emeans=emmeans(nl_class_ecs_time, pairwise ~ Class, mult.name = "Class")
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1641 0.0527 455 0.0605 0.2677 3.114 0.0020
## 3 -0.0844 0.0831 437 -0.2478 0.0790 -1.015 0.3105
## 4 -0.4619 0.1050 463 -0.6683 -0.2555 -4.397 <.0001
## 1 -0.2362 0.1398 464 -0.5109 0.0385 -1.690 0.0918
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.248 0.0989 443 0.0542 0.443 2.513 0.0123
## Class2 - Class4 0.626 0.1200 461 0.3901 0.862 5.215 <.0001
## Class2 - Class1 0.400 0.1524 462 0.1008 0.700 2.627 0.0089
## Class3 - Class4 0.377 0.1333 452 0.1154 0.639 2.831 0.0048
## Class3 - Class1 0.152 0.1619 456 -0.1663 0.470 0.938 0.3489
## Class4 - Class1 -0.226 0.1700 464 -0.5598 0.108 -1.327 0.1850
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
emeans=emmeans(nl_class_ecs_time, pairwise ~ Class|time|T0SY1Y2G_Y1Grade, mult.name = "Class", at=list(time=c(1,2,3,4)))
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## time = 1, T0SY1Y2G_Y1Grade = 1.12:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1936 0.0598 730 0.076245 0.3110 3.239 0.0013
## 3 -0.0336 0.0953 728 -0.220761 0.1535 -0.353 0.7243
## 4 -0.4736 0.1178 717 -0.704930 -0.2422 -4.019 0.0001
## 1 -0.2980 0.1578 718 -0.607854 0.0119 -1.888 0.0594
##
## time = 2, T0SY1Y2G_Y1Grade = 1.12:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1717 0.0530 470 0.067536 0.2759 3.239 0.0013
## 3 -0.0713 0.0840 458 -0.236336 0.0938 -0.848 0.3967
## 4 -0.4649 0.1050 467 -0.671328 -0.2585 -4.426 <.0001
## 1 -0.2522 0.1402 471 -0.527633 0.0233 -1.799 0.0726
##
## time = 3, T0SY1Y2G_Y1Grade = 1.12:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1499 0.0551 528 0.041668 0.2581 2.721 0.0067
## 3 -0.1089 0.0861 497 -0.278098 0.0603 -1.264 0.2067
## 4 -0.4562 0.1113 564 -0.674924 -0.2375 -4.098 <.0001
## 1 -0.2064 0.1474 557 -0.495957 0.0832 -1.400 0.1620
##
## time = 4, T0SY1Y2G_Y1Grade = 1.12:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1280 0.0651 881 0.000216 0.2558 1.966 0.0496
## 3 -0.1465 0.1008 837 -0.344441 0.0514 -1.453 0.1466
## 4 -0.4476 0.1341 966 -0.710635 -0.1845 -3.338 0.0009
## 1 -0.1606 0.1765 944 -0.507030 0.1858 -0.910 0.3631
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## time = 1, T0SY1Y2G_Y1Grade = 1.12:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.2272 0.1130 727 0.00548 0.449 2.012 0.0446
## Class2 - Class4 0.6672 0.1343 708 0.40353 0.931 4.968 <.0001
## Class2 - Class1 0.4916 0.1714 708 0.15511 0.828 2.868 0.0042
## Class3 - Class4 0.4399 0.1509 722 0.14362 0.736 2.915 0.0037
## Class3 - Class1 0.2644 0.1836 721 -0.09607 0.625 1.440 0.1503
## Class4 - Class1 -0.1756 0.1927 733 -0.55382 0.203 -0.911 0.3624
##
## time = 2, T0SY1Y2G_Y1Grade = 1.12:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.2430 0.0998 462 0.04687 0.439 2.435 0.0153
## Class2 - Class4 0.6366 0.1202 467 0.40051 0.873 5.298 <.0001
## Class2 - Class1 0.4239 0.1528 470 0.12358 0.724 2.774 0.0058
## Class3 - Class4 0.3936 0.1339 463 0.13058 0.657 2.941 0.0034
## Class3 - Class1 0.1809 0.1626 467 -0.13861 0.500 1.113 0.2664
## Class4 - Class1 -0.2127 0.1703 471 -0.54742 0.122 -1.249 0.2124
##
## time = 3, T0SY1Y2G_Y1Grade = 1.12:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.2587 0.1026 506 0.05709 0.460 2.521 0.0120
## Class2 - Class4 0.6061 0.1266 554 0.35731 0.855 4.786 <.0001
## Class2 - Class1 0.3563 0.1602 549 0.04148 0.671 2.223 0.0266
## Class3 - Class4 0.3473 0.1402 539 0.07190 0.623 2.477 0.0136
## Class3 - Class1 0.0975 0.1701 542 -0.23654 0.432 0.573 0.5666
## Class4 - Class1 -0.2498 0.1802 566 -0.60374 0.104 -1.386 0.1661
##
## time = 4, T0SY1Y2G_Y1Grade = 1.12:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.2745 0.1203 846 0.03829 0.511 2.281 0.0228
## Class2 - Class4 0.5755 0.1511 934 0.27896 0.872 3.808 0.0001
## Class2 - Class1 0.2886 0.1906 919 -0.08546 0.663 1.514 0.1303
## Class3 - Class4 0.3010 0.1674 922 -0.02740 0.629 1.799 0.0724
## Class3 - Class1 0.0141 0.2028 921 -0.38392 0.412 0.070 0.9446
## Class4 - Class1 -0.2869 0.2179 976 -0.71455 0.141 -1.317 0.1882
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
em=emtrends(nl_class_ecs_time, pairwise ~ Class, var="time", mult.name = "Class")
summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
## $emtrends
## Class time.trend SE df lower.CL upper.CL t.ratio p.value
## 2 -0.02188 0.0222 1026 -0.0654 0.0216 -0.987 0.3241
## 3 -0.03763 0.0346 990 -0.1055 0.0302 -1.088 0.2767
## 4 0.00867 0.0459 1021 -0.0814 0.0987 0.189 0.8501
## 1 0.04579 0.0606 1051 -0.0731 0.1647 0.756 0.4501
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.0158 0.0411 1001 -0.0899 0.1214 0.384 0.9808
## Class2 - Class4 -0.0306 0.0510 1022 -0.1617 0.1006 -0.599 0.9323
## Class2 - Class1 -0.0677 0.0645 1048 -0.2337 0.0984 -1.049 0.7208
## Class3 - Class4 -0.0463 0.0575 1010 -0.1942 0.1016 -0.806 0.8517
## Class3 - Class1 -0.0834 0.0698 1036 -0.2629 0.0961 -1.196 0.6298
## Class4 - Class1 -0.0371 0.0760 1040 -0.2327 0.1585 -0.488 0.9617
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: tukey method for comparing a family of 4 estimates
## P value adjustment: tukey method for comparing a family of 4 estimates
spatial_proportional_data_aswmac = spatial_proportional_data_t1_spread_class %>%
left_join(spatial_proportional_math_data[c("PRLSubjectID","T1ASWmac.s","T2ASWmac.s","T3ASWmac.s","T4ASWmac.s")],
by = "PRLSubjectID")
spatial_proportional_data_aswmac2 = spatial_proportional_data_aswmac[c("PRLSubjectID", "Class","T1ASWmac.s","T2ASWmac.s","T3ASWmac.s","T4ASWmac.s")]
spatial_proportional_data_aswmac2_gather = gather(spatial_proportional_data_aswmac2, "time","asw", -c(PRLSubjectID, Class))
spatial_proportional_data_aswmac2_gather$time = as.numeric(as.factor(spatial_proportional_data_aswmac2_gather$time))
table(spatial_proportional_data_aswmac2$T1ASWmac.s, spatial_proportional_data_aswmac2$Class)
##
## 1 2 3 4
## -2.7693154085149 0 0 1 0
## -2.76451051862549 0 1 0 0
## -2.33532100808011 0 2 0 0
## -2.21543827353739 0 0 0 1
## -2.18305608750086 0 1 0 0
## -2.12954968935934 0 0 0 3
## -1.87852624634236 1 0 0 1
## -1.86979069630665 0 4 0 0
## -1.83022119180049 0 2 0 0
## -1.73120154505634 0 0 2 2
## -1.65990159679139 0 1 0 0
## -1.4217314846046 1 3 0 0
## -1.42002834020252 1 0 4 1
## -1.3897602785109 0 0 1 0
## -1.36307652838799 0 5 1 1
## -1.33285340075333 1 0 1 1
## -1.25926798779375 0 2 1 1
## -1.20856059579365 0 0 0 1
## -1.17964257602141 1 0 0 0
## -1.1469576000786 0 0 1 0
## -1.12950419668174 0 1 1 0
## -0.970265984098398 0 8 0 4
## -0.964936722866849 1 8 2 3
## -0.934505256450334 2 4 1 7
## -0.906014218940669 0 1 0 0
## -0.895931864975495 0 5 1 0
## -0.859997660097611 0 1 0 0
## -0.781182844921938 0 0 3 1
## -0.721312849940049 0 1 2 0
## -0.700408570435923 0 2 0 0
## -0.62899205731121 0 1 0 1
## -0.558076444915087 0 0 1 0
## -0.545573367416119 0 1 0 0
## -0.536157112147333 1 3 3 2
## -0.520503627994272 1 5 3 1
## -0.508141961129095 5 5 0 2
## -0.479250234389765 0 0 1 0
## -0.442885566595133 0 1 0 0
## -0.428787201562992 0 6 0 2
## -0.392000097678806 0 1 0 0
## -0.30309770205012 3 2 0 3
## -0.234065104086442 0 2 1 0
## -0.220662057258186 0 1 0 0
## -0.137808967844333 1 6 4 2
## -0.0707412718901461 0 12 2 1
## -0.0513471993913407 0 11 3 0
## 0.0383574618495113 0 8 4 0
## 0.122014023583048 0 1 0 0
## 0.174987440821697 2 2 0 1
## 0.24328531837481 0 0 1 0
## 0.253182641767164 0 1 0 0
## 0.259084455919543 0 1 0 0
## 0.260539176458668 1 6 4 2
## 0.372032221429865 0 2 0 0
## 0.37902108421398 1 7 5 3
## 0.405447562346413 2 7 6 2
## 0.43125980973138 0 0 1 0
## 0.505502125262007 0 10 3 0
## 0.517409501476786 1 0 0 0
## 0.552661148947532 0 0 0 2
## 0.653072583693514 1 2 1 1
## 0.658887320761668 0 8 2 0
## 0.738830969097281 0 0 1 0
## 0.757041559407202 0 0 1 0
## 0.828783440318106 0 12 3 0
## 0.862242324084167 0 6 0 2
## 0.872544360800406 0 1 0 0
## 0.972646788674511 0 6 0 0
## 1.00279455846501 1 0 0 0
## 1.05723546506467 0 7 2 2
## 1.1000498786961 0 0 1 0
## 1.13115772656533 1 0 0 1
## 1.15004226610677 0 0 1 0
## 1.22767813347437 0 1 0 0
## 1.27854579642223 0 4 1 0
## 1.31903708582192 0 6 2 0
## 1.43979145208701 0 4 1 0
## 1.45558360936767 2 3 3 2
## 1.60924286943715 1 0 0 1
## 1.62451683957925 0 0 1 0
## 1.64531905849174 0 0 1 0
## 1.72830815252636 0 2 1 0
## 1.77583184755967 0 2 1 0
## 1.85393175367067 0 3 0 0
## 1.87356863954148 0 1 0 0
## 1.90693611549951 0 1 0 0
## 2.08732801230897 2 1 0 0
## 2.17807050863048 0 2 0 0
## 2.20217362518158 1 0 0 0
## 2.23262660929743 0 3 0 0
## 2.37408077891201 0 1 0 0
spatial_proportional_data_aswmac2_gather = spatial_proportional_data_aswmac2_gather %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_Y1Grade","T0PDEMOMaxParentEducation",
"T0SGENGender","T0SAGE_T1S1Age")], by = "PRLSubjectID")
spatial_proportional_data_aswmac2_gather$Class = factor(spatial_proportional_data_aswmac2_gather$Class, levels = c("2","3","4","1"))
spatial_proportional_data_aswmac2_gather$Class = relevel(spatial_proportional_data_aswmac2_gather$Class, ref = "2")
nl_class_asw_time <- lmer(asw ~ Class * time + T0SY1Y2G_Y1Grade +
(1 |PRLSubjectID) ,
data = spatial_proportional_data_aswmac2_gather,
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_asw_time)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: asw ~ Class * time + T0SY1Y2G_Y1Grade + (1 | PRLSubjectID)
## Data: spatial_proportional_data_aswmac2_gather
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 3907.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.62874 -0.62787 0.00426 0.63971 2.74193
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.2928 0.5411
## Residual 0.6806 0.8250
## Number of obs: 1426, groups: PRLSubjectID, 466
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.23120 0.08816 1210.28403 2.623 0.00884 **
## Class3 -0.17318 0.14752 1401.17046 -1.174 0.24062
## Class4 -0.73148 0.17607 1395.84049 -4.154 0.0000346 ***
## Class1 -0.16906 0.22138 1398.13941 -0.764 0.44518
## time -0.01909 0.02688 1097.01767 -0.710 0.47766
## T0SY1Y2G_Y1Grade -0.05884 0.02850 459.02827 -2.065 0.03951 *
## Class3:time 0.02089 0.05049 1076.52868 0.414 0.67916
## Class4:time 0.13139 0.06245 1118.62582 2.104 0.03561 *
## Class1:time -0.10124 0.08052 1172.53521 -1.257 0.20886
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Class3 Class4 Class1 time T0SY1Y Clss3: Clss4:
## Class3 -0.502
## Class4 -0.462 0.244
## Class1 -0.384 0.197 0.179
## time -0.705 0.424 0.354 0.281
## T0SY1Y2G_Y1 -0.483 0.092 0.161 0.163 -0.014
## Class3:time 0.377 -0.809 -0.189 -0.150 -0.532 0.004
## Class4:time 0.302 -0.182 -0.800 -0.121 -0.430 0.008 0.229
## Class1:time 0.230 -0.140 -0.116 -0.800 -0.334 0.017 0.178 0.144
Anova(nl_class_asw_time, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: asw
## F Df Df.res Pr(>F)
## (Intercept) 6.8760 1 1206.1 0.0088462 **
## Class 5.7606 3 1400.0 0.0006483 ***
## time 0.5042 1 1091.2 0.4777988
## T0SY1Y2G_Y1Grade 4.2618 1 451.8 0.0395497 *
## Class:time 2.3113 3 1117.7 0.0746393 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(ggpredict(nl_class_asw_time, terms=c("time","Class")))
emeans=emmeans(nl_class_asw_time, pairwise ~ Class|time, mult.name = "Class", at=list(time=c(1,2,3,4)))
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## time = 1:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.14234 0.0582 987 0.02807 0.25660 2.444 0.0147
## 3 -0.00996 0.0937 990 -0.19389 0.17398 -0.106 0.9154
## 4 -0.45776 0.1165 979 -0.68630 -0.22922 -3.931 0.0001
## 1 -0.12797 0.1519 996 -0.42608 0.17013 -0.842 0.3998
##
## time = 2:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.12324 0.0468 487 0.03127 0.21521 2.633 0.0087
## 3 -0.00816 0.0747 474 -0.15492 0.13859 -0.109 0.9130
## 4 -0.34547 0.0941 488 -0.53037 -0.16056 -3.671 0.0003
## 1 -0.24831 0.1232 502 -0.49036 -0.00626 -2.016 0.0444
##
## time = 3:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.10415 0.0494 557 0.00716 0.20113 2.109 0.0354
## 3 -0.00637 0.0776 524 -0.15887 0.14614 -0.082 0.9347
## 4 -0.23317 0.1025 611 -0.43450 -0.03185 -2.275 0.0233
## 1 -0.36865 0.1371 637 -0.63796 -0.09934 -2.688 0.0074
##
## time = 4:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.08505 0.0643 1094 -0.04106 0.21116 1.323 0.1860
## 3 -0.00457 0.1007 1073 -0.20207 0.19293 -0.045 0.9638
## 4 -0.12088 0.1361 1163 -0.38790 0.14613 -0.888 0.3746
## 1 -0.48899 0.1843 1162 -0.85061 -0.12736 -2.653 0.0081
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## time = 1:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.1523 0.1107 984 -0.0650 0.3696 1.375 0.1693
## Class2 - Class4 0.6001 0.1316 964 0.3419 0.8583 4.560 <.0001
## Class2 - Class1 0.2703 0.1643 979 -0.0521 0.5927 1.645 0.1002
## Class3 - Class4 0.4478 0.1489 991 0.1556 0.7400 3.008 0.0027
## Class3 - Class1 0.1180 0.1778 1002 -0.2309 0.4669 0.664 0.5070
## Class4 - Class1 -0.3298 0.1885 1018 -0.6996 0.0401 -1.750 0.0805
##
## time = 2:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.1314 0.0886 477 -0.0427 0.3055 1.483 0.1388
## Class2 - Class4 0.4687 0.1069 486 0.2587 0.6787 4.385 <.0001
## Class2 - Class1 0.3716 0.1339 498 0.1085 0.6346 2.775 0.0057
## Class3 - Class4 0.3373 0.1194 485 0.1027 0.5719 2.825 0.0049
## Class3 - Class1 0.2401 0.1432 496 -0.0412 0.5215 1.677 0.0941
## Class4 - Class1 -0.0972 0.1512 502 -0.3943 0.1999 -0.642 0.5209
##
## time = 3:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.1105 0.0925 532 -0.0711 0.2921 1.195 0.2325
## Class2 - Class4 0.3373 0.1155 595 0.1104 0.5642 2.920 0.0036
## Class2 - Class1 0.4728 0.1478 623 0.1825 0.7631 3.199 0.0015
## Class3 - Class4 0.2268 0.1279 581 -0.0245 0.4781 1.773 0.0768
## Class3 - Class1 0.3623 0.1568 611 0.0544 0.6702 2.311 0.0212
## Class4 - Class1 0.1355 0.1676 638 -0.1937 0.4647 0.808 0.4193
##
## time = 4:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.0896 0.1198 1073 -0.1454 0.3246 0.748 0.4544
## Class2 - Class4 0.2059 0.1519 1136 -0.0921 0.5039 1.356 0.1754
## Class2 - Class1 0.5740 0.1968 1143 0.1878 0.9602 2.916 0.0036
## Class3 - Class4 0.1163 0.1688 1138 -0.2149 0.4475 0.689 0.4909
## Class3 - Class1 0.4844 0.2094 1148 0.0736 0.8953 2.313 0.0209
## Class4 - Class1 0.3681 0.2263 1185 -0.0760 0.8122 1.626 0.1041
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
emeans=emmeans(nl_class_asw_time, pairwise ~ Class, mult.name = "Class")
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1162 0.0460 446 0.0259 0.2066 2.528 0.0118
## 3 -0.0075 0.0729 426 -0.1508 0.1358 -0.103 0.9181
## 4 -0.3043 0.0934 462 -0.4878 -0.1207 -3.258 0.0012
## 1 -0.2924 0.1232 479 -0.5345 -0.0504 -2.374 0.0180
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 0.1237 0.0867 431 -0.04664 0.294 1.427 0.1542
## Class2 - Class4 0.4205 0.1059 458 0.21232 0.629 3.969 0.0001
## Class2 - Class1 0.4087 0.1336 475 0.14610 0.671 3.058 0.0024
## Class3 - Class4 0.2968 0.1178 449 0.06533 0.528 2.520 0.0121
## Class3 - Class1 0.2849 0.1422 466 0.00543 0.564 2.003 0.0457
## Class4 - Class1 -0.0118 0.1507 476 -0.30795 0.284 -0.079 0.9374
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
em=emtrends(nl_class_asw_time, pairwise ~ Class, var="time", mult.name = "Class")
summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
## $emtrends
## Class time.trend SE df lower.CL upper.CL t.ratio p.value
## 2 -0.0191 0.0269 1091 -0.07186 0.0337 -0.710 0.4778
## 3 0.0018 0.0428 1062 -0.08210 0.0857 0.042 0.9665
## 4 0.1123 0.0564 1118 0.00165 0.2229 1.991 0.0467
## 1 -0.1203 0.0759 1177 -0.26932 0.0286 -1.585 0.1133
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class3 -0.0209 0.0505 1070 -0.1508 0.1091 -0.414 0.9761
## Class2 - Class4 -0.1314 0.0625 1113 -0.2921 0.0294 -2.103 0.1527
## Class2 - Class1 0.1012 0.0806 1168 -0.1060 0.3085 1.257 0.5907
## Class3 - Class4 -0.1105 0.0708 1098 -0.2926 0.0716 -1.561 0.4013
## Class3 - Class1 0.1221 0.0871 1150 -0.1021 0.3463 1.402 0.4986
## Class4 - Class1 0.2326 0.0946 1156 -0.0107 0.4760 2.460 0.0669
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: tukey method for comparing a family of 4 estimates
## P value adjustment: tukey method for comparing a family of 4 estimates
spatial_proportional_data_lwid = spatial_proportional_data_t1_spread_class %>%
left_join(spatial_proportional_math_data[c("PRLSubjectID","T2LWIDWS.s","T3LWIDWS.s","T4LWIDWS.s")],
by = "PRLSubjectID")
spatial_proportional_data_lwid2 = spatial_proportional_data_lwid[c("PRLSubjectID", "Class","T1LWIDWS.s","T2LWIDWS.s","T3LWIDWS.s","T4LWIDWS.s")]
spatial_proportional_data_lwid2_gather = gather(spatial_proportional_data_lwid2, "time","lwid", -c(PRLSubjectID, Class))
spatial_proportional_data_lwid2_gather$time = as.numeric(as.factor(spatial_proportional_data_lwid2_gather$time))
spatial_proportional_data_lwid2_gather = spatial_proportional_data_lwid2_gather %>%
left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_Y1Grade","T0PDEMOMaxParentEducation",
"T0SGENGender","T0SAGE_T1S1Age")], by = "PRLSubjectID")
spatial_proportional_data_lwid2_gather$Class = factor(spatial_proportional_data_lwid2_gather$Class, levels = c("2","3","4","1"))
spatial_proportional_data_lwid2_gather$Class = relevel(spatial_proportional_data_t1_spread_class$Class, ref = "2")
nl_class_lwid_time <- lmer(lwid ~ Class * time + T0SY1Y2G_Y1Grade +
(1 |PRLSubjectID) ,
data = spatial_proportional_data_lwid2_gather,
control = lmerControl(optimizer = "bobyqa"))
summary(nl_class_lwid_time)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: lwid ~ Class * time + T0SY1Y2G_Y1Grade + (1 | PRLSubjectID)
## Data: spatial_proportional_data_lwid2_gather
## Control: lmerControl(optimizer = "bobyqa")
##
## REML criterion at convergence: 2787.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.2946 -0.4828 -0.0037 0.5103 3.7676
##
## Random effects:
## Groups Name Variance Std.Dev.
## PRLSubjectID (Intercept) 0.8127 0.9015
## Residual 0.1671 0.4088
## Number of obs: 1425, groups: PRLSubjectID, 467
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 0.104481 0.085888 605.936661 1.216 0.22428
## Class1 -0.084049 0.190784 741.713391 -0.441 0.65967
## Class3 -0.003710 0.127071 719.510251 -0.029 0.97671
## Class4 -0.427450 0.151787 727.256754 -2.816 0.00499 **
## time 0.024338 0.013805 980.413407 1.763 0.07821 .
## T0SY1Y2G_Y1Grade -0.050397 0.036471 460.880754 -1.382 0.16769
## Class1:time -0.078766 0.040641 1002.678246 -1.938 0.05289 .
## Class3:time -0.051588 0.025539 973.507943 -2.020 0.04366 *
## Class4:time -0.001893 0.031995 988.100948 -0.059 0.95282
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Class1 Class3 Class4 time T0SY1Y Clss1: Clss3:
## Class1 -0.442
## Class3 -0.490 0.219
## Class4 -0.500 0.222 0.262
## time -0.368 0.166 0.249 0.208
## T0SY1Y2G_Y1 -0.642 0.277 0.144 0.261 -0.003
## Class1:time 0.127 -0.474 -0.085 -0.072 -0.340 -0.003
## Class3:time 0.202 -0.091 -0.467 -0.114 -0.541 -0.004 0.184
## Class4:time 0.162 -0.073 -0.108 -0.466 -0.431 -0.003 0.147 0.233
Anova(nl_class_lwid_time, test.statistic = 'F', type ="III")
## Analysis of Deviance Table (Type III Wald F tests with Kenward-Roger df)
##
## Response: lwid
## F Df Df.res Pr(>F)
## (Intercept) 1.4798 1 607.02 0.22428
## Class 2.8249 3 735.79 0.03788 *
## time 3.1077 1 981.35 0.07823 .
## T0SY1Y2G_Y1Grade 1.9094 1 461.85 0.16769
## Class:time 2.3269 3 989.29 0.07319 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(ggpredict(nl_class_lwid_time, terms=c("time","Class")))
emeans=emmeans(nl_class_lwid_time, pairwise ~ Class|time, mult.name = "Class", at=list(time=c(1,2,3,4)))
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## time = 1:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.0714 0.0619 546 -0.05026 0.1930 1.153 0.2495
## 1 -0.0914 0.1606 557 -0.40691 0.2240 -0.569 0.5694
## 3 0.0161 0.0990 541 -0.17847 0.2106 0.162 0.8710
## 4 -0.3580 0.1225 548 -0.59853 -0.1174 -2.923 0.0036
##
## time = 2:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.0957 0.0594 465 -0.02105 0.2125 1.611 0.1079
## 1 -0.1459 0.1540 473 -0.44837 0.1567 -0.947 0.3439
## 3 -0.0112 0.0951 461 -0.19802 0.1757 -0.117 0.9066
## 4 -0.3355 0.1177 469 -0.56677 -0.1043 -2.851 0.0046
##
## time = 3:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1201 0.0601 484 0.00202 0.2381 1.998 0.0462
## 1 -0.2003 0.1566 503 -0.50799 0.1074 -1.279 0.2015
## 3 -0.0384 0.0959 476 -0.22685 0.1500 -0.401 0.6889
## 4 -0.3131 0.1199 502 -0.54856 -0.0776 -2.612 0.0093
##
## time = 4:
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1444 0.0638 605 0.01914 0.2697 2.264 0.0239
## 1 -0.2547 0.1682 649 -0.58493 0.0755 -1.515 0.1303
## 3 -0.0657 0.1014 587 -0.26476 0.1334 -0.648 0.5174
## 4 -0.2906 0.1287 648 -0.54325 -0.0380 -2.259 0.0242
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## time = 1:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class1 0.1628 0.175 552 -0.1813 0.507 0.929 0.3531
## Class2 - Class3 0.0553 0.117 542 -0.1752 0.286 0.471 0.6376
## Class2 - Class4 0.4293 0.140 544 0.1548 0.704 3.072 0.0022
## Class1 - Class3 -0.1075 0.188 553 -0.4763 0.261 -0.573 0.5671
## Class1 - Class4 0.2665 0.197 559 -0.1203 0.653 1.353 0.1764
## Class3 - Class4 0.3740 0.157 546 0.0661 0.682 2.386 0.0174
##
## time = 2:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class1 0.2416 0.168 471 -0.0890 0.572 1.436 0.1516
## Class2 - Class3 0.1069 0.113 462 -0.1145 0.328 0.949 0.3433
## Class2 - Class4 0.4312 0.134 467 0.1670 0.695 3.207 0.0014
## Class1 - Class3 -0.1347 0.180 470 -0.4884 0.219 -0.748 0.4547
## Class1 - Class4 0.1897 0.189 472 -0.1808 0.560 1.006 0.3150
## Class3 - Class4 0.3244 0.151 466 0.0285 0.620 2.154 0.0317
##
## time = 3:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class1 0.3203 0.171 499 -0.0154 0.656 1.875 0.0614
## Class2 - Class3 0.1585 0.114 478 -0.0649 0.382 1.394 0.1639
## Class2 - Class4 0.4331 0.137 496 0.1646 0.702 3.169 0.0016
## Class1 - Class3 -0.1619 0.183 496 -0.5209 0.197 -0.886 0.3762
## Class1 - Class4 0.1128 0.192 505 -0.2647 0.490 0.587 0.5575
## Class3 - Class4 0.2747 0.153 492 -0.0256 0.575 1.798 0.0729
##
## time = 4:
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class1 0.3991 0.183 636 0.0402 0.758 2.184 0.0294
## Class2 - Class3 0.2101 0.120 590 -0.0261 0.446 1.747 0.0811
## Class2 - Class4 0.4350 0.146 631 0.1483 0.722 2.979 0.0030
## Class1 - Class3 -0.1891 0.196 634 -0.5731 0.195 -0.967 0.3340
## Class1 - Class4 0.0359 0.207 660 -0.3706 0.442 0.173 0.8624
## Class3 - Class4 0.2250 0.163 626 -0.0954 0.545 1.379 0.1684
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
emeans=emmeans(nl_class_lwid_time, pairwise ~ Class, mult.name = "Class")
summary(emeans, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## Class emmean SE df lower.CL upper.CL t.ratio p.value
## 2 0.1047 0.0593 460 -0.0118 0.221 1.766 0.0781
## 1 -0.1659 0.1538 471 -0.4682 0.136 -1.078 0.2814
## 3 -0.0212 0.0948 456 -0.2075 0.165 -0.224 0.8232
## 4 -0.3272 0.1177 468 -0.5585 -0.096 -2.781 0.0056
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class1 0.271 0.168 469 -0.0596 0.601 1.610 0.1080
## Class2 - Class3 0.126 0.112 457 -0.0949 0.347 1.120 0.2631
## Class2 - Class4 0.432 0.134 466 0.1678 0.696 3.214 0.0014
## Class1 - Class3 -0.145 0.180 467 -0.4980 0.209 -0.805 0.4213
## Class1 - Class4 0.161 0.188 471 -0.2090 0.532 0.856 0.3924
## Class3 - Class4 0.306 0.150 463 0.0105 0.602 2.035 0.0424
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
em=emtrends(nl_class_lwid_time, pairwise ~ Class, var="time", mult.name = "Class")
summary(em, infer=c(TRUE,TRUE), null=0, type = "response")
## $emtrends
## Class time.trend SE df lower.CL upper.CL t.ratio p.value
## 2 0.0243 0.0138 981 -0.00275 0.0514 1.763 0.0782
## 1 -0.0544 0.0382 1006 -0.12945 0.0206 -1.424 0.1549
## 3 -0.0272 0.0215 972 -0.06942 0.0149 -1.268 0.2051
## 4 0.0224 0.0289 991 -0.03420 0.0791 0.778 0.4370
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
##
## $contrasts
## contrast estimate SE df lower.CL upper.CL t.ratio p.value
## Class2 - Class1 0.07877 0.0406 1004 -0.0258 0.1834 1.938 0.2129
## Class2 - Class3 0.05159 0.0255 974 -0.0141 0.1173 2.020 0.1813
## Class2 - Class4 0.00189 0.0320 989 -0.0805 0.0842 0.059 0.9999
## Class1 - Class3 -0.02718 0.0439 998 -0.1400 0.0857 -0.620 0.9258
## Class1 - Class4 -0.07687 0.0479 1001 -0.2001 0.0464 -1.605 0.3764
## Class3 - Class4 -0.04969 0.0360 984 -0.1423 0.0429 -1.381 0.5116
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
## Conf-level adjustment: tukey method for comparing a family of 4 estimates
## P value adjustment: tukey method for comparing a family of 4 estimates
eucDist <- function(x, y) sqrt(sum( (x-y)^2))
prop_centers = spatial_proportional_data_t1_all_class %>%
aggregate(PRLCResp ~ Class * image, mean)
prop_centers$Class = factor(prop_centers$Class, levels = c("1","2","3","4"))
prop_centers_spread = spread(prop_centers, image, PRLCResp)
prop_centers_spread_names = prop_centers_spread
prop_centers_spread = prop_centers_spread[-1]
rownames(prop_centers_spread) <- prop_centers_spread_names[,1]
classifyNewSample <- function(newData, centroids =prop_centers_spread) {
dists = apply(centroids, 1, function(y) eucDist(y,newData))
order(dists)[1]
}
spatial_proportional_complete_t2 = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete, time == "t2")
spatial_proportional_complete_t2_spread =
spatial_proportional_complete_t2[c("PRLSubjectID","image","PRLCResp")]
spatial_proportional_complete_t2_spread = spread(spatial_proportional_complete_t2_spread, image, PRLCResp)
new_labels = apply(spatial_proportional_complete_t2_spread[c(2:16)], 1, classifyNewSample)
new_labels = as.data.frame(new_labels)
spatial_proportional_complete_t2_spread = cbind(spatial_proportional_complete_t2_spread, new_labels)
table(spatial_proportional_complete_t2_spread$new_labels)
##
## 1 2 3 4
## 33 294 101 49
spatial_proportional_complete_t2 = spatial_proportional_complete_t2 %>%
left_join(spatial_proportional_complete_t2_spread[c("PRLSubjectID","new_labels")])
t2_nl = distinct(spatial_proportional_complete_t2[c("PRLSubjectID","new_labels")])
table(t2_nl$new_labels)
##
## 1 2 3 4
## 33 294 101 49
spatial_proportional_complete_t3 = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete, time == "t3")
spatial_proportional_complete_t3_spread = spatial_proportional_complete_t3[c("PRLSubjectID","image","PRLCResp")]
spatial_proportional_complete_t3_spread = spread(spatial_proportional_complete_t3_spread, image, PRLCResp)
new_labels_t3 = apply(spatial_proportional_complete_t3_spread[c(2:16)], 1, classifyNewSample)
new_labels_t3 = as.data.frame(new_labels_t3)
spatial_proportional_complete_t3_spread = cbind(spatial_proportional_complete_t3_spread, new_labels_t3)
table(spatial_proportional_complete_t3_spread$new_labels_t3)
##
## 1 2 3 4
## 33 284 95 45
spatial_proportional_complete_t3 = spatial_proportional_complete_t3 %>%
left_join(spatial_proportional_complete_t3_spread[c("PRLSubjectID","new_labels_t3")])
t3_nl = distinct(spatial_proportional_complete_t3[c("PRLSubjectID","new_labels_t3")])
####
spatial_proportional_complete_t4 = subset(spatial_proportional_data_nona_importantcols_names_alltimes_no20_noshortrt_complete, time == "t4")
spatial_proportional_complete_t4_spread = spatial_proportional_complete_t4[c("PRLSubjectID","image","PRLCResp")]
spatial_proportional_complete_t4_spread = spread(spatial_proportional_complete_t4_spread, image, PRLCResp)
new_labels_t4 = apply(spatial_proportional_complete_t4_spread[c(2:16)], 1, classifyNewSample)
new_labels_t4 = as.data.frame(new_labels_t4)
spatial_proportional_complete_t4_spread = cbind(spatial_proportional_complete_t4_spread, new_labels_t4)
table(spatial_proportional_complete_t4_spread$new_labels_t4)
##
## 1 2 3 4
## 18 317 67 19
spatial_proportional_complete_t4 = spatial_proportional_complete_t4 %>%
left_join(spatial_proportional_complete_t4_spread[c("PRLSubjectID","new_labels_t4")])
t4_nl = distinct(spatial_proportional_complete_t4[c("PRLSubjectID","new_labels_t4")])
# t4_nl_grade = t4_nl %>%
# left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade","T0PDEMOMaxParentEducation",
# "T0SGENGender","T0SAGE_T1S1Age")], by = "PRLSubjectID")
# table(t4_nl_grade$new_labels_t4,t4_nl_grade$T0SY1Y2G_StartGrade)
# with(t4_nl_grade, table(new_labels_t4, T0SY1Y2G_StartGrade)) %>% prop.table(margin = 1)
#
# t1_nl_grade = spatial_proportional_data_t1_spread_class[c("PRLSubjectID","Class")] %>%
# left_join(spatial_demographics[c("PRLSubjectID","T0SY1Y2G_StartGrade","T0PDEMOMaxParentEducation",
# "T0SGENGender","T0SAGE_T1S1Age")], by = "PRLSubjectID")
# table(t1_nl_grade$Class,t1_nl_grade$T0SY1Y2G_StartGrade)
# with(t1_nl_grade, table(Class, T0SY1Y2G_StartGrade)) %>% prop.table(margin = 1)
tall_nl = spatial_proportional_data_t1_spread_class[c("PRLSubjectID","Class")]
tall_nl = tall_nl %>%
full_join(t2_nl[c("PRLSubjectID","new_labels")], by = "PRLSubjectID")
tall_nl = tall_nl %>%
full_join(t3_nl[c("PRLSubjectID","new_labels_t3")], by = "PRLSubjectID")
table(tall_nl$Class, tall_nl$new_labels)
##
## 1 2 3 4
## 1 4 13 8 7
## 2 8 178 28 7
## 3 7 37 35 8
## 4 4 26 13 15
table(tall_nl$new_labels, tall_nl$new_labels_t3)
##
## 1 2 3 4
## 1 3 8 6 6
## 2 10 173 26 15
## 3 7 34 32 6
## 4 3 17 6 9
tall_nl = tall_nl %>%
full_join(t4_nl[c("PRLSubjectID","new_labels_t4")], by = "PRLSubjectID")
## [1] "2" "3" "4" "1"
## [1] "2" "3" "4" "1"
## new_labels_t4
## Class D A B C
## B 0.06329114 0.68354430 0.21518987 0.03797468
## D 0.04347826 0.69565217 0.13043478 0.13043478
## C 0.02439024 0.68292683 0.21951220 0.07317073
## A 0.05376344 0.85483871 0.08064516 0.01075269
## new_labels Class Freq.x Freq.y Freq t1_class_prop p prop
## 1 2 2 178 221 221 0.55527638 0.000 0.805
## 2 3 2 28 221 87 0.21859296 0.001 0.127
## 3 4 2 7 221 58 0.14572864 0.000 0.032
## 4 1 2 8 221 32 0.08040201 0.022 0.036
## 5 2 3 37 87 221 0.55527638 0.020 0.425
## 6 3 3 35 87 87 0.21859296 0.000 0.402
## 7 4 3 8 87 58 0.14572864 0.204 0.092
## 8 1 3 7 87 32 0.08040201 1.000 0.080
## 9 2 4 26 58 221 0.55527638 0.132 0.448
## 10 3 4 13 58 87 0.21859296 1.000 0.224
## 11 4 4 15 58 58 0.14572864 0.024 0.259
## 12 1 4 4 58 32 0.08040201 0.937 0.069
## 13 2 1 13 32 221 0.55527638 0.129 0.406
## 14 3 1 8 32 87 0.21859296 0.829 0.250
## 15 4 1 7 32 58 0.14572864 0.357 0.219
## 16 1 1 4 32 32 0.08040201 0.547 0.125
## new_labels_t3 new_labels Freq.x Freq.y Freq t2_class_prop p prop
## 1 2 2 173 224 224 0.62049861 0.000 0.772
## 2 3 2 26 224 79 0.21883657 0.000 0.116
## 3 4 2 15 224 35 0.09695291 0.160 0.067
## 4 1 2 10 224 23 0.06371191 0.302 0.045
## 5 2 3 34 79 224 0.62049861 0.001 0.430
## 6 3 3 32 79 79 0.21883657 0.000 0.405
## 7 4 3 6 79 35 0.09695291 0.659 0.076
## 8 1 3 7 79 23 0.06371191 0.499 0.089
## 9 2 4 17 35 224 0.62049861 0.142 0.486
## 10 3 4 6 35 79 0.21883657 0.636 0.171
## 11 4 4 9 35 35 0.09695291 0.004 0.257
## 12 1 4 3 35 23 0.06371191 0.852 0.086
## 13 2 1 8 23 224 0.62049861 0.013 0.348
## 14 3 1 6 23 79 0.21883657 0.814 0.261
## 15 4 1 6 23 35 0.09695291 0.021 0.261
## 16 1 1 3 23 23 0.06371191 0.377 0.130
## Freq
## 1 0.64265928
## 2 0.19390582
## 3 0.09972299
## 4 0.06371191
## new_labels_t4 new_labels_t3 Freq.x Freq.y Freq t3_class_prop p prop
## 1 2 2 218 256 256 0.64646465 0.000 0.852
## 2 3 2 24 256 80 0.20202020 0.000 0.094
## 3 4 2 4 256 32 0.08080808 0.000 0.016
## 4 1 2 10 256 28 0.07070707 0.064 0.039
## 5 2 3 41 80 256 0.64646465 0.017 0.512
## 6 3 3 29 80 80 0.20202020 0.001 0.362
## 7 4 3 4 80 32 0.08080808 0.420 0.050
## 8 1 3 6 80 28 0.07070707 1.000 0.075
## 9 2 4 23 32 256 0.64646465 0.503 0.719
## 10 3 4 3 32 80 0.20202020 0.192 0.094
## 11 4 4 5 32 32 0.08080808 0.214 0.156
## 12 1 4 1 32 28 0.07070707 0.599 0.031
## 13 2 1 16 28 256 0.64646465 0.527 0.571
## 14 3 1 7 28 80 0.20202020 0.691 0.250
## 15 4 1 4 28 32 0.08080808 0.391 0.143
## 16 1 1 1 28 28 0.07070707 0.724 0.036
## Freq
## 1 0.75252525
## 2 0.15909091
## 3 0.04292929
## 4 0.04545455
## [1] "1" "2" "3" "4"
## [1] "1" "2" "3" "4"
## new_labels
## Class 1 2 3 4
## 1 0.12500000 0.40625000 0.25000000 0.21875000
## 2 0.03619910 0.80542986 0.12669683 0.03167421
## 3 0.08045977 0.42528736 0.40229885 0.09195402
## 4 0.06896552 0.44827586 0.22413793 0.25862069
## new_labels_t3
## new_labels 1 2 3 4
## 1 0.13043478 0.34782609 0.26086957 0.26086957
## 2 0.04464286 0.77232143 0.11607143 0.06696429
## 3 0.08860759 0.43037975 0.40506329 0.07594937
## 4 0.08571429 0.48571429 0.17142857 0.25714286
## new_labels_t4
## new_labels_t3 1 2 3 4
## 1 0.03571429 0.57142857 0.25000000 0.14285714
## 2 0.03906250 0.85156250 0.09375000 0.01562500
## 3 0.07500000 0.51250000 0.36250000 0.05000000
## 4 0.03125000 0.71875000 0.09375000 0.15625000