[R] Simple DLNM in R

John Kane jrkrideau at inbox.com
Mon Dec 7 13:22:27 CET 2015

Welcome to the list. 

You have provided a nic clear question but I think the one thing missing in dealing with it is  some sample data. 

Have a look at ?dput or see the dput() discussions in one of these links : http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and/or http://adv-r.had.co.nz/Reproducibility.html

Someone may easily find the problem without sample data but it usually is best to troubleshoot with the "real" data.

John Kane
Kingston ON Canada

> -----Original Message-----
> From: djv5030 at gmail.com
> Sent: Sun, 6 Dec 2015 19:47:12 -0600
> To: r-help at r-project.org
> Subject: [R] Simple DLNM in R
> 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')
> mortdata <- read.table('STLmort.txt', sep="\t", header=T)
> morts <- subset(mortdata, Month %in% 5:9)
> deaths <- morts$AllMort
> tempdata <- read.csv('STLRanges.csv',sep=',',header=T)
> 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]]
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!

More information about the R-help mailing list