Description Usage Arguments Examples
Plot the coefficients resulting from an EMD-regression acording to the mean period of the corresponding IMFs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
x |
The coefficient matrix to plot. Can also contain sensitivities
(see |
periods |
Matrix containting the mean period of IMFs correspondind to
the coefficients in |
lower, upper |
Matrices containing lower and upper confidence limits. |
ci.args |
A list of arguments to be passed to the function
|
period.log2 |
Logical. If TRUE, a log2 transformation is applied to the x axis. |
trend.label |
The label to be displayed for the trend component's coefficient. |
show.coef |
Character giving restrictions for the coefficients to draw.
|
col, pch |
color and point type for drawn coefficients. If matrices one value corresponds to one coefficient and if vectors a value per variable is used. |
line.pars |
List of parameters for the line separating the trend
coefficients from the other. See |
... |
Other arguments to be passed to the plot. See
|
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | ## EMD-R1
library(dlnm)
library(glmnet)
# 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)
## EMD-R2
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"))
# EMD-R2 with glm
lm.R2 <- emdr2(death ~ temp + rhum, mimf = cmimfs)
betas.R2 <- coef(lm.R2)
amps <- mean_amplitude(cmimfs)
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.