To Start R: Click on the R icon
If no R icon, go to Start and then All Programs to find R
R function: lme
> library(nlme)
> help(lme)
What is the default method?
We will use the textbook web page , Click on Chapter 3
We will use the Rat Pup Data: this is an example of of a two-level clustered data set from a randomized trial: each litter (cluster) was randomly assigned to a specific level of treatment, and rat pups (unit of analysis) were nested with litters.
Study: 30 female rats were randomly assigned to receive 1 of 3 doses (high, low, control) of an experimental compound. The objective: compare the birth weights of the pups from litters born to high and low to birth weights of pups from the control. Note: the number of litters per treatment and number of pups per litter are unequal, so the study has an unbalanced design.
I have put the data in the file off the web page, so let's use my code, ch3desc.r
Let's make boxplots of rat pup birth weights for levels of treatment by sex. (Figure 3.1).
What do you notice?
Let's make litter-specfic boxplots of rat pup birth weights by treatment level and sex, and ordered by litter size. (Figure 3.2)
What do you notice? (except for males from litters in low dose)
We will follow the Chapter 3: R Syntax file.
Note you already have the
object ratpup. You will need to make the ratpup$sex1 variable.
Model 3.1:
Weight_ij is birth weight on rat pup i within the jth litter.
Weigth _ij = beta_0 + beta_1 x TREAT1_j + beta_2 x Treat2_j + beta_3 x SEX1_ij
+ beta_4 x LITSIZE_j + beta_5 x TREAT1_j x SEX1_ij + beta_6 x TREAT2_j x SEX1_ij
+ u_j + epsilon_ij
We will go through the code and stop at #Test Hypothesis 3.5
There are is a diagostic plot function with an lme object.
You should be able to write down the Models: 3.1, 3.1A, 3.2A, 3.2B