Skip to content

Instantly share code, notes, and snippets.

@marutter
Created April 27, 2011 12:48
Show Gist options
  • Save marutter/944188 to your computer and use it in GitHub Desktop.
Save marutter/944188 to your computer and use it in GitHub Desktop.
hw_11_code.R
library(lme4)
data.3 <- read.table("CH27PR20.txt")
response <- data.3$V1
field <- factor(data.3$V2)
fert <- factor(data.3$V4)
irrigation <- factor(data.3$V3)
res3.m <- lmer(response~irrigation*fert+(1|field:irrigation))
summary(res3.m)
51.6/(51.6+1.5)
anova(res3.m)
1-pf(13.26,1,10-1)
1-pf(45.63,1,20-2-10)
1-pf(.03331,1,20-2-10)
tapply(response,fert,mean) # Note the correct way to find the means
tapply(response,irrigation,mean)
data.2 <- read.csv("split_plot_2.csv")
attach(data.2)
head(data.2)
repf <- factor(replicate)
soilf <- factor(soil)
xyplot(yield~soil|air)
res2.m <- lmer(yield~air*soilf+(1|air:repf))
summary(res2.m)
14.08/(14.08+2.6)
anova(res2.m)
1-pf(12.48,1,4-1)
1-pf(32.26,2,12-2*2-4)
1-pf(1.58,2,12-2*2-4)
sort(tapply(yield,air,mean))
sort(tapply(yield,soilf,mean))
1/sqrt(2)*qtukey(.975,3,12-2*2-4)*1.607 # .975 since both factors are significant
1/sqrt(2)*qtukey(.95,3,12-2*2-4)*1.607 # Not correct, but here for reference
24.75-17.50
data <- read.csv("split_plot_3.csv")
head(data)
attach(data)
repf <- factor(Replicate)
res.m <- lmer(Yield~Variety*Date+(1|Variety:repf))
summary(res.m)
.0849/(.0849+.0280)
anova(res.m)
1-pf(.2421,2,18-2)
1-pf(23.39,3,72-3*3-18)
1-pf(1.2548,6,72-3*3-18)
sort(tapply(Yield,Date,mean))
1/sqrt(2)*qtukey(.95,4,72-3*3-18)*.09655
1.57-1.34
1.78-1.57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment