cd4$vdate <- as.Date(cd4$vdate)
require(lattice)
xyplot(sqrt(cd4pct) ~ vdate, cd4, group=newpid,type=c("p","r"))
lmList
in nlme
package. (The intervals command creates 95%
CIs for each kid's intercept and slope.)
require(nlme) cd4.kidfit <- lmList(sqrt(cd4pct) ~ I(as.numeric(vdate)-7128)|factor(newpid),cd4[,3:5]) plot(intervals(cd4.kidfit))
intercepts <- summary(cd4.kidfit)$coefficients[,1,1] slopes <- summary(cd4.kidfit)$coefficients[,1,2] plot(slopes~intercepts) age1 <- with(cd4, tapply(baseage, newpid,min)) trt <- with(cd4, tapply(treatmnt, newpid,min))Obtain estimates for the whole population by fitting a model for intercept as a function of initial age and treatment, then fitting a similar model for slopes. Plot these fits and their "data points" (in quotes because they are estimates, not data).
by newpid; statement to fit a line to each
kid. Save the parameter
estimates by including the right option in the PROC
line. Examine the structure of the dataset output and fit
the models above in SAS. Report on how well these match
with the R output.