I think I need to restate the problem. If the test data is only a vector, then I am predicting one test sample. But the output from the predict result has the same length as the training set. And there is a warning message about this.
Annie On Sat, Aug 8, 2009 at 2:52 PM, annie Zhang <annie.zhang2...@gmail.com>wrote: > Hi, Milton, > > Thank you for the reply. I tried, but it seems the problem is the column > name of the test data is not the same as the column name of the training > data. I didn't give the column name, the system seemed do. How to chang > here? > > Annie > > On Fri, Aug 7, 2009 at 7:52 PM, milton ruser <milton.ru...@gmail.com>wrote: > >> Hi Annie, >> >> create a new data.frame with input variables having all predictors >> variables on it. >> after give a look at ?predict >> >> best wishes >> >> milton >> >> On Fri, Aug 7, 2009 at 8:19 PM, annie Zhang >> <annie.zhang2...@gmail.com>wrote: >> >>> Hi, R users, >>> >>> I am trying to use glm to do logistic regression. I know generally when I >>> have two covariates, say x1 and x2, then I do >>> fit <- glm(y~x1+x2,famliy='binomial') >>> But now my covariates form a n*p matrix, say x, so actually each column >>> is a >>> covariate. So I think I should do >>> fit <- glm(y~x,family='binomial') >>> Then I need to predict new data. How should I write the newdata? I tried >>> several thing, all failed. The x in the fit is a matrix, but is a vector >>> for >>> the new data. >>> >>> Thank you, >>> Annie >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@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<http://www.r-project.org/posting-guide.html> >>> and provide commented, minimal, self-contained, reproducible code. >>> >> >> > [[alternative HTML version deleted]] ______________________________________________ R-help@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.