Class Lecture Notes 3
Data entry
When R is launched the R Console window appears in which R commands can be
entered. In the Windows operating system to move around within a command line to
correct mistakes you need to use the left and right arrow keys on

Practice Exam 1
Problem 1
#read in data
endo <read.table( 'http:/www.unc.edu/courses/2010fall/ecol
/563/001/data/hw/Endo.csv', header=T, sep=',')
Question 1
The basic design is a randomized block design with a two-factor crossed
treatment structure involv

Lecture Notes 2
Homogeneity of variance
In the basic analysis of variance we assume that
where i denotes the treatment, j an experimental unit assigned to that treatment, and y is
the response. So each observation has a normal distribution in which the me

HW 5
Question 1
I read in the data.
stems <read.table( 'http:/www.unc.edu/courses/2010fall/ecol/563/0
01/data/hw/stems.csv', header=T, sep=',')
In Assignment 3 we fit a Poisson and negative binomial distributions
to num.stems variable in this data set. In

HW 4
Question 1
I read in the data.
aphids <read.table( 'http:/www.unc.edu/courses/2010fall/ecol/563/0
01/data/hw/aphids.csv', header=T, sep=',')
I next redefine the two factors precip and heat so that their low levels are the
reference levels.
names(aphi

HW 3
Question 1
I read in the data.
stems<read.table( 'http:/www.unc.edu/courses/2010fall/ecol/563/0
01/data/hw/stems.csv', header=T,sep=',')
The variable containing the stem counts in each plot is stems$num.stems. The
negative log-likelihood functions fo

HW 2
Problem 1
The code to fit the model was presented in the solutions to Assignment 1 and the relevant
portions are repeated below.
#read in data
dixon <read.table('http:/www.unc.edu/courses/2010fall/ecol/563/00
1/data/hw/alpine2.txt', header=T)
lm(lnwt

Final Exam Review Questions
Question 6
I answer this question first for the random intercepts model and then for the
random intercepts and linear coefficients model. Expt is a level-2 predictor (it
varies between moms) and hence it can be used as predicto

Practice Exam 2
Question 1
I fit the variance components model with ID nested in mom.
library(nlme)
out0 <- lme(grorate~1, data=growth, random=~1|mom/ID,
method="ML", na.action=na.omit)
VarCorr(out0)
mom =
(Intercept)
ID =
(Intercept)
Residual
Variance
pd