I am trying to understand how one would go about setting up a regression model, including construction of the data matrix, when you have a response variable y that experiences lagged effects from a single predictor variable x; for example, modelling the expected impact on blood glucose levels over time based on one dose of insulin. I imagine dummy coding of the time intervals into dichotomous variables could be a place to start but I am not sure. I am experienced with regression using paired observations but not so much with this example. Thank you!
1 Answer
$\begingroup$
$\endgroup$
If you know how many lags you want to include, why don't you just include them as regressors? In R there is a useful function embed
that produces a matrix of lags of variable. That matrix could be used as the design matrix.
embed
that produces a matrix of lags of variable. That matrix could be used as the design matrix. (My background is in financial or macroeconomic time series, so I might be missing some peculiarity of your setting.) $\endgroup$