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:
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)),
my doubts are :
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
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.