Eren Yalın
2023-Dec-06 13:52 UTC
[R] How to calculate relative risk from GAM model in mgcv package?
Hi R users,I am a beginner in the use of R. I need urgent help for my thesis study. <https://stats.stackexchange.com/posts/633206/timeline> I have daily air pollution parameters PM10, PM2.5 CO, NO2, SO2, and O3. I also have daily hospital admission numbers. Taking into account the effect of weekends and holidays, I would like to used generalised additive model (GAM) to explore the relationship between daily patients admissions, and air pollution parameters. I would like tu use mgcv package. How to get overall relative risk and 95%CI for every pollutant? I don't know if it's correct but here are the codes I used: install.packages("mgcv") library(mgcv) data=read.csv2(file.choose(),header=TRUE) data$date <- as.Date(data$date, format="%d.%m.%Y") data$weekend <- factor(data$weekend) data$holiday <- factor(data$holiday) model <- gam(adm ~ s(PM10, k = 5) + s(PM2.5, k = 5) + s(CO, k = 5) + s(NO2, k = 5) + s(SO2, k = 5) + s(O3, k = 5) + weekend + holiday, family quasipoisson(link = "log"), data = data, method = "REML") pred <- predict.gam (model, type = "response") relative_risk <- exp(pred$fit) However, when I look at the results, it calculates RR for 365 days separately. How can I get a result like the table 4 in this article ( https://pubmed.ncbi.nlm.nih.gov/36161569/)? There is only one RR calculation for each pollutant. I would be very grateful if you could help me. Thank you. Eren YALIN M.D., Research Assistant . University, Medical Faculty, Department of Public Health [[alternative HTML version deleted]]