Skip to content

Instantly share code, notes, and snippets.

@marutter
Created February 25, 2011 00:51
Show Gist options
  • Select an option

  • Save marutter/843217 to your computer and use it in GitHub Desktop.

Select an option

Save marutter/843217 to your computer and use it in GitHub Desktop.
1/sqrt(2)*qtukey(.90,6,60-6)
(S <- sqrt((6-1)*qf(.90,6-1,60-6)))
g <- c(2,5,15)
qt(1-.10/(2*g),60-6)
1/sqrt(2)*qtukey(.95,5,25-5)
(S <- sqrt((5-1)*qf(.95,5-1,25-5)))
g <- c(2,5,10)
qt(1-.05/(2*g),25-5)
1/sqrt(2)*qtukey(.95,5,100-5)
(S <- sqrt((5-1)*qf(.95,5-1,100-5)))
g <- c(2,5,10)
qt(1-.05/(2*g),100-5)
data2 <- read.table("CH16PR12.txt",col.names=c("days","agents","obs"))
attach(data2)
agentsf <- factor(agents)
res <- lm(days~agentsf)
anova(res)
TukeyHSD(aov(res))
sort(tapply(days,agentsf,mean))
library(gmodels)
fit.contrast(res,agentsf,c(1,0,-1,0,0),conf.int=1-.10/3)
fit.contrast(res,agentsf,c(1,0,0,0,-1),conf.int=1-.10/3)
fit.contrast(res,agentsf,c(0,0,1,0,-1),conf.int=1-.10/3)
anova(res)
1/sqrt(2)*qtukey(.90,5,95)
qt(1-.10/(2*3),100-5)
data3 <- read.table("CH16PR09.txt",col.names=c("days","fitness","obs"))
attach(data3)
fitnessf <- factor(fitness,levels=c(1:3),labels=c("Below Average","Average","Above Average"))
res <- lm(days~fitnessf)
anova(res)
fit.contrast(res,fitnessf,c(1,-1,0),conf.int=1-.05/4)
fit.contrast(res,fitnessf,c(1,0,-1),conf.int=1-.05/4)
fit.contrast(res,fitnessf,c(0,1,-1),conf.int=1-.05/4)
fit.contrast(res,fitnessf,c(1,-2,1),conf.int=1-.05/4)
anova(res)
(S <- sqrt((2)*qf(.95,2,21)))
qt(1-.05/(2*4),21)
data2 <- read.table("CH16PR12.txt",col.names=c("days","agents","obs"))
attach(data2)
agentsf <- factor(agents)
res <- lm(days~agentsf)
anova(res)
cmat <- rbind(c(1,-1,0,0,0),
c(0,0,1,-1,0),
c(1/2,1/2,0,0,-1),
c(0,0,1/2,1/2,-1))
fit.contrast(res,agentsf,cmat)
fit.contrast(res,agentsf,c(1/2,1/2,-1/2,-1/2,0))
anova(res)
(S <- sqrt((4)*qf(.90,4,95)))
2+c(-1,1)*.8673311*S
-3.05+c(-1,1)*.8673311*S
-6.550+c(-1,1)*.7511307*S
-16.825+c(-1,1)*.7511307*S
10.275+c(-1,1)*0.6132957*S
c.i <- c(.25,.20,.20,.20,.15)
mu.i <- tapply(days,agentsf,mean)
n.i <- tapply(days,agentsf,length)
mu.i*c.i
sum(mu.i*c.i)
(se <- sqrt(7.52*sum(c.i^2/n.i)))
sum(mu.i*c.i)+c(-1,1)*qt(.95,95)*se
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment