Re: [R] mgcv: relative risk from GAM with distributed lag

2022-07-23 Thread jade.shodan--- via R-help
t; documentation p.54 > > # https://cran.rstudio.com/web/packages/gamair/gamair.pdf) > > lagard <- function(x,n.lag=7) { > > n <- length(x); X <- matrix(NA,n,n.lag) > > for (i in 1:n.lag) X[i:n,i] <- x[i:n-i+1] > > X > > } > > > > # set up

Re: [R] mgcv: relative risk from GAM with distributed lag

2022-07-22 Thread jade.shodan--- via R-help
rep(median(dat$rain), N) pd <- data.frame(temp = pred_temp, lag = pred_lag, humidity = pred_humidity, rain = pred_rain) # make predictions predictions <- predict(mod, pd, type = "terms") On Fri, 22 Jul 2022 at 09:54, Simon Wood wrote: > > > On 21/07/2022 15:19, jade

Re: [R] mgcv: relative risk from GAM with distributed lag

2022-07-21 Thread jade.shodan--- via R-help
Hello everyone (incl. Simon Wood?), I'm not sure that my original question (see below, including reproducible example) was as clear as it could have been. To clarify, what I would to like to get is: 1) a perspective plot of temperature x lag x relative risk. I know how to use plot.gam and

[R] mgcv: relative risk from GAM with distributed lag

2022-07-19 Thread jade.shodan--- via R-help
Dear list members, Does anyone know how to obtain a relative risk/ risk ratio from a GAM with a distributed lag model implemented in mgcv? I have a GAM predicting daily deaths from time series data consisting of daily temperature, humidity and rainfall. The GAM includes a distributed lag model

Re: [R] Geom ribbon

2022-07-09 Thread jade.shodan--- via R-help
I'm not sure if geom_ribbon works with categorical data. It didn't work for me, so I have coded location as a numeric, which works. You can then manuall re-label the tick marks, as per the code below. Others may be able to add to the code to add a legend, or propose a different solution

[R] Space between axis title and tick labels in persp plot in R (using vis.gam)

2022-07-06 Thread jade.shodan--- via R-help
Dear list, I am making a perspective plot of my generalised additive model (GAM) named a1b, using vis.gam() in mgcv, which in turn makes use of the persp function in base R. Code is as follows: library(mgcv) vis.gam(x = a1b, view = c("wbgt_max", "lag"), plot.type = "persp",

Re: [R] High concurvity/ collinearity between time and temperature in GAM predicting deaths but low ACF. Does this matter?

2022-06-10 Thread jade.shodan--- via R-help
ctor or a categorical one with fewer > > levels, perhaps 14 (for heaping in each year) or 12 (for each calendar > > month). I have no idea whether that would help but it seems worth a try. > > > > Michael > > > > On 08/06/2022 18:15, jade.shodan--- via R-help w

Re: [R] High concurvity/ collinearity between time and temperature in GAM predicting deaths but low ACF. Does this matter?

2022-06-06 Thread jade.shodan--- via R-help
--Original Message- > From: R-help On Behalf Of jade.shodan--- via > R-help > Sent: Sunday, June 5, 2022 3:02 PM > To: r-help@r-project.org > Subject: [R] High concurvity/ collinearity between time and temperature in > GAM predicting deaths but low ACF. Does this matter? > > [Ext