Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I have two timeseries, y[t] and x[t]. A domain expert tells me that y[t] should be a linear combination of past values of x[t] up to a certain horizon, i.e.

y[t] = a[0]*x[t] + a[1]*x[t-1] + ... + a[n]*x[t-n]

How do I estimate the a[i] coefficients in R? Indeed, what is the proper name for this kind of model?

share|improve this question

1 Answer

It is called distributed lag model. The model from of your example can be estimated with simple linear regression. You can use dynlm package for easier lag handling:

> library(dynlm)
> n<-4 ##Number of lag used in a model
> data("USDistLag", package = "lmtest")
> dynlm(consumption~L(gnp,0:4))

Time series regression with "ts" data:
Start = 1967, End = 1982

Call:
dynlm(formula = consumption ~ L(gnp, 0:4), data = USDistLag)

Coefficients:
        (Intercept)  L(gnp, 0:4)Series 1  L(gnp, 0:4)Series 2  L(gnp, 0:4)Series 3  
          -30.54113              0.46253              0.09632             -0.06309  
L(gnp, 0:4)Series 4  L(gnp, 0:4)Series 5  
            0.13511              0.03176  
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.