# [R] Simple DLNM in R

Dan Vecellio djv5030 at gmail.com
Mon Dec 7 02:47:12 CET 2015

```Hello, first time poster so forgive any mistakes.

I have limited familiarity with R, but am working on a project to find the
relative risk of mortality due to changes in diurnal temperature range.
What I am trying to do is find the relative risk of mortality at the 10th,
50th and 90th percentiles of diurnal temperature range and its additive
effects at lags of 0, 1, 3 and 5 days. I'm doing this for a subset of
months May-Sept (I call the subset here for mortality, temperature is
already subsetted when read in). I have a code that works below, but no
matter what city and what lag I introduce, I get a RR of essentially 1.0,
so I believe that something is off or I am missing an argument somewhere.
If anyone has more experience with these problems than I, your help would
be greatly appreciated. Code is below:

library('dlnm')
library('splines')

morts <- subset(mortdata, Month %in% 5:9)
deaths <- morts\$AllMort
temp <- tempdata\$Trange
HI <- tempdata\$HIrange
#basis.var <- onebasis(1:5, knots=3)#mklagbasis(maxlag=5, type="poly",
degree=3)
basis.temp <- crossbasis(temp,vardegree=3,lag=5)
summary(basis.temp)
model <- glm (deaths ~ basis.temp, family=quasipoisson())
pred.temp <- crosspred(basis.temp, model,
at=quantile(temp,c(.10,.50,.90),na.rm=TRUE) , cumul=T)
plot(pred.temp, "slices", var=c(quantile(temp, c(.10, .50,
.90),na.rm=TRUE)) ,lag=c(0,1,5))

--
Daniel J. Vecellio

PhD Student, Department of Geography
Texas A&M University

[[alternative HTML version deleted]]

```