Application of R language dlnm package in distributed lag linear and nonlinear models of time series data (1)

The lagged nature of temperature effects on health is well established. This issue uses the dlnm package to introduce the application of the dlnm package in the distribution lag linear and nonlinear models of time series data. The Dlnm package performs analysis by constructing a cross-base matrix.
insert image description here
We continue to use the data of air pollution and death in Chicago, USA from 1987 to 2000 (official account reply: Chicago 3, data can be obtained) for example analysis, let's first import the required R package and data to see

library(dlnm)
library(splines)
library(tsModel)
bc<-read.csv("E:/r/test/chicago3.csv",sep=',',header=TRUE)

insert image description here
Let's take a look at the composition of the data first, death: number of deaths (per day), pm10: median value of air pollutant pm10, o3median: median value of ozone, time: number of days, here is our time, tmpd: Fahrenheit temperature, date: date
Suppose we need to study the impact of pm10 concentration changes on death, and we want to use temperature as an adjustment factor, so we need to design a matrix of two cross-bases. Let me explain the Crossbasis function. The first parameter x is used to specify the vector sequence. Fill in bc$pm10 here, and lag here indicates the number of lag days. Fill in 15 days. The two functions argvar and arglag will transfer the data Pass it to a onebasis function to generate a predicted matrix. Here, it is assumed that the impact of pm10 on the outcome is linear, using fun="lin", followed by a polynomial function fun="poly", and the degree of freedom is set to 4. If we do not choose fun, the function defaults to fun="ns", the following temperature is like this, we can also choose a temperature reference value, such as we choose 21 degrees, argvar = list(fun = "ns", df =3, cen =21). "strata" means stratification, because we set a lag of 3 days, so breaks=1, is to divide the temperature into two lag layers (0-1 and 1-3) and two lag layers.

cb1.pm <- crossbasis(bc$pm10, lag=15, argvar=list(fun="lin"),
                     arglag=list(fun="poly",degree=4))
cb1.temp <- crossbasis(bc$temp, lag=3, argvar=list(df=5),
                       arglag=list(fun="strata",breaks=1))
我们summmary cb1.pm一下看看

insert image description here
After generating two cross basis matrices, the prediction model can be generated.

model1 <- glm(death ~ cb1.pm + cb1.temp + ns(time, 7*14) + dow,
                family=quasipoisson(), chicagoNMMAPS)

Generate forecast data for cb1.pm

pred1.pm <- crosspred(cb1.pm, model1, at=0:20, bylag=0.2, cumul=TRUE)

at=0:20 means that the forecast must be calculated for each integer value from 0 to 20 µgr/m 3 , by setting bylag=0.2 the forecast is calculated along the lag space in increments of 0.2. The increment is 0.2. This finer mesh is to produce a smoother lag curve when plotting the results. If the parameter cen is not set, the default reference value is 0.
After generating the forecast data, you can draw. First, draw a graph of the relationship between pm10 lag and death. "slices" indicates the type of drawing, and var=10 indicates the relationship. If not set The reference value is 0 as the reference. Var setting must be in the "slices" type. ci.arg is used to draw confidence intervals.

plot(pred1.pm, "slices", var=10, col=3, ylab="RR", ci.arg=list(density=15,lwd=2),
     main="Association with a 10-unit increase in PM10")

insert image description here
This figure shows the lagged association of a 10 µgr/m increase in PM10 with mortality. The hysteresis curve represents the increased risk for each future day following a 10-microgram increase. The hysteresis curve indicates that after a PM10 increase of 10 µgr/m 3 on a certain day, the risk of each future day increases, or the contribution of the PM10 increase of each past day to the risk of a certain day.
Next draw a risk map of the cumulative increase in pm10,

plot(pred1.pm, "slices", var=10, col=2, cumul=TRUE, ylab="Cumulative RR",
     main="Cumulative association with a 10-unit increase in PM10")

insert image description here
The figure shows that the initial risk increase for PM10 is reversed over longer lags. The relevant data can be extracted using allRRfit, allRRhigh and allRRlow.

Guess you like

Origin blog.csdn.net/dege857/article/details/129694041