1. Notes

NOTE TO SELF: Hilary don’t forget that warnings and messages are turned off.

This document conducts the interrupted time series analysis for TSTM data to be included in the report of post-hoc analyses. Analyses are based on descriptions in this walk-thru of ITA from ASU. Note, figure 1.8 on that webpage demonstrates the effect and subsequent equation we hypothesize for TSTM.

We will be specifically testing for an ‘immediate effect’ post-cue within switch blocks only, such that the starting point of performance trajectory is either notable below or above the project trajectory of performance prior to cue introduction. This comprises an effect of \(b_2\) in the following simplified equation:

\[Y = b_0 + b_1T + b_2D + e\]

It is also likely we’ll see evidence for an ‘immediate’ as well as a ‘sustained’ effect of cue introduction, in which the start point differs as well as the subsequent slope. This could comprise effects of both \(b_2\) and \(b_3\) in the following equation:

\[ Y = b_0 + b_1T + b_2D + b_3P + e\]

2. Documents & Dataframes

A ITA specific dataframe will be created including:

  • Y = Outcome variable (bin)
  • T = Time since start of task (1-32)
  • D = Dummy var indicating if observation is before or after treatment (0/1)
  • P = Time since intervention (i.e. cued trials) (0-16)

Our data set will also include a variable for age group.

## `summarise()` regrouping output by 'partID', 'trial', 'pondnum', 'strategy' (override with `.groups` argument)

Initial dataframe from prior analyses.

summary(tstm_measures)
##      partID         trial         strategy       cue             P1       
##  Min.   :3001   Min.   : 3.00   maint :1504   False:1541   Min.   :0.000  
##  1st Qu.:3025   1st Qu.:10.00   prac  :   0   True :1510   1st Qu.:4.000  
##  Median :3070   Median :18.00   switch:1547                Median :5.000  
##  Mean   :3064   Mean   :18.34                              Mean   :4.054  
##  3rd Qu.:3096   3rd Qu.:26.00                              3rd Qu.:5.000  
##  Max.   :3121   Max.   :34.00                              Max.   :5.000  
##        P2             all         age_grp       bin               id       
##  Min.   :0.000   Min.   : 0.000   a:1024   Min.   :0.0000   Min.   :1.000  
##  1st Qu.:5.000   1st Qu.: 6.000   s:1014   1st Qu.:0.0000   1st Qu.:2.000  
##  Median :5.000   Median :10.000   t:1013   Median :1.0000   Median :4.000  
##  Mean   :4.114   Mean   : 8.168            Mean   :0.5618   Mean   :4.492  
##  3rd Qu.:5.000   3rd Qu.:10.000            3rd Qu.:1.0000   3rd Qu.:6.000  
##  Max.   :5.000   Max.   :10.000            Max.   :1.0000   Max.   :8.000

Creation of new ITA dataframe.

tstm_ita <- tstm_measures                                 #copy orig. df
tstm_ita <- tstm_ita %>%                                  #create Time since start of task var
  group_by(partID) %>% 
  mutate(T = row_number())
tstm_ita$D <- if_else(tstm_measures$cue == 'True', 1, 0)  #create Dummy var
tstm_ita$P <- tstm_ita$id                                 #create time since intervention
tstm_ita$P[tstm_ita$D == 0] <- 0
tstm_ita <- tstm_ita[tstm_ita$strategy == "switch", c(1,9,11:13,8,3)]; str(tstm_ita)
## tibble [1,547 × 7] (S3: grouped_df/tbl_df/tbl/data.frame)
##  $ partID  : int [1:1547] 3001 3001 3001 3001 3001 3001 3001 3001 3001 3001 ...
##  $ bin     : int [1:1547] 0 0 0 0 0 0 1 1 1 1 ...
##  $ T       : int [1:1547] 1 2 3 4 5 6 7 8 9 10 ...
##  $ D       : num [1:1547] 0 0 0 0 0 0 0 0 1 1 ...
##  $ P       : num [1:1547] 0 0 0 0 0 0 0 0 1 2 ...
##  $ age_grp : Factor w/ 3 levels "a","s","t": 1 1 1 1 1 1 1 1 1 1 ...
##  $ strategy: Factor w/ 3 levels "maint","prac",..: 3 3 3 3 3 3 3 3 3 3 ...
##  - attr(*, "groups")= tibble [100 × 2] (S3: tbl_df/tbl/data.frame)
##   ..$ partID: int [1:100] 3001 3002 3003 3004 3005 3007 3008 3009 3010 3011 ...
##   ..$ .rows : list<int> [1:100] 
##   .. ..$ : int [1:16] 1 2 3 4 5 6 7 8 9 10 ...
##   .. ..$ : int [1:16] 17 18 19 20 21 22 23 24 25 26 ...
##   .. ..$ : int [1:16] 33 34 35 36 37 38 39 40 41 42 ...
##   .. ..$ : int [1:16] 49 50 51 52 53 54 55 56 57 58 ...
##   .. ..$ : int [1:16] 65 66 67 68 69 70 71 72 73 74 ...
##   .. ..$ : int [1:16] 81 82 83 84 85 86 87 88 89 90 ...
##   .. ..$ : int [1:16] 97 98 99 100 101 102 103 104 105 106 ...
##   .. ..$ : int [1:16] 113 114 115 116 117 118 119 120 121 122 ...
##   .. ..$ : int [1:16] 129 130 131 132 133 134 135 136 137 138 ...
##   .. ..$ : int [1:16] 145 146 147 148 149 150 151 152 153 154 ...
##   .. ..$ : int [1:16] 161 162 163 164 165 166 167 168 169 170 ...
##   .. ..$ : int [1:16] 177 178 179 180 181 182 183 184 185 186 ...
##   .. ..$ : int [1:16] 193 194 195 196 197 198 199 200 201 202 ...
##   .. ..$ : int [1:16] 209 210 211 212 213 214 215 216 217 218 ...
##   .. ..$ : int [1:16] 225 226 227 228 229 230 231 232 233 234 ...
##   .. ..$ : int [1:16] 241 242 243 244 245 246 247 248 249 250 ...
##   .. ..$ : int [1:16] 257 258 259 260 261 262 263 264 265 266 ...
##   .. ..$ : int [1:16] 273 274 275 276 277 278 279 280 281 282 ...
##   .. ..$ : int [1:16] 289 290 291 292 293 294 295 296 297 298 ...
##   .. ..$ : int [1:16] 305 306 307 308 309 310 311 312 313 314 ...
##   .. ..$ : int [1:16] 321 322 323 324 325 326 327 328 329 330 ...
##   .. ..$ : int [1:16] 337 338 339 340 341 342 343 344 345 346 ...
##   .. ..$ : int [1:16] 353 354 355 356 357 358 359 360 361 362 ...
##   .. ..$ : int [1:16] 369 370 371 372 373 374 375 376 377 378 ...
##   .. ..$ : int [1:16] 385 386 387 388 389 390 391 392 393 394 ...
##   .. ..$ : int [1:16] 401 402 403 404 405 406 407 408 409 410 ...
##   .. ..$ : int [1:16] 417 418 419 420 421 422 423 424 425 426 ...
##   .. ..$ : int [1:16] 433 434 435 436 437 438 439 440 441 442 ...
##   .. ..$ : int [1:16] 449 450 451 452 453 454 455 456 457 458 ...
##   .. ..$ : int [1:16] 465 466 467 468 469 470 471 472 473 474 ...
##   .. ..$ : int [1:16] 481 482 483 484 485 486 487 488 489 490 ...
##   .. ..$ : int [1:16] 497 498 499 500 501 502 503 504 505 506 ...
##   .. ..$ : int [1:16] 513 514 515 516 517 518 519 520 521 522 ...
##   .. ..$ : int [1:16] 529 530 531 532 533 534 535 536 537 538 ...
##   .. ..$ : int [1:16] 545 546 547 548 549 550 551 552 553 554 ...
##   .. ..$ : int [1:16] 561 562 563 564 565 566 567 568 569 570 ...
##   .. ..$ : int [1:16] 577 578 579 580 581 582 583 584 585 586 ...
##   .. ..$ : int [1:16] 593 594 595 596 597 598 599 600 601 602 ...
##   .. ..$ : int [1:16] 609 610 611 612 613 614 615 616 617 618 ...
##   .. ..$ : int [1:16] 625 626 627 628 629 630 631 632 633 634 ...
##   .. ..$ : int [1:16] 641 642 643 644 645 646 647 648 649 650 ...
##   .. ..$ : int [1:16] 657 658 659 660 661 662 663 664 665 666 ...
##   .. ..$ : int [1:16] 673 674 675 676 677 678 679 680 681 682 ...
##   .. ..$ : int [1:8] 689 690 691 692 693 694 695 696
##   .. ..$ : int [1:16] 697 698 699 700 701 702 703 704 705 706 ...
##   .. ..$ : int [1:16] 713 714 715 716 717 718 719 720 721 722 ...
##   .. ..$ : int [1:16] 729 730 731 732 733 734 735 736 737 738 ...
##   .. ..$ : int [1:16] 745 746 747 748 749 750 751 752 753 754 ...
##   .. ..$ : int [1:9] 761 762 763 764 765 766 767 768 769
##   .. ..$ : int [1:2] 770 771
##   .. ..$ : int [1:16] 772 773 774 775 776 777 778 779 780 781 ...
##   .. ..$ : int [1:16] 788 789 790 791 792 793 794 795 796 797 ...
##   .. ..$ : int [1:16] 804 805 806 807 808 809 810 811 812 813 ...
##   .. ..$ : int [1:16] 820 821 822 823 824 825 826 827 828 829 ...
##   .. ..$ : int [1:16] 836 837 838 839 840 841 842 843 844 845 ...
##   .. ..$ : int [1:3] 852 853 854
##   .. ..$ : int [1:16] 855 856 857 858 859 860 861 862 863 864 ...
##   .. ..$ : int [1:16] 871 872 873 874 875 876 877 878 879 880 ...
##   .. ..$ : int [1:16] 887 888 889 890 891 892 893 894 895 896 ...
##   .. ..$ : int [1:16] 903 904 905 906 907 908 909 910 911 912 ...
##   .. ..$ : int [1:16] 919 920 921 922 923 924 925 926 927 928 ...
##   .. ..$ : int [1:16] 935 936 937 938 939 940 941 942 943 944 ...
##   .. ..$ : int [1:16] 951 952 953 954 955 956 957 958 959 960 ...
##   .. ..$ : int [1:16] 967 968 969 970 971 972 973 974 975 976 ...
##   .. ..$ : int [1:16] 983 984 985 986 987 988 989 990 991 992 ...
##   .. ..$ : int [1:16] 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 ...
##   .. ..$ : int [1:16] 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 ...
##   .. ..$ : int [1:16] 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 ...
##   .. ..$ : int [1:16] 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 ...
##   .. ..$ : int [1:16] 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 ...
##   .. ..$ : int [1:16] 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 ...
##   .. ..$ : int [1:16] 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 ...
##   .. ..$ : int [1:16] 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 ...
##   .. ..$ : int [1:16] 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 ...
##   .. ..$ : int [1:16] 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 ...
##   .. ..$ : int [1:16] 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 ...
##   .. ..$ : int [1:16] 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 ...
##   .. ..$ : int [1:16] 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 ...
##   .. ..$ : int [1:16] 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 ...
##   .. ..$ : int [1:16] 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 ...
##   .. ..$ : int [1:16] 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 ...
##   .. ..$ : int [1:16] 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 ...
##   .. ..$ : int [1:16] 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 ...
##   .. ..$ : int [1:16] 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 ...
##   .. ..$ : int [1:16] 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 ...
##   .. ..$ : int [1:16] 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 ...
##   .. ..$ : int [1:16] 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 ...
##   .. ..$ : int [1:16] 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 ...
##   .. ..$ : int [1:16] 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 ...
##   .. ..$ : int [1:16] 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 ...
##   .. ..$ : int [1:16] 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 ...
##   .. ..$ : int [1:16] 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 ...
##   .. ..$ : int [1:16] 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 ...
##   .. ..$ : int [1:16] 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 ...
##   .. ..$ : int [1:16] 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 ...
##   .. ..$ : int [1:8] 1479 1480 1481 1482 1483 1484 1485 1486
##   .. ..$ : int [1:16] 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 ...
##   .. ..$ : int [1:16] 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 ...
##   .. ..$ : int [1:16] 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 ...
##   .. .. [list output truncated]
##   .. ..@ ptype: int(0) 
##   ..- attr(*, ".drop")= logi TRUE
summary(tstm_ita)
##      partID          bin               T                D       
##  Min.   :3001   Min.   :0.0000   Min.   : 1.000   Min.   :0.00  
##  1st Qu.:3026   1st Qu.:0.0000   1st Qu.: 4.000   1st Qu.:0.00  
##  Median :3070   Median :0.0000   Median : 8.000   Median :0.00  
##  Mean   :3064   Mean   :0.4447   Mean   : 8.404   Mean   :0.49  
##  3rd Qu.:3097   3rd Qu.:1.0000   3rd Qu.:12.000   3rd Qu.:1.00  
##  Max.   :3121   Max.   :1.0000   Max.   :16.000   Max.   :1.00  
##        P         age_grp   strategy   
##  Min.   :0.000   a:512   maint :   0  
##  1st Qu.:0.000   s:518   prac  :   0  
##  Median :0.000   t:517   switch:1547  
##  Mean   :2.198                        
##  3rd Qu.:4.000                        
##  Max.   :8.000

This dataframe now contains all vars necessary for ITA using a standard regression approach.

3. ITA Model Build

3.1 Null Model

Null model converges.

ita_null <- glm(bin ~ T + D + P, family = binomial(link = "logit"), data = tstm_ita)
ita_null
## 
## Call:  glm(formula = bin ~ T + D + P, family = binomial(link = "logit"), 
##     data = tstm_ita)
## 
## Coefficients:
## (Intercept)            T            D            P  
##     -2.6404       0.3642      -0.1247      -0.3064  
## 
## Degrees of Freedom: 1546 Total (i.e. Null);  1543 Residual
## Null Deviance:       2126 
## Residual Deviance: 1876  AIC: 1884

Main effects of T and P are evident - but not D.

summary(ita_null)
## 
## Call:
## glm(formula = bin ~ T + D + P, family = binomial(link = "logit"), 
##     data = tstm_ita)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.4457  -1.1392  -0.4421   1.0439   2.1789  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -2.64037    0.22195 -11.896  < 2e-16 ***
## T            0.36425    0.03947   9.229  < 2e-16 ***
## D           -0.12470    0.21265  -0.586    0.558    
## P           -0.30641    0.05112  -5.994 2.05e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 2125.7  on 1546  degrees of freedom
## Residual deviance: 1875.7  on 1543  degrees of freedom
## AIC: 1883.7
## 
## Number of Fisher Scoring iterations: 4

3.2 Model with Age

ita_age <- glm(bin ~ T*age_grp + D*age_grp + P*age_grp, family = binomial(link = "logit"), data = tstm_ita)
summary(ita_age)
## 
## Call:
## glm(formula = bin ~ T * age_grp + D * age_grp + P * age_grp, 
##     family = binomial(link = "logit"), data = tstm_ita)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2774  -0.7188  -0.2242   0.7865   2.8646  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -2.61765    0.37121  -7.052 1.77e-12 ***
## T            0.50377    0.07107   7.088 1.36e-12 ***
## age_grps    -2.29927    0.94747  -2.427  0.01523 *  
## age_grpt     0.46394    0.50246   0.923  0.35583    
## D           -0.54870    0.44157  -1.243  0.21401    
## P           -0.29730    0.10728  -2.771  0.00558 ** 
## T:age_grps  -0.08850    0.15337  -0.577  0.56393    
## T:age_grpt  -0.13323    0.09541  -1.396  0.16260    
## age_grps:D   0.75181    0.66366   1.133  0.25729    
## age_grpt:D   0.47399    0.58688   0.808  0.41930    
## age_grps:P  -0.08395    0.18536  -0.453  0.65064    
## age_grpt:P  -0.02672    0.13903  -0.192  0.84758    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 2125.7  on 1546  degrees of freedom
## Residual deviance: 1492.7  on 1535  degrees of freedom
## AIC: 1516.7
## 
## Number of Fisher Scoring iterations: 6

Main effects of T and P are evident - but not D.

car::Anova(ita_age)
## Registered S3 methods overwritten by 'car':
##   method                          from
##   influence.merMod                lme4
##   cooks.distance.influence.merMod lme4
##   dfbeta.influence.merMod         lme4
##   dfbetas.influence.merMod        lme4
## Analysis of Deviance Table (Type II tests)
## 
## Response: bin
##           LR Chisq Df Pr(>Chisq)    
## T           113.77  1  < 2.2e-16 ***
## age_grp     373.53  2  < 2.2e-16 ***
## D             0.38  1     0.5401    
## P            28.40  1  9.867e-08 ***
## T:age_grp     1.98  2     0.3712    
## age_grp:D     1.36  2     0.5068    
## age_grp:P     0.21  2     0.9010    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

3.3 MLM Build

Same song, but with structured data!

ita_age_mlm <- lme4::glmer(bin ~ T*age_grp + D*age_grp + P*age_grp + (1|partID), 
                           family = binomial(link = "logit"), 
                           control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=1000000)),
                           data = tstm_ita)
summary(ita_age_mlm)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: bin ~ T * age_grp + D * age_grp + P * age_grp + (1 | partID)
##    Data: tstm_ita
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+06))
## 
##      AIC      BIC   logLik deviance df.resid 
##   1283.0   1352.4   -628.5   1257.0     1534 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -10.0373  -0.3453  -0.0707   0.4162  12.5616 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  partID (Intercept) 3.062    1.75    
## Number of obs: 1547, groups:  partID, 100
## 
## Fixed effects:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -3.903760   0.576109  -6.776 1.23e-11 ***
## T            0.745716   0.094387   7.901 2.78e-15 ***
## age_grps    -2.702743   1.169779  -2.310 0.020862 *  
## age_grpt     0.968063   0.759608   1.274 0.202513    
## D           -0.749508   0.540013  -1.388 0.165153    
## P           -0.447865   0.133221  -3.362 0.000774 ***
## T:age_grps  -0.251001   0.178282  -1.408 0.159165    
## T:age_grpt  -0.251523   0.119960  -2.097 0.036018 *  
## age_grps:D   1.123885   0.803833   1.398 0.162066    
## age_grpt:D   0.705448   0.708532   0.996 0.319421    
## age_grps:P   0.013517   0.217423   0.062 0.950429    
## age_grpt:P  -0.003891   0.169078  -0.023 0.981638    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr) T      ag_grps ag_grpt D      P      T:g_grps T:g_grpt
## T          -0.785                                                       
## age_grps   -0.464  0.354                                                
## age_grpt   -0.746  0.581  0.356                                         
## D           0.280 -0.485 -0.132  -0.210                                 
## P           0.522 -0.675 -0.243  -0.390  -0.159                         
## T:age_grps  0.410 -0.522 -0.855  -0.305   0.256  0.354                  
## T:age_grpt  0.607 -0.774 -0.282  -0.756   0.380  0.526  0.406           
## age_grps:D -0.191  0.330  0.286   0.142  -0.672  0.105 -0.494   -0.257  
## age_grpt:D -0.213  0.370  0.101   0.268  -0.762  0.121 -0.195   -0.494  
## age_grps:P -0.317  0.410  0.692   0.238   0.098 -0.611 -0.810   -0.320  
## age_grpt:P -0.404  0.523  0.194   0.519   0.127 -0.784 -0.276   -0.691  
##            ag_grps:D ag_grpt:D ag_grps:P
## T                                       
## age_grps                                
## age_grpt                                
## D                                       
## P                                       
## T:age_grps                              
## T:age_grpt                              
## age_grps:D                              
## age_grpt:D  0.513                       
## age_grps:P  0.027    -0.075             
## age_grpt:P -0.085    -0.145     0.480

No evidence for immediate effect.

car::Anova(ita_age_mlm)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: bin
##              Chisq Df Pr(>Chisq)    
## T         108.0006  1  < 2.2e-16 ***
## age_grp    63.3900  2  1.718e-14 ***
## D           0.2696  1    0.60358    
## P          35.9406  1  2.034e-09 ***
## T:age_grp   4.7667  2    0.09224 .  
## age_grp:D   2.0604  2    0.35693    
## age_grp:P   0.0075  2    0.99626    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

3.4 7yos Only

ita_7yo <- glm(bin ~ T + D + P, 
               family = binomial(link = "logit"), 
               data = tstm_ita[tstm_ita$age_grp=="s",])
ita_7yo
## 
## Call:  glm(formula = bin ~ T + D + P, family = binomial(link = "logit"), 
##     data = tstm_ita[tstm_ita$age_grp == "s", ])
## 
## Coefficients:
## (Intercept)            T            D            P  
##     -4.9169       0.4153       0.2031      -0.3812  
## 
## Degrees of Freedom: 517 Total (i.e. Null);  514 Residual
## Null Deviance:       421.3 
## Residual Deviance: 380.3     AIC: 388.3
summary(ita_7yo)
## 
## Call:
## glm(formula = bin ~ T + D + P, family = binomial(link = "logit"), 
##     data = tstm_ita[tstm_ita$age_grp == "s", ])
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -0.7517  -0.6975  -0.4117  -0.1825   2.8646  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  -4.9169     0.8717  -5.640  1.7e-08 ***
## T             0.4153     0.1359   3.055  0.00225 ** 
## D             0.2031     0.4954   0.410  0.68185    
## P            -0.3812     0.1512  -2.522  0.01167 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 421.28  on 517  degrees of freedom
## Residual deviance: 380.30  on 514  degrees of freedom
## AIC: 388.3
## 
## Number of Fisher Scoring iterations: 6

No evidence for immediate effect.

car::Anova(ita_7yo)
## Analysis of Deviance Table (Type II tests)
## 
## Response: bin
##   LR Chisq Df Pr(>Chisq)    
## T  11.6778  1  0.0006325 ***
## D   0.1688  1  0.6811402    
## P   7.2734  1  0.0069983 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1