Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
That's what I am looking for. Thanks for being so helpful, I appreciate it very much. On Sun, Feb 23, 2014 at 10:16 PM, Gabor Grothendieck < ggrothendi...@gmail.com> wrote: > On Sun, Feb 23, 2014 at 9:06 PM, C W wrote: > > Is there a way to rbind this? Do I have to use use a package like 'zoo

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread Gabor Grothendieck
On Sun, Feb 23, 2014 at 9:06 PM, C W wrote: > Is there a way to rbind this? Do I have to use use a package like 'zoo' and > merge()? > > p <- predict(model, data.frame(t = 1, q = factor(1, 1:4)) > rbind(tsdat, p) > If you want to append this to the end of the series then try this: ts(c(tsdat,

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Is there a way to rbind this? Do I have to use use a package like 'zoo' and merge()? p <- predict(model, data.frame(t = 1, q = factor(1, 1:4)) rbind(tsdat, p) On Sun, Feb 23, 2014 at 8:43 PM, C W wrote: > I guess this is for anyone in the future. > > > predict(model, data.frame(t = 1, q = fac

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
I guess this is for anyone in the future. > predict(model, data.frame(t = 1, q = factor(1, 1:4)) This would be the answer. Thanks again, Gabor! Mike On Sun, Feb 23, 2014 at 8:23 PM, Gabor Grothendieck wrote: > On Sun, Feb 23, 2014 at 7:40 PM, C W wrote: > > Gabor, > > Your response worked p

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread Gabor Grothendieck
On Sun, Feb 23, 2014 at 7:40 PM, C W wrote: > Gabor, > Your response worked perfectly, list(t = 1, q = factor(1, 1:4) was what I > couldn't figure out. Thank you. > > In predict.lm(model, newdata), 2nd argument MUST be data.frame(). Why does > list() also work? > Yes, it would be better to use

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Gabor, Your response worked perfectly, list(t = 1, q = factor(1, 1:4) was what I couldn't figure out. Thank you. In predict.lm(model, newdata), 2nd argument MUST be data.frame(). Why does list() also work? Mike On Sun, Feb 23, 2014 at 7:32 PM, Gabor Grothendieck wrote: > On Sun, Feb 23, 20

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread Gabor Grothendieck
On Sun, Feb 23, 2014 at 7:25 PM, C W wrote: > Gabor, > Let me change newdata since it's confusing. > > Suppose I want to predict, year 1990, and quarter 2. >> newdata <- data.frame(c(1990, 1, 0, 0) > > Since Q1 is a baseline, we will only see Q2, Q3, Q4. So, 4 parameters in > total. > The formul

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Gabor, Let me change newdata since it's confusing. Suppose I want to predict, year 1990, and quarter 2. > newdata <- data.frame(c(1990, 1, 0, 0) Since Q1 is a baseline, we will only see Q2, Q3, Q4. So, 4 parameters in total. Mike On Sun, Feb 23, 2014 at 7:13 PM, Gabor Grothendieck wrote: >

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread Gabor Grothendieck
On Sun, Feb 23, 2014 at 6:56 PM, C W wrote: > Gabor, > I want the new data to be this, > newdata <- data.frame(c(1, 0, 0, 0)) > Its not clear what this means. There are two input variables so we must specify two inputs. For example, this would get the prediction for t=1 and for level 1 of q whic

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Gabor, I want the new data to be this, newdata <- data.frame(c(1, 0, 0, 0)) Here the code with the new data, > dat <- rnorm(20) > tsdat <- ts(dat, start=c(1900, 1), freq=4) > q <- as.factor(rep(1:4, 5)) > t <- 1:20 > lm(tsdat~t+q) Call: lm(formula = tsdat ~ t + q) Coefficients: (Intercept)

Re: [R] predict.lm() does not take ts objects in formula

2014-02-23 Thread Gabor Grothendieck
On Sun, Feb 23, 2014 at 6:34 PM, C W wrote: > Hello, > I don't know how to use predict.lm() for ts object. > > Here's the time series regression. > y = t + Q1 + Q2 + Q3 + Q4 > > Here's my R code, > >> dat <- rnorm(20) >> tsdat <- ts(dat, start=c(1900, 1), freq=4) >> q <- as.factor(rep(1:4, 5)) >>

[R] predict.lm() does not take ts() objects in formula

2014-02-23 Thread C W
Hello list, Does predict.lm() take ts object. I am aware that it requires data to come in data.frame Here's the time series regression. y = t + Q1 + Q2 + Q3 + Q4 Here's my R code, > dat <- rnorm(20) > tsdat <- ts(dat, start=c(1900, 1), freq=4) > q <- as.factor(rep(1:4, 5)) > t <- 1:20 > lm(ts

[R] predict.lm() does not take ts objects in formula

2014-02-23 Thread C W
Hello, I don't know how to use predict.lm() for ts object. Here's the time series regression. y = t + Q1 + Q2 + Q3 + Q4 Here's my R code, > dat <- rnorm(20) > tsdat <- ts(dat, start=c(1900, 1), freq=4) > q <- as.factor(rep(1:4, 5)) > t <- 1:20 > lm(tsdat~t+q) Call: lm(formula = tsdat ~ t + q)