Here we are primarily interested in \((\beta_{0}, \beta_{1})\), which determines the expected \(y\) given \(x\). The individual-specific effect \(\gamma_i\) is included to acknowledge that repeated measurements for the same individuals are likely to be closer to each other than measurements from different individuals.
gender
ethnicity Female Male
Mexican American 1942 1864
Non-Hispanic Black 4272 3992
Non-Hispanic White 5258 5383
Other Hispanic 1549 1483
Other Race - Including Multi-Racial 2578 2644
bpsys_wm <-subset(bpsys, age >=20& gender =="Male"& ethnicity =="Non-Hispanic White")bpsys_mf <-subset(bpsys, age >=20& gender =="Female"& ethnicity =="Mexican American")bpsys_sub <- bpsys_mf
A wrong option is to fit a linear model:
fm1 <-lm(bpsys ~1+ age, data = bpsys_sub)fm1
Call:
lm(formula = bpsys ~ 1 + age, data = bpsys_sub)
Coefficients:
(Intercept) age
82.9327 0.7576
A natural and basic question that we may be interested in asking is whether systolic blood pressure is independent of age. For the linear model above, this is equivalent to testing \(H_0: \beta_{1} = 0\), but a more useful summary is to look at a confidence interval for \(\beta_{1}\). Confidence intervals for the model parameters in fm1 can be obtained as follows.
confint(fm1, level =0.95)
2.5 % 97.5 %
(Intercept) 80.1202540 85.7450647
age 0.6997983 0.8153212
A simple and mostly correct option is to take the average of the repeated measurements:
where \(\delta_i = \gamma_i + \bar{\epsilon}_{i\cdot}\) combines the individual variations \(\gamma_i\) and the measurement errors \(\epsilon_{ij}\). This is reasonable as long as we consider \(\delta_i\) to be mean 0 errors as well. Specifically, if we assume \(\gamma_i \sim N(0, \tau^2)\), independent of \(\epsilon_{ij}\), then
where \(n_i\) is the number of replications for the \(i\)th individual. However, if the number of replications \(n_i\) are different for different individuals, then the problem is not straightforward.
Task 1: Compute the average \(\bar{y}_{i\cdot}\) values and fit a suitable linear regression model assuming all \(n_i = 3\). Obtain the corresponding confidence interval for \(\beta_{1}\), and compare it with the interval obtained from fm1 above.
We can formulate, in principle, the corresponding likelihood \(L(\beta_{0}, \beta_{1}, \tau^2, \sigma^2)\) and maximize it, although in practice the details can be complicated.
library(lme4)
Loading required package: Matrix
fm2 <-lmer(bpsys ~1+ age + (1|SEQN), data = bpsys_sub, REML =FALSE)summary(fm2)
Linear mixed model fit by maximum likelihood ['lmerMod']
Formula: bpsys ~ 1 + age + (1 | SEQN)
Data: bpsys_sub
AIC BIC logLik -2*log(L) df.resid
8975.0 8995.6 -4483.5 8967.0 1257
Scaled residuals:
Min 1Q Median 3Q Max
-9.2848 -0.4166 -0.0177 0.4207 4.9087
Random effects:
Groups Name Variance Std.Dev.
SEQN (Intercept) 239.77 15.48
Residual 22.28 4.72
Number of obs: 1261, groups: SEQN, 421
Fixed effects:
Estimate Std. Error t value
(Intercept) 82.70441 2.41367 34.27
age 0.76368 0.04953 15.42
Correlation of Fixed Effects:
(Intr)
age -0.948
Notice that the confidence intervals are considerably wider than the ones obtained from the wrong model fm1, which gains false confidence by ignoring the correlation in the errors within subjects. On the other hand, they should closely match the confidence interval you get after averaging.
Approach B: Regularization
Another option is to take a regularization approach by saying that we want both \(\gamma_i^2\) and \(\epsilon_{ij}^2\) to be small. Of course we need to give some relative weights to these errors, so we may minimize, given \(\lambda > 0\):