Title: | Visualization the Effects of Collinearity in Distributed Lag Models and Other Linear Models |
---|---|
Description: | Tool to assessing whether the results of a study could be influenced by collinearity. Simulations under a given hypothesized truth regarding effects of an exposure on the outcome are used and the resulting curves of lagged effects are visualized. A user's manual is provided, which includes detailed examples (e.g. a cohort study looking for windows of vulnerability to air pollution, a time series study examining the linear association of air pollution with hospital admissions, and a time series study examining the non-linear association between temperature and mortality). The methods are described in Basagana and Barrera-Gomez (2021) <doi:10.1093/ije/dyab179>. |
Authors: | Jose Barrera-Gomez [aut, cre]
|
Maintainer: | Jose Barrera-Gomez <[email protected]> |
License: | GPL-3 |
Version: | 0.0.4 |
Built: | 2025-01-29 05:29:00 UTC |
Source: | https://github.com/cran/collin |
Simulates results from a distributed lag model under an hypothetical effect
pattern provided by the user, which can be linear or non-linear. The output
is the passed to the plot
method to visualize consequences of
collinearity.
collindlnm( model, x, cb, at = 1, cen = 0, effect, type = c("coef", "risk"), shape = c("linear", "nonlinear"), nsim = 100, verbose = TRUE, seed = NULL )
collindlnm( model, x, cb, at = 1, cen = 0, effect, type = c("coef", "risk"), shape = c("linear", "nonlinear"), nsim = 100, verbose = TRUE, seed = NULL )
model |
a model that includes a crossbasis. Currently, models allowed are those
of class |
x |
if |
cb |
an object of class |
at |
the increase(s) in the predictor under study to be considered to report the
effects of the variable. If |
cen |
a number. Reference value of the predictor under study, used to calculate
effects. If |
effect |
a vector or a matrix, depending on |
type |
a character. If |
shape |
the shape of the relationship between the linear predictor of the model
and the outcome. Default is |
nsim |
number of simulations. Default is 100. |
verbose |
a logical value indicating output status messages. Default is |
seed |
a number. Seed for reproducibility of results. Default is |
A list including the results of the simulations to be passed to the plot
method.
crossbasis
, glm
,
lme
.
# For detailed examples: browseVignettes("collin")
# For detailed examples: browseVignettes("collin")
Function to get a vector lagged.
lagpad(x, k)
lagpad(x, k)
x |
numeric vector to be lagged. |
k |
number of lags to be applied. |
A lagged vector.
Simulated data for repeated measures of working memory test scores and
residential PM levels in 2,221 children.
mempm25
mempm25
A data frame with 8,884 rows and 17 variables:
individual identifier
test session identifier
chool identifier
sex of individual
age of individual, centered at the mean, in years
maternal education
residential neighborhood socioeconomic status indicator
estimated average concentration of PM
(
g/m
) at residence address during pregnancy
estimated average concentration of PM
(
g/m
) at residence address during year 1
estimated average concentration of PM
(
g/m
) at residence address during year 2
estimated average concentration of PM
(
g/m
) at residence address during year 3
estimated average concentration of PM
(
g/m
) at residence address during year 4
estimated average concentration of PM
(
g/m
) at residence address during year 5
estimated average concentration of PM
(
g/m
) at residence address during year 6
estimated average concentration of PM
(
g/m
) at residence address during year 7
weight of the observation
working memory test score
This is a synthetic dataset generated with the synthpop
package, based on
a cohort study of children examining the association between PM
concentrations during the prenatal period and the first seven postnatal years on
cognitive tests taken at age 8 (see ‘References’).
See ‘References’.
Rivas I et al. Association between Early Life Exposure to Air Pollution and Working Memory and Attention. Environmental Health Perspectives. 2019;127(5):57002. doi: 10.1289/EHP3169.
# correlation of air pollution levels between two different periods: pm25yearly <- mempm25[, grep("pm25", names(mempm25))] print(cor(pm25yearly, use = "complete.obs"), digits = 2)
# correlation of air pollution levels between two different periods: pm25yearly <- mempm25[, grep("pm25", names(mempm25))] print(cor(pm25yearly, use = "complete.obs"), digits = 2)
Visualize the results from a distributed lag model under an hypothetical
linear effect pattern provided by the user, generated using the function
collindlnm
.
## S3 method for class 'collindlnmlinear' plot(x, lags = NULL, ...)
## S3 method for class 'collindlnmlinear' plot(x, lags = NULL, ...)
x |
an object of class |
lags |
a number or a numeric vector indicating at what lags the results
will be visualized. Default ( |
... |
other parameters to be passed through to plot function. |
A plot showing a comparison between the results under the fitted model and the results under the hypothetical true effect.
collindlnm
, plot.collindlnmnonlinear
.
# For detailed examples: browseVignettes("collin")
# For detailed examples: browseVignettes("collin")
Visualize the results from a distributed lag model under an hypothetical
non-linear effect pattern provided by the user, generated using the function
collindlnm
. The number of plots shown is equal to the number
of values passed by at
in the function collindlnm
.
The way in which these plots are displayed is controlled by the user through
the argument show
.
## S3 method for class 'collindlnmnonlinear' plot( x, lags = NULL, show = c("manual", "auto", "sequence"), addlegend = TRUE, varlegend = NULL, ... )
## S3 method for class 'collindlnmnonlinear' plot( x, lags = NULL, show = c("manual", "auto", "sequence"), addlegend = TRUE, varlegend = NULL, ... )
x |
an object of class |
lags |
a number or a numeric vector indicating at what lags the results
will be visualized. Default ( |
show |
character indicating how the multiple plots will be shown. If
|
addlegend |
logical indicating whether a legend indicating at what
value (of |
varlegend |
character indicating the label for the explored variable to be shown in the legend. |
... |
other parameters to be passed through to plot function. |
A plot showing a comparison between results under the fitted model and the results under the hypothetical true effect, for each of the different values of the variable of interest where effects were explored.
collindlnm
, plot.collindlnmlinear
.
Simulated data for daily measures of hospital admissions for respiratory causes
count and ambient air NO concentrations during 10 years.
rhospno2
rhospno2
A data frame with 3,652 rows and 7 variables:
date of the observation
numerical indicator of date
year indicator
day of week
ambient temperature in Celsius degrees
NO concentration in
g/m
number of hospital admissions for respiratory causes
This is a synthetic dataset generated with the synthpop
package, based on
true data on daily number of hospital admissions for respiratory causes and
ambient air NO concentrations in the city of Barcelona (Spain) for years
2006-2015.
# time series: par(las = 1, mfrow = c(3, 1)) with(rhospno2, plot(date, hresp, type = "l", lwd = 0.5)) with(rhospno2, plot(date, no2, type = "l", lwd = 0.5)) with(rhospno2, plot(date, temp, type = "l", lwd = 0.5))
# time series: par(las = 1, mfrow = c(3, 1)) with(rhospno2, plot(date, hresp, type = "l", lwd = 0.5)) with(rhospno2, plot(date, no2, type = "l", lwd = 0.5)) with(rhospno2, plot(date, temp, type = "l", lwd = 0.5))
Simulation procedure internally called by the collindlnm
function for a given hypothetical effect.
simulatedlnm(x) ## S3 method for class 'linearlme' simulatedlnm(x) ## S3 method for class 'linearglm' simulatedlnm(x) ## S3 method for class 'nonlinearglm' simulatedlnm(x)
simulatedlnm(x) ## S3 method for class 'linearlme' simulatedlnm(x) ## S3 method for class 'linearglm' simulatedlnm(x) ## S3 method for class 'nonlinearglm' simulatedlnm(x)
x |
an object internally generated by the |
simulatedlnm(linearlme)
: case of a hypothetical linear effect in a model of
class "lme"
.
simulatedlnm(linearglm)
: case of a hypothetical linear effect in a model of
class "glm"
.
simulatedlnm(nonlinearglm)
: case of a hypothetical non-linear effect in a model
of class "glm"
.