View source: R/dthelper-computation-functions.R
abstract.regression | R Documentation |
Perform linear regressions given an abstract formulae. This is especially useful for regressing variables over time. Say we have a variable called e in our data that is indexed based on time, e1, e2, e3, etc (this assumes our data is in wide format). We can use the abstract formulae "e{X} ~ e{X-1}" to use e at previous timepoints to predict e at the next time step. Typically, we get a single estimate of this relationship (or autocorrelation). However, abstract regression runs a regression separately at each timestep, for e1 ~ e2, then e2 ~ e3, etc. To use this function, simply replace the index of your variable of interest with the symbol "X". The are necessary if any computations such {X+1} or {X-2} are used
abstract.regression(form, df)
form |
Input formulae string. |
df |
data.frame object |
data.frame object
df <- data.frame( x = rnorm(10), e1 = rnorm(10), e2 = rnorm(10), e3 = rnorm(10), e4 = rnorm(10) ) abstract.regression("e{X} ~ e{X-1}", df) abstract.regression("e{X} ~ e{X-1} + x", df) abstract.regression("e{X} ~ e{X-1} * x", df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.