Dear R-helpers
I have a question related to logistic GAM models. Consider the following 
example:
# Load package
library(mgcv)

# Simulation of dataset
n <- 1000
set.seed(0)
age            <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol    <- rnorm(n, 200, 25)
sex            <- factor(sample(c('female','male'), n,TRUE))

L <- 0.4*(sex=='male') + 0.045*(age-50) + (log(cholesterol - 
10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
y <- ifelse(runif(n) < plogis(L), 1, 0)


I now want to fit a logistic GAM model and model age as a cubic spline:

fit <- gam(y ~ blood.pressure + sex  + cholesterol + s(age, bs="cr") 
,family=binomial)

Now my question: In a normal logistic regression, the odds ratio (OR) 
simply is the exponentiated coefficient exp(beta).
How is it possible to calculate the odds ratio for age (in this example) 
based on the spline? For example the odds ratio based on the spline 
between the age of, say, 20-30?
Or even better: How can I plot the odds ratios against age in a continuous 
form?

Many thanks for your help.

Best,
Denis Aydin

--------------------------------------------------------------------------
This email and any files transmitted with it are confide...{{dropped:8}}

______________________________________________
[email protected] mailing list
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.

Reply via email to