r - Different regression output using dynlm and lm -


i ran regression first using lm , using dynlm(from package dynlm). here did using lm:

euribor3t <- ts(diff(euribor3)) ois3t <- ts(diff(ois3)) x <- ts(diff(eurepo3-ois3)) vstoxxt <- ts(diff(vstoxx)) cdst <- ts(diff(cds)) omo2 <- ts(diff(log(open.market.operations))) l1 <- (lag(euribor3t, k=-1)) axx <- ts.intersect(euribor3t, ois3t, x, vstoxxt, cdst, omo2, l1) reg1 <- lm(euribor3t~ois3t+cdst+x+vstoxxt+omo2+l1, data=axx) summary(reg1) 

and dynlm:

zoox = zoo(test[, -1]) lmx <- dynlm(d(euribor3)~d(ois3)+d(cds)+d(eurepo3-ois3)+d(vstoxx)+d(log(open.market.operations))+d(l(euribor3, 1)), data=zoox) summary(lmx) 

these 2 approaches give me exact same output. if add subset both regressions 1 24 (all else equal):

euribor3t <- ts(diff(euribor3)) ois3t <- ts(diff(ois3)) x <- ts(diff(eurepo3-ois3)) vstoxxt <- ts(diff(vstoxx)) cdst <- ts(diff(cds)) omo2 <- ts(diff(log(open.market.operations))) l1 <- (lag(euribor3t, k=-1)) axx <- ts.intersect(euribor3t, ois3t, x, vstoxxt, cdst, omo2, l1) reg1 <- lm(euribor3t~ois3t+cdst+x+vstoxxt+omo2+l1, data=axx, subset=1:24) summary(reg1)  zoox = zoo(test[, -1]) lmx <- dynlm(d(euribor3)~d(ois3)+d(cds)+d(eurepo3-ois3)+d(vstoxx)+d(log(open.market.operations))+d(l(euribor3, 1)), data=zoox[1:24]) summary(lmx) 

the 2 outputs differ each other. might problem causing deviation in regression outputs?

here data sample experimented with:

    date    euribor3    ois3    eurepo3 vstoxx  cds open.market.operations 1   03.01.2005  2.154   2.089   2.09    14.47   17.938  344999 2   04.01.2005  2.151   2.084   2.09    14.51   17.886  344999 3   05.01.2005  2.151   2.087   2.08    14.42   17.950  333998 4   06.01.2005  2.150   2.085   2.08    13.80   17.950  333998 5   07.01.2005  2.146   2.086   2.08    13.57   17.913  333998 6   10.01.2005  2.146   2.087   2.08    12.92   17.958  333998 7   11.01.2005  2.146   2.089   2.08    13.68   17.962  333998 8   12.01.2005  2.145   2.085   2.08    14.05   17.886  339999 9   13.01.2005  2.144   2.084   2.08    13.64   17.568  339999 10  14.01.2005  2.144   2.085   2.08    13.57   17.471  339999 11  17.01.2005  2.143   2.085   2.08    13.20   17.365  339999 12  18.01.2005  2.144   2.085   2.08    13.17   17.214  347999 13  19.01.2005  2.143   2.086   2.08    13.63   17.143  354499 14  20.01.2005  2.144   2.087   2.08    14.17   17.125  354499 15  21.01.2005  2.143   2.087   2.08    13.96   17.193  354499 16  24.01.2005  2.143   2.086   2.08    14.11   17.283  354499 17  25.01.2005  2.144   2.086   2.08    13.63   17.083  354499 18  26.01.2005  2.143   2.086   2.08    13.32   17.348  347999 19  27.01.2005  2.144   2.085   2.08    12.46   17.295  352998 20  28.01.2005  2.144   2.084   2.08    12.81   17.219  352998 21  31.01.2005  2.142   2.084   2.08    12.72   17.143  352998 22  01.02.2005  2.142   2.083   2.08    12.36   17.125  352998 23  02.02.2005  2.141   2.083   2.08    12.25   17.000  357499 24  03.02.2005  2.144   2.088   2.08    12.38   16.808  357499 25  04.02.2005  2.142   2.084   2.08    11.60   16.817  357499 26  07.02.2005  2.142   2.084   2.08    11.99   16.798  359999 27  08.02.2005  2.141   2.083   2.08    11.92   16.804  355500 28  09.02.2005  2.142   2.080   2.08    12.19   16.589  355500 29  10.02.2005  2.140   2.080   2.08    12.04   16.500  355500 30  11.02.2005  2.140   2.078   2.08    11.99   16.429  355500 31  14.02.2005  2.139   2.078   2.08    12.52   16.042  355500 

you not allowing dynlm use same amount of data in lm. latter model contains 2 fewer observations.

dim(model.frame(reg1)) # [1] 24  7 dim(model.frame(lmx)) # [1] 22  7 

the reason withlm transforming variables (differencing) entire data set (31 observations), while in dynlm passing 24 observations and, hence, dynlm differencing 24 observations. due observations lost after differencing, resulting number of rows not same in both cases.

in dylm should use data=zoox[1:26]. in way same subset used , same result obtained:

reg1 <- lm(euribor3t~ois3t+cdst+x+vstoxxt+omo2+l1, data=axx, subset=1:24) lmx <- dynlm(d(euribor3)~d(ois3)+d(cds)+d(eurepo3-ois3)+d(vstoxx)+   d(log(open.market.operations))+d(l(euribor3, 1)), data=zoox[1:26]) all.equal(as.vector(fitted(reg1)), as.vector(fitted(lmx))) # [1] true all.equal(coef(reg1), coef(lmx), check.attributes=false) # [1] true 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -