Hello everyone,
I'm new to the list, but could really use some assistance.
My problem concerns the multicomp() function S-Plus (version 7.0).
I am trying to generate some random data, assign them to groups, run a
one-way anova with group as the factor, and then perform Dunnett's
method for multiple comparisons, as part of a simulation I am
performing. I cannot seem to get the multicomp function working
properly.
Can anyone take a look at it, and offer some hints or guidance? I
would be much obliged. The code, as well as the error output is
pasted below.
dunnettsim=function(seedval,groups,n,a){
#seedval=5; n=c(5,5,5,4); groups=4; a=.05; set.seed(seedval)
alphabet=c("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
groupvar=matrix("z",max(n),groups)
for(j in 1:groups){
for(i in 1:n[j]){
groupvar[i,j]=alphabet[j]
}
}
dat=rnorm(sum(n))
groupvec=rep("a",n[1])
for(k in 2:groups){
groupvec=c(groupvec,groupvar[,k])
}
groupvec=as.factor(groupvec[groupvec!="z"])
#groupvec=groupvec[groupvec!="z"]
output=lm(dat~groupvec)
multicomp.lm(output,focus="a",comparisons="mcc",alpha=a,
method="dunnett")
}
dunnettsim(seedval=5,groups=4,n=c(5,5,5,4),a=.05)
OUTPUT:
Problem in multicomp.lm(output, focus = "a", comparisons = "mcc",
alpha = a, method = "dunnett"): focus = a must be one of the factors =
groupvec
--
Chris Gast
cmgast@gmail.com
(206) 271-6418
|