vignettes/session_lecture.Rmd
session_lecture.Rmd
Where we assume: \(SUBJECT_i \stackrel{iid}{\sim} N(0, \tau_{00}^2)\)
## Linear mixed-effects model fit by REML
## Data: dat
## Log-restricted-likelihood: -84.55594
## Fixed: fecfat ~ pilltype
## (Intercept) pilltypetablet pilltypecapsule pilltypecoated
## 38.083334 -21.550001 -20.666667 -7.016668
##
## Random effects:
## Formula: ~1 | subject
## (Intercept) Residual
## StdDev: 15.89557 10.34403
##
## Number of Observations: 24
## Number of Groups: 6
\(ICC = 15.9^2 / (15.9^2 + 10.34^2)\) = 0.7 = 0.7.
\[ FECFAT_{ij} = \beta_0 + SUBJECT_i + \beta_{pilltype j} PILLTYPE_j + \epsilon_{ij} \]
## Linear mixed-effects model fit by REML
## Data: dat
## AIC BIC logLik
## 181.1119 187.0863 -84.55594
##
## Random effects:
## Formula: ~1 | subject
## (Intercept) Residual
## StdDev: 15.89557 10.34403
##
## Fixed effects: fecfat ~ pilltype
## Value Std.Error DF t-value p-value
## (Intercept) 38.08333 7.742396 15 4.918805 0.0002
## pilltypetablet -21.55000 5.972127 15 -3.608430 0.0026
## pilltypecapsule -20.66667 5.972127 15 -3.460521 0.0035
## pilltypecoated -7.01667 5.972127 15 -1.174903 0.2583
## Correlation:
## (Intr) plltypt plltypcp
## pilltypetablet -0.386
## pilltypecapsule -0.386 0.500
## pilltypecoated -0.386 0.500 0.500
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -1.210052934 -0.615068039 -0.002727166 0.457105344 1.725618643
##
## Number of Observations: 24
## Number of Groups: 6
Inference for variance terms (and fixed effects):
## Approximate 95% confidence intervals
##
## Fixed effects:
## lower est. upper
## (Intercept) 21.58081 38.083334 54.585860
## pilltypetablet -34.27929 -21.550001 -8.820714
## pilltypecapsule -33.39595 -20.666667 -7.937381
## pilltypecoated -19.74595 -7.016668 5.712618
##
## Random Effects:
## Level: subject
## lower est. upper
## sd((Intercept)) 8.00117 15.89557 31.57904
##
## Within-group standard error:
## lower est. upper
## 7.23240 10.34403 14.79438
Note: there are not enough degrees of freedom to also fit a random coefficient for birth order
summary(gafit1)
## Linear mixed-effects model fit by REML
## Data: ga
## AIC BIC logLik
## 15321.65 15341.28 -7656.826
##
## Random effects:
## Formula: ~1 | momid
## (Intercept) Residual
## StdDev: 367.2676 445.0228
##
## Fixed effects: bweight ~ birthord
## Value Std.Error DF t-value p-value
## (Intercept) 2995.640 41.99615 799 71.33130 0
## birthord 46.608 9.95101 799 4.68374 0
## Correlation:
## (Intr)
## birthord -0.711
##
## Standardized Within-Group Residuals:
## Min Q1 Med Q3 Max
## -5.26801358 -0.43683345 0.05028638 0.52703429 3.30770805
##
## Number of Observations: 1000
## Number of Groups: 200
intervals(gafit1, which = "all")
## Approximate 95% confidence intervals
##
## Fixed effects:
## lower est. upper
## (Intercept) 2913.20418 2995.640 3078.07582
## birthord 27.07478 46.608 66.14122
##
## Random Effects:
## Level: momid
## lower est. upper
## sd((Intercept)) 323.1724 367.2676 417.3794
##
## Within-group standard error:
## lower est. upper
## 423.7298 445.0228 467.3859
Compare mixed model multiple linear regression: \[ E[Y_{ij}|X_{ij}] = \beta_0 + \alpha_{0j} + \beta_1 X_{ij}, \alpha_{0j} \sim N(0, \sigma) \] for subject \(i\) in group \(j\).
to a population average model: \[ E[Y_{ij}|X_{ij}] = \beta_0^* + \beta_1^* X_{ij} \]
Interpretations of \(\beta^*\) and \(\beta\) are equivalent
Numerically equivalent for linear and log-linear models (if specification of mixed model is correct), but not for logistic link.
gafit.gee <- gee::gee(bweight ~ birthord,
corstr = "exchangeable",
id = momid,
data = ga)
summary(gafit.gee)
##
## GEE: GENERALIZED LINEAR MODELS FOR DEPENDENT DATA
## gee S-function, version 4.13 modified 98/01/27 (1998)
##
## Model:
## Link: Identity
## Variance to Mean Relation: Gaussian
## Correlation Structure: Exchangeable
##
## Call:
## gee::gee(formula = bweight ~ birthord, id = momid, data = ga,
## corstr = "exchangeable")
##
## Summary of Residuals:
## Min 1Q Median 3Q Max
## -2795.464 -299.126 48.840 341.144 1824.536
##
##
## Coefficients:
## Estimate Naive S.E. Naive z Robust S.E. Robust z
## (Intercept) 2995.640 41.973695 71.369462 38.808066 77.191170
## birthord 46.608 9.958128 4.680398 9.996256 4.662546
##
## Estimated Scale Parameter: 332525.3
## Number of Iterations: 1
##
## Working Correlation
## [,1] [,2] [,3] [,4] [,5]
## [1,] 1.0000000 0.4035684 0.4035684 0.4035684 0.4035684
## [2,] 0.4035684 1.0000000 0.4035684 0.4035684 0.4035684
## [3,] 0.4035684 0.4035684 1.0000000 0.4035684 0.4035684
## [4,] 0.4035684 0.4035684 0.4035684 1.0000000 0.4035684
## [5,] 0.4035684 0.4035684 0.4035684 0.4035684 1.0000000
Must make some assumption about the form of correlation among grouped observations. Some options are:
Fewer assumptions requires more data, and good assumptions improve results