Description Usage Arguments Value Author(s)
Given a dataframe containing a target and covariates, createcorlag
returns a dataframe containing all the variables and only the lagged variables whose absolute pairwise correlation with the target exceeds a fixed threshold. Lag function is applied by groups. Additional variables
that should not be lagged can be provided.
1 2 | createcorlag(df, refvar="incidence", groupingvar = c("sex","age","Country_Transco"), k = 1, cross_cor_threshold=0.2,
labelvar = c("year", "Zonier"))
|
df |
Dataframe whose variables must be lagged |
refvar |
Reference variable or target from which to compute the cross correlation with other lagged variables |
cross_cor_threshold |
Correlation threshold required to keep a lag |
groupingvar |
Variables used to define group |
k |
Maximum lag that must be computed. If k>1, lags 1:k are computed |
labelvar |
Variables that should not be lagged |
A dataframe with non lagged and lagged observations -whose absolute correlation with the target exceeds the selected threshold- by groups.
Benjamin Schannes
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.