1
$\begingroup$

I am trying to apply GAM Model on one Health Claims Dataset (from 2007 to 2018), trying to find the association between daily hospital admissions of heart diseases) and temperature.

all: daily number of hospital admissions, which assumed to follow quasi-Poisson distribution

tmk_mw: temperature

ndate: date, for example 01-01-2017

doy: day of the month

week: a dummy variable for day of the week

vor_nach_2012: categorical variable; 0: before 2012 1:after 2012 (because the daily number of hospital admission have a clear increase after year 2012,from 2012 to 2018 the daily number is obviously higher)

mod2 <-  gam(all ~ s(tmk_mw) + s(ndate) +  te(doy, ndate, 
    bs = c("cc", "tp"), k=c(20,30)) +  s(nyear) + s(nmonth) + 
       week + vor_nach_2012,  data=mydata,method = "REML",
       family = quasipoisson)

summary(mod2)

enter image description here

It seems that the variable temperature is not significant. How should I revise the model?

enter image description here

plot(mod2,all.terms = TRUE,residuals = TRUE, pages =1)

enter image description here

Then I plotted the fitted value as well

pdata <- mutate(mydata, myfitted = predict(mod2))

ggplot(pdata, aes(x = ndate,y = all)) + 
   geom_point() + geom_line(aes(y = exp(myfitted)), 
   col = 'red')

enter image description here

The purpose here is to quantify the exposure-response relationship between temperature and daily hospital admissions.

The graphic shows the relationship between Relative Risk and temperature. How can we create a graphic like this after we fit our GAM model with function from mgcv or other package?
enter image description here

$\endgroup$
6
  • 1
    $\begingroup$ I would also help to see how you fitted your GAM; what you are showing likely isn't possible with a GAM (unless you did something very unusual) so it could just be an issue with the visualization. It is impossible to help you with what information you have given us in this question. $\endgroup$ Commented Oct 20, 2021 at 8:54
  • $\begingroup$ Thanks @GavinSimpson I used the function exp() on my fitted value. Because i assumed a quasi-Poisson distribution, and y = ln(µ) . i revised my question and added more imformation $\endgroup$
    – Thomas
    Commented Oct 20, 2021 at 15:16
  • 1
    $\begingroup$ Thomas, many users might reflexively vote to close this post, because it asks how to do something in R (apparently a software-only question), I think there nevertheless is an underlying statistical question: namely, what does that last plot (of relative risk vs. a single explanatory variable) represent and how is such a plot created generally, regardless of the software environment. Consider including this clarification in your post. $\endgroup$
    – whuber
    Commented Oct 20, 2021 at 15:23
  • $\begingroup$ thanks for the comment and advice. @whuber. i revised the question. acutally i am trying to figure out how to generate that Relative Risk graphic with mgcv Package. $\endgroup$
    – Thomas
    Commented Oct 20, 2021 at 15:41
  • $\begingroup$ The obvious problem is that you’re plotting the predicted values for all the observed data and not a smooth grid over the covariate of interest. But I think a more general problem is that you aren’t decomposing the time information into different components of temporal variation. I’m traveling for most of today but I’ll take a closer look later if no one has answered by the $\endgroup$ Commented Oct 21, 2021 at 7:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.