Hi! My regression is lm(Y ~ A + B + C + D + E + F + G), where each covariate "A--G" is of the kind "as.factor(column of the dataframe)". I receive an error for the first explanatory variable "A": Error in column of the dataframe: wrong number of dimensions. What does it mean? -- View this message in context: http://r.789695.n4.nabble.com/lm-regression-tp3060123p3060123.html Sent from the R help mailing list archive at Nabble.com.
Hi, It probably means that somehow your data is stored incorrectly. Try using str(name of the dataframe) and see if everything is named what you expect and is the class you think it is with equal numbers of observations. HTH, Josh On Fri, Nov 26, 2010 at 3:39 AM, effeesse <scarpino86 at gmail.com> wrote:> > Hi! My regression is lm(Y ~ A + B + C + D + E + F + G), where each covariate > "A--G" is of the kind "as.factor(column of the dataframe)". > I receive an error for the first explanatory variable "A": Error in ?column > of the dataframe: wrong number of dimensions. What does it mean? > -- > View this message in context: http://r.789695.n4.nabble.com/lm-regression-tp3060123p3060123.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/
I found one error in in the code, however, I still receive errors. Error in storage.mode(y) <- "double" : invalid to change the storage mode of a factor Moreover: Warning message: In model.response(mf, "numeric") : using type="numeric" with a factor response will be ignored>From my understanding of the warning there are two errors, maybe they areconnected. I think I should change an option in the lm changing the responso from "numeric" to "factor". Is it true? How it can be done? -- View this message in context: http://r.789695.n4.nabble.com/lm-regression-tp3060123p3060363.html Sent from the R help mailing list archive at Nabble.com.
Can you create a small example that replicates your problem? If not, at least send the code you are running right before R throws an error (e.g., the exact call to lm) and some basic information on your data like the class of each variable and the number of observations. Is your outcome variable, Y, a factor? That is what the warning suggests (model.response extracts the response (outcome, the variable on the left side of the ~ ) variable from your model. HTH, Josh On Fri, Nov 26, 2010 at 6:06 AM, effeesse <scarpino86 at gmail.com> wrote:> > I found one error in in the code, however, I still receive errors. > > Error in storage.mode(y) <- "double" : > ?invalid to change the storage mode of a factor > Moreover: Warning message: > In model.response(mf, "numeric") : > ?using type="numeric" with a factor response will be ignored > > >From my understanding of the warning there are two errors, maybe they are > connected. I think I should change an option in the lm changing the responso > from "numeric" to "factor". Is it true? How it can be done? > -- > View this message in context: http://r.789695.n4.nabble.com/lm-regression-tp3060123p3060363.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/