I want to compute the following time series regression using R:
$\Delta y_t=\beta_1 \Delta x_t+\beta_2 \Delta z_t+\beta_3 \Delta m_t+\beta_4 \Delta y_{t−1}$
Since I have not that much experience with R I want to ask if the following R code gives me what I want:
y <- ts(diff(YY))
x <- ts(diff(XX))
z <- ts(diff(ZZ))
m <- ts(diff(MM))
l1 <- lag(y, k=-1)
int <- ts.intersect(y, x, z, m, l1)
reg1 <- lm(y~x+z+m+l1, data=int)
summary(reg1)`
Sorry but I can`t find the typo in my formula.
Here is a data sample:
Date YY XX ZZ MM
03.01.2005 2.154 2.089 0.001 344999
04.01.2005 2.151 2.084 0.006 344999
05.01.2005 2.151 2.087 -0.007 333998
06.01.2005 2.15 2.085 -0.005 333998
07.01.2005 2.146 2.086 -0.006 333998
10.01.2005 2.146 2.087 -0.007 333998
11.01.2005 2.146 2.089 -0.009 333998
12.01.2005 2.145 2.085 -0.005 339999
13.01.2005 2.144 2.084 -0.004 339999
14.01.2005 2.144 2.085 -0.005 339999
17.01.2005 2.143 2.085 -0.005 339999
18.01.2005 2.144 2.085 -0.005 347999
19.01.2005 2.143 2.086 -0.006 354499
20.01.2005 2.144 2.087 -0.007 354499
21.01.2005 2.143 2.087 -0.007 354499
24.01.2005 2.143 2.086 -0.006 354499
25.01.2005 2.144 2.086 -0.006 354499
26.01.2005 2.143 2.086 -0.006 347999
27.01.2005 2.144 2.085 -0.005 352998
28.01.2005 2.144 2.084 -0.004 352998
31.01.2005 2.142 2.084 -0.004 352998
01.02.2005 2.142 2.083 -0.003 352998
02.02.2005 2.141 2.083 -0.003 357499
03.02.2005 2.144 2.088 -0.008 357499
04.02.2005 2.142 2.084 -0.004 357499
07.02.2005 2.142 2.084 -0.004 359999
08.02.2005 2.141 2.083 -0.003 355500
I tried what fg nu answered to my original question but get an error message.
1. zooX = zoo(test4[, -1], order.by = test4$Date)
this comand works fine. (The first column of my data set is the date column, so my dataset looks exactly like the data sample in my question.)
2. I ran the regression: lmX = dynlm(d(YY) ~ d(XX) + d(ZZ) + d(MM) + L(YY, 1), data = zooX)
Here I get the following error message: Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases In addition: Warning message: In dynlm(d(YY) ~ d(XX) + d(ZZ) + d(MM) + L(YY, 1), data = zooX) : empty model frame specified
What is the bug I am overseeing?