"Maja Schröter"
2007-Aug-04 10:02 UTC
[R] Problems using "lm" in combination with "predict"
Hello everybody, I'm trying to predict a linear regression model but it does not work. My Model: y = Worktime + Vacation + Illnes + Bankholidays My modelmatrix is of dimension 28x4 Then I want to make use of the function predict because there confidence.intervals are include. My idea was: mod <- lm(y~Worktime+Vacation+Illnes+Bankholidays) newdate=data.frame(x=c(324,123,0.9,0.1)) predict(y,newdate) But I always get the message: 'newdata' had 1 rows but variable(s) found have 28 rows What can I do? Yours, Maja -- Psssst! Schon vom neuen GMX MultiMessenger geh?rt? Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
Stephen Tucker
2007-Aug-04 11:42 UTC
[R] Problems using "lm" in combination with "predict"
I think you need predict(mod,newdate) instead of predict(y,newdate) --- "Maja Schr?ter" <maja.schroeter at gmx.de> wrote:> Hello everybody, > > I'm trying to predict a linear regression model but it does not work. > > My Model: y = Worktime + Vacation + Illnes + Bankholidays > > My modelmatrix is of dimension 28x4 > > Then I want to make use of the function predict because there > confidence.intervals are include. > > My idea was: > > mod <- lm(y~Worktime+Vacation+Illnes+Bankholidays) > > newdate=data.frame(x=c(324,123,0.9,0.1)) > predict(y,newdate) > > But I always get the message: > > > 'newdata' had 1 rows but variable(s) found have 28 rows > > > What can I do? > > Yours, > > Maja > > -- > Psssst! Schon vom neuen GMX MultiMessenger geh?rt? > Der kanns mit allen: http://www.gmx.net/de/go/multimessenger > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Frede Aakmann Tøgersen
2007-Aug-06 05:59 UTC
[R] Problems using "lm" in combination with "predict"
> > My modelmatrix is of dimension 28x4 > > Then I want to make use of the function predict because there > confidence.intervals are include. > > My idea was: > > mod <- lm(y~Worktime+Vacation+Illnes+Bankholidays) > > newdate=data.frame(x=c(324,123,0.9,0.1))Perhaps you want to specify newdate like this newdate=data.frame(Worktime = 324, Vacation = 123, Illness = 0.9, Bankholidays = 0.1))? Best regards Frede Aakmann T?gersen Scientist UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers All? 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1878 E-mail: FredeA.Togersen at agrsci.dk Web: http://www.agrsci.org This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email.
Apparently Analagous Threads
- Functions for autoregressive Regressionmodels (Mix between times series and Regression Models) ?
- How to use group in nested associations
- Questions about date/time and truncating
- Subtracting number of days from a date
- validates presence of foreign key fails in nested form