Dear all, I've tried a multiple regression, and now I want to try a cross-validation. I obtain this error (it must be sth related to df) that I don't understand, any help would be appreciated. cv.lm(df= dat, lm2.52f, m=3) Error en `[.data.frame`(df, , ynam) : undefined columns selected lm2.52f is my lm object, dat is a dataframe where the variables involved in .lm are I tried CVlm also but the same error Thanks, user at host.com -- View this message in context: http://r.789695.n4.nabble.com/cv-lm-syntax-error-tp3334889p3334889.html Sent from the R help mailing list archive at Nabble.com.
On 04.03.2011 10:11, agent dunham wrote:> Dear all, > > I've tried a multiple regression, and now I want to try a cross-validation. > > I obtain this error (it must be sth related to df) that I don't understand, > any help would be appreciated. > > cv.lm(df= dat, lm2.52f, m=3) > > Error en `[.data.frame`(df, , ynam) : undefined columns selected > > lm2.52f is my lm object,If this is the cv.lm from the DAAG package (unstated), then please read its help page and find that you need to specify a formula as the second argument rather than an already fitted lm object. Uwe Ligges > dat is a dataframe where the variables involved in> .lm are > > I tried CVlm also but the same error > > Thanks, user at host.com > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/cv-lm-syntax-error-tp3334889p3334889.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.
Thanks for your answer, but I type the following:> dfmod.1 <- data.frame(dat$v1,dat$v2,dat$v3,dat$v4, dat$v5,factor)> CVlm(df= dfmod.1, form.lm = formula(dat$v1 ~ dat$v2+dat$v3+ dat$v4+ > dat$v5+ factor), m=3, seed=29, plotit=TRUE, printit =TRUE)Error en `[.data.frame`(df, , ynam) : undefined columns selected What does it mean? user at host.com -- View this message in context: http://r.789695.n4.nabble.com/cv-lm-syntax-error-tp3334889p3341767.html Sent from the R help mailing list archive at Nabble.com.
Your message subject says it all. The function is "cv.lm()". Also check the syntax for data.frame() On 8-Mar-11, at 8:47 AM, agent dunham wrote:> Thanks for your answer, but I type the following: > >> dfmod.1 <- data.frame(dat$v1,dat$v2,dat$v3,dat$v4, dat$v5,factor) > >> CVlm(df= dfmod.1, form.lm = formula(dat$v1 ~ dat$v2+dat$v3+ dat$v4+ >> dat$v5+ factor), m=3, seed=29, plotit=TRUE, printit =TRUE) > > Error en `[.data.frame`(df, , ynam) : undefined columns selected > > What does it mean? > > user at host.com > > -- > View this message in context: http://r.789695.n4.nabble.com/cv-lm- > syntax-error-tp3334889p3341767.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.Why does the universe go to all the bother of existing? -- Stephen Hawking #define QUESTION ((bb) || !(bb)) -- William Shakespeare Don McKenzie, Research Ecologist Pacific WIldland Fire Sciences Lab US Forest Service Affiliate Professor School of Forest Resources, College of the Environment CSES Climate Impacts Group University of Washington desk: 206-732-7824 cell: 206-321-5966 dmck at uw.edu donaldmckenzie at fs.fed.us
It means that dat$v1, dat$v2, . . . are not columns in the data frame df Specify the formula as v1 ~ v2+v2+v3+v4+v5+factor Then (assuming that factor is a column object of the right length) you should be fine. John Maindonald email: john.maindonald@anu.edu.au phone : +61 2 (6125)3473 fax : +61 2(6125)5549 Centre for Mathematics & Its Applications, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. http://www.maths.anu.edu.au/~johnm> From: agent dunham <crosspide@hotmail.com> > Date: 9 March 2011 3:47:10 AM AEDT > To: r-help@r-project.org > Subject: Re: [R] cv.lm syntax error > > > Thanks for your answer, but I type the following: > >> dfmod.1 <- data.frame(dat$v1,dat$v2,dat$v3,dat$v4, dat$v5,factor) > >> CVlm(df= dfmod.1, form.lm = formula(dat$v1 ~ dat$v2+dat$v3+ dat$v4+ >> dat$v5+ factor), m=3, seed=29, plotit=TRUE, printit =TRUE) > > Error en `[.data.frame`(df, , ynam) : undefined columns selected > > What does it mean? > > user@host.com > > -- > View this message in context: http://r.789695.n4.nabble.com/cv-lm-syntax-error-tp3334889p3341767.html > Sent from the R help mailing list archive at Nabble.com.[[alternative HTML version deleted]]