dsM <- dplyr::filter(dsL, id <= 300) %>%
dplyr::filter(ave((!is.na(attend)), id, FUN = all)) %>%
dplyr::mutate(time=year-2000) %>%
dplyr::select(id, time, attend)
modelA <- nlme::gls(attend ~ 1 , data=dsM)
modelB <- nlme::gls(attend ~ 1 + time, data=dsM)
dsM$modelA <- predict(modelA)
dsM$modelB <- predict(modelB)
dplyr::filter(dsM,id==1)
id time attend modelA modelB
1 1 0 1 2.477 2.788
2 1 1 6 2.477 2.732
3 1 2 2 2.477 2.675
4 1 3 1 2.477 2.618
5 1 4 1 2.477 2.562
6 1 5 1 2.477 2.505
7 1 6 1 2.477 2.449
8 1 7 1 2.477 2.392
9 1 8 1 2.477 2.335
10 1 9 1 2.477 2.279
11 1 10 1 2.477 2.222
12 1 11 1 2.477 2.166
modelB
Generalized least squares fit by REML
Model: attend ~ 1 + time
Data: dsM
Log-restricted-likelihood: -3719
Coefficients:
(Intercept) time
2.7882 -0.0566
Degrees of freedom: 1860 total; 1858 residual
Residual standard error: 1.782
\({y_{it}} = {\beta _0} + {\beta _1}tim{e_t} + {\varepsilon _{it}}\)