Tania Pollak
2015-Nov-15 21:58 UTC
[R] Error in mkRespMod(fr, family = family) : response must be numeric
Hi -- I am new to R, and not much more advanced in stats, but am trying to learn my way through the program to finish my master's thesis. I am trying to run tests using glmer, and am getting the above error message. My code is:> test1=glmer(V12~V10+(1|V4),family=poisson)Error in mkRespMod(fr, family = family) : response must be numeric (The V's are the column numbers for the variable names -- the program doesn't seem to recognize the actual variable names, although they are in the table, but does recognize the column numbers.) Any help is much appreciated. I tried searching online for some guidance, but came up empty. Thank you -- Tania [[alternative HTML version deleted]]
David L Carlson
2015-Nov-16 17:53 UTC
[R] Error in mkRespMod(fr, family = family) : response must be numeric
The error message is straightforward. V12 is not a numeric variable and probably not a variable at all. Why would R assume that V12 is a column? A column in what? Read the manual page for glmer() and a basic tutorial on R. Don't assume that R can read your mind. Without knowing something about your data, it is impossible to answer your question. How is your data stored? As a data frame? If so, you need to use the variable names in your formula and specify the data frame using the data= argument in glmer(). A good place to start would be to read one of these: Using R by J H Maindonald - https://cran.r-project.org/doc/contrib/usingR.pdf R for Beginners by E Paradis - https://cran.r-project.org/doc/contrib/Paradis-rdebuts_en.pdf The R Guide by W J Owen - https://cran.r-project.org/doc/contrib/Owen-TheRGuide.pdf ------------------------------------- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Tania Pollak Sent: Sunday, November 15, 2015 3:58 PM To: r-help at r-project.org Subject: [R] Error in mkRespMod(fr, family = family) : response must be numeric Hi -- I am new to R, and not much more advanced in stats, but am trying to learn my way through the program to finish my master's thesis. I am trying to run tests using glmer, and am getting the above error message. My code is:> test1=glmer(V12~V10+(1|V4),family=poisson)Error in mkRespMod(fr, family = family) : response must be numeric (The V's are the column numbers for the variable names -- the program doesn't seem to recognize the actual variable names, although they are in the table, but does recognize the column numbers.) Any help is much appreciated. I tried searching online for some guidance, but came up empty. Thank you -- Tania [[alternative HTML version deleted]] ______________________________________________ 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.
David Winsemius
2015-Nov-16 18:03 UTC
[R] Error in mkRespMod(fr, family = family) : response must be numeric
> On Nov 15, 2015, at 1:58 PM, Tania Pollak <pollaktn at gmail.com> wrote: > > Hi -- > > I am new to R, and not much more advanced in stats, but am trying to learn > my way through the program to finish my master's thesis. I am trying to > run tests using glmer, and am getting the above error message. > > My code is: > >> test1=glmer(V12~V10+(1|V4),family=poisson) > Error in mkRespMod(fr, family = family) : response must be numeric > > (The V's are the column numbers for the variable names -- the program > doesn't seem to recognize the actual variable names, although they are in > the table, but does recognize the column numbers.)I do not understand what you are calling ?the table?. Did you use attach() on a dataframe that has those variable names as its column names? Using `attach` is very unwise, often leading to getting puzzling error messages. If my guess is correct, you should detach() the dataframe and post the output of summary( <whatever name it might have>). It appears you do not understand what is in the `V12` column.> > Any help is much appreciated. I tried searching online for some guidance, > but came up empty. > > Thank you -- > > Tania > > [[alternative HTML version deleted]]This is a plain text mailing list.> > ______________________________________________ > 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.David Winsemius Alameda, CA, USA
John Kane
2015-Nov-16 23:12 UTC
[R] Error in mkRespMod(fr, family = family) : response must be numeric
Welcome to R-help. We probably need some more code and sample data. Please have a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and/or http://adv-r.had.co.nz/Reproducibility.html for some suggestions. John Kane Kingston ON Canada> -----Original Message----- > From: pollaktn at gmail.com > Sent: Sun, 15 Nov 2015 13:58:24 -0800 > To: r-help at r-project.org > Subject: [R] Error in mkRespMod(fr, family = family) : response must be > numeric > > Hi -- > > I am new to R, and not much more advanced in stats, but am trying to > learn > my way through the program to finish my master's thesis. I am trying to > run tests using glmer, and am getting the above error message. > > My code is: > >> test1=glmer(V12~V10+(1|V4),family=poisson) > Error in mkRespMod(fr, family = family) : response must be numeric > > (The V's are the column numbers for the variable names -- the program > doesn't seem to recognize the actual variable names, although they are in > the table, but does recognize the column numbers.) > > Any help is much appreciated. I tried searching online for some > guidance, > but came up empty. > > Thank you -- > > Tania > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.____________________________________________________________ Send any screenshot to your friends in seconds... Works in all emails, instant messengers, blogs, forums and social networks. TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE
William Dunlap
2015-Nov-17 00:10 UTC
[R] Error in mkRespMod(fr, family = family) : response must be numeric
You should look at the data that you imported to R from somewhere else with the str() or summary() function. Since you think the data should have nice column names but seems to have the names V1, ..., Vn, I think that you may may have read a file with column names at the top into R with read.table without specifying header=TRUE. With header=FALSE, the names will cause read.table to think that the column contains character data and header=FALSE also causes the column names to be V1, ..., Vn. E.g.,> dataText <- "ColA ColB\n1 100\n2 200\n" > str(read.table(text=dataText))'data.frame': 3 obs. of 2 variables: $ V1: Factor w/ 3 levels "1","2","ColA": 3 1 2 $ V2: Factor w/ 3 levels "100","200","ColB": 3 1 2> str(read.table(text=dataText, header=TRUE))'data.frame': 2 obs. of 2 variables: $ ColA: int 1 2 $ ColB: int 100 200 Again, use str() and summary() (or some of Hadley's tools) to make sure what you read into R is what you think it is. Also, make some simple plots of the data, say with pairs(). Do this before fitting any serious models to it. Bill Dunlap TIBCO Software wdunlap tibco.com On Sun, Nov 15, 2015 at 1:58 PM, Tania Pollak <pollaktn at gmail.com> wrote:> Hi -- > > I am new to R, and not much more advanced in stats, but am trying to learn > my way through the program to finish my master's thesis. I am trying to > run tests using glmer, and am getting the above error message. > > My code is: > >> test1=glmer(V12~V10+(1|V4),family=poisson) > Error in mkRespMod(fr, family = family) : response must be numeric > > (The V's are the column numbers for the variable names -- the program > doesn't seem to recognize the actual variable names, although they are in > the table, but does recognize the column numbers.) > > Any help is much appreciated. I tried searching online for some guidance, > but came up empty. > > Thank you -- > > Tania > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.