Error In Tukeyhsd.aov
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Tukey HSD for mixed continuous and categorical variables, error: “no factors” up vote -1 down vote favorite I'm trying to run a Tukey test on mortality data, where I want to test whether mortality is influenced by the amount of copper (in an one-way ANOVA) and the combination of copper and temperature (in a two-way ANOVA). These are my formulas: lm2<-lm(Mortality~Cu) anova(lm2) TukeyHSD(aov(Mortality~Cu)) lm2<-lm(Mortality~Cu+Temp+Cu:Temp) anova(lm2) TukeyHSD(aov(Mortality~Cu+Temp+Cu:Temp)) The ANOVA is no problem, but for both Tukey's, I get the following error message: Error in TukeyHSD.aov(aov(Mortality ~ Cu + Temp + Cu:Temp)) : no factors in the fitted model In addition: Warning messages: 1: In replications(paste("~", xx), data = mf) : non-factors ignored: Cu 2: In replications(paste("~", xx), data = mf) : non-factors ignored: Temp 3: In replications(paste("~", xx), data = mf) : non-factors ignored: Cu, Temp I've read on other posts that there should be a factor somewhere, but all my data are numbers! I'm quite baffled and have no idea what to do next. Thanks in advance for your help! Lundill r anova categorical-data continuous share|improve this question edited Apr 29 at 5:01 DirtStats 187114 asked May 9 '14 at 15:23 Lundill 1111 Cu:Temp expects that Cu and/or Temp are factors. So you should convert them. –Rich Scriven May 9 '14 at 15:43 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote TukeyHSD only works with categorical variables so it's looking for factors in your formula. Are the values of Cu discrete bust just coded as numeric values? If so then use fCu<-
♦ ♦ | Report Content as Inappropriate ♦ ♦ TukeyHSD troubles I've tried to run a Tukey post-hoc but keep getting this weird error, whether the aov was significant or not. treat_code is a dummy variable, but that shouldn't matter. Any suggestions? Thanks Amy > summary(aov(EtoH~treat_code, mydata)) Df Sum Sq Mean Sq F value Pr(>F) treat_code 1 16.44 16.44 11.027 0.001014 ** Residuals 287 427.91 1.49 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > TukeyHSD(aov(EtoH~treat_code, mydata)) Error in TukeyHSD.aov(aov(EtoH ~ treat_code, http://stackoverflow.com/questions/23568362/tukey-hsd-for-mixed-continuous-and-categorical-variables-error-no-factors mydata)) : no factors in the fitted model In addition: Warning message: In replications(paste("~", xx), data = mf) : non-factors ignored: treat_code -- Amy Freitag Ph.D. student, Marine Science and Conservation Nicholas School for the Environment Duke University [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. Richard M. Heiberger Threaded Open this post in threaded http://r.789695.n4.nabble.com/TukeyHSD-troubles-td1570205.html view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: TukeyHSD troubles > treat_code is a dummy > variable, but that shouldn't matter. Any suggestions? It does matter to TukeyHSD. If treat_code is a numeric variable with discrete values 0 and 1, then it does not have class "factor". It is true that aov will give the same ANOVA table for a two-level factor as for a two-value numeric. It will give different ANOVA tables if there are more than two values. TukeyHSD will refuse to do anything for a numeric variable. It insists on factors. You must use the statement mydata$treat_code <- factor(mydata$treat_code) before creating the aov object that you give to TukeyHSD. Rich ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. Bart Joosen Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: TukeyHSD troubles In reply to this post by Amy Freitag treat_code isn't a factor, but a numeric variable. You should use: summary(aov(EtoH~as.factor(treat_code), mydata)) TukeyHSD(aov(EtoH~as.factor(treat_code), mydata)) Bart jhartsho Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: TukeyHSD troubles Thanks! I was
♦ ♦ | Report Content as Inappropriate ♦ ♦ TukeyHSD error All - I think I'm being dense, http://r.789695.n4.nabble.com/TukeyHSD-error-td3051059.html but for the life of me, I can't figure out why I get error message with the code below. I have data that looks like param level http://forums.cirad.fr/logiciel-R/viewtopic.php?t=3721 perc.surv asin.tran DO 3 0.6864407 0.9764544 DO 3 0.1250000 0.3613671 DO 3 0.8738739 1.2077299 DO 4 0.4615385 0.7468986 DO error in 4 0.5691057 0.8547258 DO 4 0.8504673 1.1737517 DO 6 0.5494505 0.8349297 DO 6 0.4938272 0.7792252 DO 6 0.1230769 0.3584500 DO 6 0.7209302 1.0142339 DO 6 0.2297297 0.4998584 DO 6 0.9300000 1.3030330 DO 6 0.4482759 0.7335813 DO 6 error in tukeyhsd.aov 0.0000000 0.0000000 DO 6 0.6018519 0.8879679 and code aov.DO <- aov(asin.tran~level) summary(aov.DO) TukeyHSD(aov.DO) When I run the final line, I get the following error message "Error in TukeyHSD.aov(aov.DO) : no factors in the fitted model In addition: Warning message: In replications(paste("~", xx), data = mf) : non-factors ignored: level" What am I missing? Thanks for your help - Steven Ranney [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. Steven Ranney Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: TukeyHSD error Rescinded. Problem solved. I discovered that TukeyHSD doesn't like numeric factors; changing the "level" to a factor solved my problem. SR Steven H. Ranney [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. « Return to R help | 1 view|%1 views Loading... Free forum by Nabble Edit this page
forum FAQ Connexion M’enregistrer Index du forum Discussions Questions en cours Rechercher TukeyHSD et aov, "which" ne spécifie aucun facteur Postez ici vos questions, réponses, commentaires ou suggestions - Les sujets seront ultérieurement répartis dans les archives par les modérateurs Modérateur : Groupe des modérateurs Répondre Rechercher Recherche avancée 8 messages • Page 1 sur 1 nicolas casadei Messages : 18 Enregistré le : 11 Jan 2011, 13:01 TukeyHSD et aov, "which" ne spécifie aucun facteur Citation Messagepar nicolas casadei » 13 Avr 2011, 09:58 contexte: des sujets se déplacent dans une pièce, un tracking mesurent différent paramètres toutes les minutes (distance parcourue, distance au centre de la pièce, genre...) Le but de cette partie du script et de faire une comparaison de valeur distance parcourue en fonction du genre et du temps table originale (bien réduite) nomée res.patient: XT.YT;Gender;Time214;male;840264;male;841328;male;842283;male;843324;male;844331;male;845272;male;846187;male;847244;male;848169;male;849210;male;85047;female;8402;female;8410;female;8420;female;84368;female;84449;female;84590;female;846128;female;847107;female;84812;female;849262;female;850247;male;840178;male;841178;male;842203;male;843169;male;844229;male;845296;male;846196;male;847214;male;848219;male;849240;male;850175;female;840291;female;841271;female;842216;female;843285;female;844208;female;845262;female;846240;female;847225;female;848251;female;849151;female;850 mon code: Code : Tout sélectionnerres.patient <- read.csv2("table.csv")
table.tmp <- aov(res.patient[,1] ~ res.patient$Gender + res.patient$Time)
table1 <- TukeyHSD(table.tmp, "Gender")
voila l´erreur: Error in TukeyHSD.aov(table.tmp, "Gender") : 'which' specified no factorsIn addition: Warning message:In replications(paste("~", xx), data = mf) : non-factors ignored: res.patient$Time Merci pour votre temps PS: si vous avez des conseils pour que mes posts soient plus clair ou plus facile à reproduire, n´hésitez pas. Haut Nicolas Péru Messages : 1403 Enregistré le : 07 Aoû 2006, 08:13 Citation Messagepar Nicolas Péru » 13 Avr 2011, 10:06 Salut, Certainement une erreur de spécification de modèle (non testé) : Code : Tout sélectionnerres.patient <- read.csv2("table.csv")
table.tmp <- aov( ?? ~ Gender + Time, data=res.patient)
table1 <- Tuk