Skip to content
Prev 392297 / 398502 Next

mgcv: relative risk from GAM with distributed lag

On 21/07/2022 15:19, jade.shodan--- via R-help wrote:
- You are on the log scale so I think that all you need to do is to use 
'predict.gam', with 'type = "terms"' to? get the predictions for the 
te(temp, lag) term over the required grid of lags and temperatures. 
Suppose the dataframe of prediction data is 'pd'. Now produce pd0, which 
is identical to pd, except that the temperatures are all set to the 
reference temperature. Use predict.gam to predict te(temp,lag) from pd0. 
Now the exponential of the difference between the first and second 
predictions is the required RR, which you can plot using 'persp', 
'contour', 'image' or whatever. If you need credible intervals see pages 
341-343 of my 'GAMs: An intro with R' book (2nd ed).
- I guess this only makes sense if you have the same temperature at all 
lags. So this time produce a data.frame with each desired temperature 
repeated for each lag: 'pd1'. Again use predict.gam(...,type="terms"). 
Then sum the predictions over lags for each temperature, subtract the 
minimum, and take the exponential. Same as above for CIs.

best,

Simon