Professional Documents
Culture Documents
data(ratdrink)
#Q2 Create a plot showing weight (wt) as a function of time (weeks), subject (subject) and
treatment (treat). The plot should indicate weight trajectories versus time for subjects (rats)
within each of the three treatment groups, essentially similar to plots we’ve seen for the
dental data and fev1 data in class. You may consider the units of weight to be grams. What
does the plot suggest about a statistical model for these data? Be thorough yet concise. (10
points)
plot(rd.gd, outer=~treat, key=FALSE)
We can see from the above plot that the weights have increased linearly throughout the
course time in the control treatment graph. When it comes to thioracil treatment, we see a
lot of irregular growth and the total weight of the rats is low/less than in other models. When
it comes to throxine, there are few parallels between it and the control treatment, and the
growth rate is significantly higher than the other two therapies.
#Q3 Fit a linear longitudinal model with random intercepts and slopes for each subject (rat)
(aka, random coefficients model or linear mixed effects) while allowing each treatment
group to have its own within subject error standard deviation. Your population averaged
(fixed effects) model should allow each treatment group to have its own linear trend in time
(weeks) (own intercept and slope). The model is parameterized for the within subject error
standard deviation of a reference group (the control group here), with the parameters for
the other groups being the ratio of the group standard deviation relative to that of the
reference group. So, a ratio of 1 for a group means that group’s within subject error standard
deviation is no different than that of the reference group, and so on for ratios greater or less
than 1. Compute 95% confidence intervals for these within subject error standard
deviation/ratios (i.e., ‘variance components’), and use these intervals to comment briefly on
whether we need to consider different within subject error variability across treatment
groups. Show your code and output. (10 points)
mod1<- lme(fixed = wt ~ weeks + treat + weeks:treat,
random = ~1+ weeks| subject, weights = varIdent(form = ~1|treat),
data=rd.gd,
method="REML")
summary(mod1)
Yes, different within-subject error variability across treatment groups must be considered.
Because there is no "1" inside the 95% confidence ranges for variance components. As we
can see, the interval is between 2.717199 and 4.54330, and it does not include 1, thus we
must take it into account.
#Q4 Fit a reduced model having common within subject error (uncorrelated) variance and
conduct a likelihood ratio test of equal within subject variability across groups verses
different variability across groups. Report your code, output and conclusion, and comment
on how this test agrees or disagrees with you assessment based on the intervals in the
previous item. (10 points)
mod2<- update(mod1,
summary(mod2)
anova(mod2 , mod1 )
We can see that the P value is high (> 0.5), hence model 2 (the simplified model) is the best
model. We can see from the preceding question that we need to account for subject error
variability between treatments, thus we go with the reduced model, which is model 2.
#Q5 Regardless of your conclusions, above, continue here with the smaller of the above two
models, the one with constant variance of errors within subjects. Report a partial anova table
(i.e., ‘type 3’ (car::Anova) or ‘marginal’ (nlme::anova.lme), as we’ve presented in our notes,
and comment on the (population averaged, fixed) effects of treatment on weight. Be sure to
consider any interaction of the treatments with weeks (i.e., don’t violate the marginality
principle.) You may find that a summary of the fixed effects will help you to explain such
effects. Discuss your results in the context of the original plot, above. (10 points)
car::Anova(mod2, type=3)
As we can see from the varied P values, the p value for the treatments is high, while the others
are notably low, therefore we can conclude that the treatments contribute the most. The
graphs also support the same conclusion.