Calculation of level fitted values doesn't seem to be correct

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Calculation of level fitted values doesn't seem to be correct

agarwaldvk
Hi Guys

I have a time series regression like so :-

dlmres <- dynlm(dusage ~ L(dusage, 1:5))

The regression output is shown below :-

Time series regression with "ts" data:
Start = 6, End = 364

Call:
dynlm(formula = dusagets ~ (L(dusagets, 1:5)))

where dusage refers to the first difference series of the usage series.

Residuals:
    Min      1Q  Median      3Q     Max
-6915.9  -748.9    20.7   822.1  6099.6

Coefficients:
                   Estimate Std. Error t value Pr(>|t|)    
(Intercept)       -41.24158   88.26414  -0.467 0.640608    
L(dusagets, 1:5)1  -0.19753    0.05231  -3.776 0.000187 ***
L(dusagets, 1:5)2  -0.43436    0.05311  -8.179 5.22e-15 ***
L(dusagets, 1:5)3  -0.15207    0.05729  -2.654 0.008305 **
L(dusagets, 1:5)4  -0.14216    0.05292  -2.687 0.007561 **
L(dusagets, 1:5)5  -0.17909    0.05243  -3.415 0.000711 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1671 on 353 degrees of freedom
Multiple R-squared:  0.1858, Adjusted R-squared:  0.1743
F-statistic: 16.11 on 5 and 353 DF,  p-value: 2.602e-14

The fitted values from this regression is for the first difference series. I tried to calculate the level fitted values using the cumsum() function in R. The fitted values start from 7th observation as 6 observations are lost from 5 lags of the difference series. The attached file shows a small subset of observed, fitted values from R and computed level fitted values

For example, to calculate the fitted level value for interval 10
L1Fitted_Int10 <- cumsum(7 : 10) + usage[6]
L1Fitted_Int11 <- cumsum(7 : 11) + usage[6]
L1Fitted_Int12 <- cumsum(7 : 12) + usage[6]
L1Fitted_Int13 <- cumsum(7 : 13) + usage[6]

Going down to interval 210 and beyond, the level fitted values seem to diverge massively from the actual usage values. I am presuming that this is because something doesn't appear to be correct in my computation using the cumsum() function + usage[6] value

I tested with the actual usage values and it works perfectly for every single value.

Can some one help me identify where am I going wrong in my computation.


Best regards


Deepak

Data_For_Nabble.TXT
Reply | Threaded
Open this post in threaded view
|

Re: Calculation of level fitted values doesn't seem to be correct

GregChapman
I think you've posted to the wrong forum.

This is for solving issues with Nabble applications.
Just a Volunteer Nabble Helper - because the nice folk at Nabble have helped me!
GregHelp - Building a set of answers to Nabble FAQs.