Dear R people, I generated a glm logit model using a sample of a bigger set, and now I want to test the model with the bigger set. How can I do this? predict makes predictions only for a number of rows equal to the sample used. The question is, how can I use the coefficients of a glm with other sets than the one used to generate those coefficients? Thank you in advance. -- View this message in context: http://r.789695.n4.nabble.com/Use-glm-coefficients-for-other-datasets-tp3276626p3276626.html Sent from the R help mailing list archive at Nabble.com.
maxsilva <mmsilva3 <at> uc.cl> writes:> I generated a glm logit model using a sample of a bigger set, and now I want > to test the model with the bigger set. How can I do this? predict makes > predictions only for a number of rows equal to the sample used. The question > is, how can I use the coefficients of a glm with other sets than the one > used to generate those coefficients? >Take a closer look at ?predict.glm, especially the 'newdata' argument ...
Thank you for your answer. But I still have the problem; for example, if i have data for 10 months, estimate the parameters of my logit model using 10 months of data, and then use predictions<-predict(model,data=1monthonly,family = binomial(link logit),type="response") I still get the rpedictions vector with as many rows as the 10month dataset :( What can I do to solve this issue? Thank you in advance. -- View this message in context: http://r.789695.n4.nabble.com/Use-glm-coefficients-for-other-datasets-tp3276626p3276881.html Sent from the R help mailing list archive at Nabble.com.
What happens if you use the "newdata" argument name instead of "data"? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of maxsilva > Sent: Tuesday, February 08, 2011 2:29 PM > To: r-help at r-project.org > Subject: Re: [R] Use glm coefficients for other datasets > > > Thank you for your answer. But I still have the problem; for example, > if i > have data for 10 months, estimate the parameters of my logit model > using 10 > months of data, and then use > > predictions<-predict(model,data=1monthonly,family = binomial(link > logit),type="response") > > I still get the rpedictions vector with as many rows as the 10month > dataset > :( > > What can I do to solve this issue? > > Thank you in advance. > > > -- > View this message in context: http://r.789695.n4.nabble.com/Use-glm- > coefficients-for-other-datasets-tp3276626p3276881.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.