search for: lagx

Displaying 4 results from an estimated 4 matches for "lagx".

Did you mean: lag
2005 Feb 18
9
Using time series and lm
...iate time series containing NA values. I want to compute a linear regression and obtain a time serie for both residuals and fitted values. I have tried the trick ts.intersect, without success. Could you help me out of this? #### Example: y<-ts(1:10+rnorm(10)) x<-ts(1:10) datats<-cbind(y,lagx=lag(x)) Notice the datats could come directly from an imported file, that is why I did not use ts.intersect(y,lagx=lag(x)) fit<-lm(y~lagx,data=datats,na.action=na.omit) but how do I get a time serie of residuals instead of a vector residuals(fit)? ###### Matthieu Cornec
2005 Mar 05
4
How to use "lag"?
Is it possible to fit a lagged regression, "y[t]=b0+b1*x[t-1]+e", using the function "lag"? If so, how? If not, of what use is the function "lag"? I get the same answer from y~x as y~lag(x), whether using lm or arima. I found it using y~c(NA, x[-length(x)])). Consider the following: > set.seed(1) > x <- rep(c(rep(0, 4), 9), len=9) > y <-
2011 Aug 04
2
Efficient way of creating a shifted (lagged) variable?
Hello! I have a data set: set.seed(123) y<-data.frame(week=seq(as.Date("2010-01-03"), as.Date("2011-01-31"),by="week")) y$var1<-c(1,2,3,round(rnorm(54),1)) y$var2<-c(10,20,30,round(rnorm(54),1)) # All I need is to create lagged variables for var1 and var2. I looked around a bit and found several ways of doing it. They all seem quite complicated - while in
2005 Apr 26
1
Time alignment of time series
One thing that has given me trouble is the fact that the time series implementation in the class ts relies on the concept of a "start" to the time series. For example, if I have ts1 <- ts(c(1,2,3)) dts1 <- diff(ts1) then dts1 will be a vector c(1,1) but with the attribute start = 2. Similarly, when one takes lags the "start" is moved around and the underlying vector