emdr2: EMD-R2

Description Usage Arguments Details Value References See Also Examples

View source: R/emdr2.R

Description

Performs EMD-R2 by using the given regression function in each MIMF.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
emdr2(
  formula,
  mimf,
  covariates = NULL,
  tt = attr(mimf, "tt"),
  reg.fun = "glm",
  reg.args = list(),
  pimf.args = list(),
  xy.args = c("x", "y")
)

Arguments

formula

A formula describing the models to be fit for each MIMF.

mimf

mimf object containing both the response and predictor IMFs.

covariates

A list or data.frame containing eventual covariates which are not IMFs.

tt

A vector of time indices for mimf. The default is to use the tt attribute.

reg.fun

The regression function to perform either as a function or as a character. Should include formula and data arguments.

reg.args

A list containing additional arguments to be passed to reg.fun.

pimf.args

A list of arguments to be passed to the function pimf to prepare the IMFs for the regression.

xy.args

A character vector of length two indicating the argument names corresponding to the predictors and response in the case reg.fun does not include arguments formula and data. The default of xy.args = c("x", "y") should cover the majority of cases.

Details

emdr2 wraps the chosen regression function (reg.fun), and applies it once per MIMF in mimf. Variables given in covariates are used with each IMF.

reg.fun can include either a couple formula and data arguments, either x and y arguments. Particular argument names for the response or predictor variables can be given in xy.args.

Value

A emdr2 object which is a list of length nimf containing all results of reg.fun on individual MIMFs.

References

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.

See Also

extract.emdr2 to extract a particular element of the result from reg.fun for each submodel. coef.emdr2 to specifically extract the coefficients. predict.emdr2 to obtain predictions from the whole EMD-R2 model.

Examples

 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
 
   library(dlnm)
   library(glmnet)

   dat <- chicagoNMMAPS[,c("death", "temp", "rhum")]

   mimfs <- memd(dat)
   cmimfs <- combine.mimf(mimfs, list(12:13, 14:17, 18:19), 
     new.names = c("C12", "C13", "r"))
   amps <- mean_amplitude(cmimfs)

   # EMD-R2 with glm
   lm.R2 <- emdr2(death ~ temp + rhum, mimf = cmimfs)
   betas.R2 <- coef(lm.R2)
   sensitivity.R2 <- sensitivity(amps[,-1], coefs = betas.R2[,-1])
   plot_emdr(sensitivity.R2, periods = period(cmimfs)[,-1],  
     col = c("red", "blue"), pch = 16:17)
   abline(h = 0, lty = 2)
   
   # EMD-R2 with lasso
   lasso.R2 <- emdr2(death ~ temp + rhum, mimf = cmimfs, 
     reg.fun = "cv.glmnet")
   betas.R2 <- coef(lasso.R2, s = "lambda.1se")
   sensitivity.R2 <- sensitivity(amps[,-1], coefs = betas.R2[,-1])
   plot_emdr(sensitivity.R2, periods = period(cmimfs)[,-1], 
     show.coef = "nonzero", pch = 16:17)
   abline(h = 0, lty = 2)
 

PierreMasselot/Library--emdr documentation built on June 19, 2021, 8:58 a.m.