Robert Zimbardo
2015-Aug-19 00:49 UTC
[R] Error message from allEffects(model) / effect(model)" ‘range’ not meaningful for factors"
Hi I cannot figure out why the effects package throws me error messages with the following simple code: rm(list=ls(all=TRUE)); set.seed(1); library(effects) # set up data x <- factor(rep(letters[1:3], each=100)) y <- c(rnorm(100, 3, 3), rnorm(100, 4, 3), rnorm(100, 5, 3)) # fit linear model m <- summary(lm(y~x)) # no problem # now the problem plot(allEffects(m)) # Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, : # ?range? not meaningful for factors plot(effect("x", m)) # Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, : # ?range? not meaningful for factors Any ideas? It's go to be something superobvious, but I don't get it. Thanks, RZ
John Fox
2015-Aug-19 15:55 UTC
[R] Error message from allEffects(model) / effect(model)" ‘range’ not meaningful for factors"
Hi,> m <- lm(y~x) # no problem> allEffects(m)# also no problemmodel: y ~ x x effect x a b c 3.322448 3.830997 4.969154> effect("x", m) # dittox effect x a b c 3.322448 3.830997 4.969154> Effect("x", m) # dittox effect x a b c 3.322448 3.830997 4.969154 Best, John ----------------------------------------------- John Fox, Professor McMaster University Hamilton, Ontario, Canada http://socserv.socsci.mcmaster.ca/jfox/> -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Robert > Zimbardo > Sent: Tuesday, August 18, 2015 8:50 PM > To: r-help at r-project.org > Subject: [R] Error message from allEffects(model) / effect(model)" > ?range? not meaningful for factors" > > Hi > > I cannot figure out why the effects package throws me error messages > with the following simple code: > > > rm(list=ls(all=TRUE)); set.seed(1); library(effects) > # set up data > x <- factor(rep(letters[1:3], each=100)) > y <- c(rnorm(100, 3, 3), rnorm(100, 4, 3), rnorm(100, 5, 3)) > > > # fit linear model > m <- summary(lm(y~x)) # no problem > > # now the problem > plot(allEffects(m)) > # Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > : > # ?range? not meaningful for factors > plot(effect("x", m)) > # Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > : > # ?range? not meaningful for factors > > > Any ideas? It's go to be something superobvious, but I don't get it. > Thanks, > RZ > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code.
Michael Dewey
2015-Aug-19 15:57 UTC
[R] Error message from allEffects(model) / effect(model)" ‘range’ not meaningful for factors"
You rm is of class summary.lm Is that what allEffects is expecting? On 19/08/2015 01:49, Robert Zimbardo wrote:> Hi > > I cannot figure out why the effects package throws me error messages > with the following simple code: > > > rm(list=ls(all=TRUE)); set.seed(1); library(effects) > # set up data > x <- factor(rep(letters[1:3], each=100)) > y <- c(rnorm(100, 3, 3), rnorm(100, 4, 3), rnorm(100, 5, 3)) > > > # fit linear model > m <- summary(lm(y~x)) # no problem > > # now the problem > plot(allEffects(m)) > # Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, : > # ?range? not meaningful for factors > plot(effect("x", m)) > # Error in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, : > # ?range? not meaningful for factors > > > Any ideas? It's go to be something superobvious, but I don't get it. Thanks, > RZ > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Michael http://www.dewey.myzen.co.uk/home.html