1
$\begingroup$

I am using the dlnm package to build a finite distribute lag linear model. I intend on testing the model-fit based on various lag levels to assess which lag is suitable. Needless to mention I will apply some domain knowledge to make a good call. I am using these two available resources to carry out this rather complex exercise: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3191524/

http://cran.r-project.org/web/packages/dlnm/vignettes/dlnmOverview.pdf

I first created a Matrix to include non-linear effects of both my predictors using this: ImpressionsA.x<-onebasis(locanatmodelset$ImpressionsA.x, fun="poly", degree=2) ImpressionsA.y<-onebasis(locanatmodelset$ImpressionsA.y, fun="poly", degree=2)

Since my non-linear relationship is tending to be quadratic, I am using 2nd degree polynomials. Now I need to factor in the lags for each variable by calling crossbasis. This is where I am confused. The function as per the package documentation is of the format: cb <- crossbasis(chicagoNMMAPS$temp,lag=30,argvar=list("thr",thr.value=c(10,20)), arglag=list(knots=c(1,4,12)))

my doubts are :

1) in lag=30 is 30 of the same units as my response variable or will it be in the units of my predictor variable? In my case, my lag is specified in days. I want to specify 5 days as lag before fitting the model. How should I pass the argument?

2) Since I have already created my basis matrix for predictor variables using onebasis, how should I pass the arguments argvar and arglag?

3) I also wanted to extract the lagged values of my predictor variables (ImpressionsA.x and ImpressionsA.y) in their original units. The matrix itself is not helpful. It transforms everything into negative values on some other scale all together.

$\endgroup$
8
  • $\begingroup$ The $y=x1*x2$ formula is shorthand for $y=x1+x2+x1:x2$. That is, it introduces the interaction between the two variables. Not sure if you're confusing autocorrelation and correlation: autocorrelation is correlation of a variable with lagged versions of itself. ("Auto" = "Self") $\endgroup$
    – Wayne
    Jul 25 '14 at 14:26
  • $\begingroup$ thanks Wayne. Apologies for wrong usage of concepts & terms. I am reading ncbi.nlm.nih.gov/pmc/articles/PMC3191524 and its very insightful on how dlnm should be used for lag models. I might self answer after reading it. $\endgroup$
    – vagabond
    Jul 25 '14 at 14:33
  • $\begingroup$ @Wayne I've made edits based on my progress with the work so far. $\endgroup$
    – vagabond
    Jul 27 '14 at 19:42
  • $\begingroup$ You mention that you are doing a "finite distribute lag linear model". Has an "infinite" DLNM ever been proposed? $\endgroup$
    – zkurtz
    Jul 29 '14 at 17:38
  • $\begingroup$ Please look up Koyck Model or Geometric Lags. $\endgroup$
    – vagabond
    Jul 29 '14 at 17:40
1
$\begingroup$

This answer will likely be an iterative process, because you may want to rephrase your question as things become more clear.

1) In your usage, the first argument to crossbasis is a vector. According to ?crossbasis, as a vector it needs to represent "a complete series of ordered observations". You said that your time units are days. Thus, presumably, lag = 30 means that you'll be looking back 1 day, 2 days, ..., 30 days simultaneously. With dlnm, you never fit individual lags. You fit the whole range of lags. If you are particularly interested in the 5th lag, maybe you want to use lag = 8 or so and then see if the estimated effect for the fifth lag stands out as being bigger than the effects for the other lags. NOTE: The whole idea of the word "distributed" in dlnm is that the lagged effect of a variable is literally distributed across several lags, or even fractions of lags.

2) The crossbasis function does not accept the output of onebasis as an argument; it's just not set up that way. Instead, you pass in your arguments to onebasis through argvar=list(), arglag=list() in crossbasis, which calls onebasis internally. In particular, if you do crossbasis(locanatmodelset$ImpressionsA.x, lag = 8,..., then crossbasis will actually go and call onebasis two times, once to make a basis for locanatmodelset$ImpressionsA.x and once to make a basis for the lags [0,1, ...,8].

3) Clarify what you mean here. If you want to "extract the lagged value" of any vector element, say the kth element of a vector x, you just do x[k-L] to get the Lth lag. No special R package is necessary.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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