Description Usage Arguments Value References Examples
Prepare a data.frame to be used in a regression function for EMD-R1, including the predictors MIMF and the response.
1 2 3 4 5 6 7 8 9 |
x |
|
y |
Vector containing the response variable of the regression. |
covariates |
List containing eventual covariates to be added to the output data.frame. |
tt |
Vector of custom time indices. Useful to lag irregular time series. |
lag |
Vector of lagging values for the IMFs in |
lag.max |
The maximum lag to consider in the automatic lag choice. See
|
fill.na |
Logical indicating if irregularly sampled IMFs should be filled with NAs. This function take a Also allows the inclusion of non-IMF predictors in |
A data.frame containing all necessary variables for a regression
function. The first column contains the response vector y. The
following columns contain the IMFs to be used and the last columns
contain the eventual covariates.
Masselot, P., Chebana, F., Belanger, D., St-Hilaire, A., Abdous, B., Gosselin, P., Ouarda, T.B.M.J., 2018. EMD-regression for modelling multi-scale relationships, and application to weather-related cardiovascular mortality. Science of The Total Environment 612, 1018-1029.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | library(dlnm)
# Predictor decomposition
X <- chicagoNMMAPS[,c("temp", "rhum")]
set.seed(123)
mimfs <- memd(X, l = 2) # Takes a couple of minutes
cmimfs <- combine.mimf(mimfs, list(10:11, 12:13),
new.names = c("C10", "C11"))
# Response variable
Y <- chicagoNMMAPS$resp[attr(cmimfs, "tt")]
# Data preparation: includes the day-of-week variable as potential
# confounder
dataR1 <- pimf(cmimfs, Y, covariates = list(dow =
chicagoNMMAPS$dow[attr(cmimfs, "tt")]))
# Apply the Lasso
library(glmnet)
lasso.res <- cv.glmnet(data.matrix(dataR1[,-1]), dataR1[,1],
family = "poisson")
# Compute sensitivity and plot results
amps <- mean_amplitude(dataR1[,2:25])
betas <- coef(lasso.res)
s <- sensitivity(amps, coefs = betas[2:25])
plot_emdr(matrix(s, ncol = 2, byrow = FALSE), periods = period(cmimfs),
show.coef = "nonzero", col = c("red", "blue"), pch = 16:17)
abline(h = 0, lty = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.