Custom Functions for Specifying Nonlinear Terms to gnm
Heather Turner, David Firth and Andy Batchelor
Department of Statistics University of Warwick, UK
- H. Turner, D. Firth and A. Batchelor
() Custom “nonlin” Functions UseR August 2008 1 / 17
Custom Functions for Specifying Nonlinear Terms to gnm Heather - - PowerPoint PPT Presentation
Custom Functions for Specifying Nonlinear Terms to gnm Heather Turner, David Firth and Andy Batchelor Department of Statistics University of Warwick, UK H. Turner, D. Firth and A. Batchelor () Custom nonlin Functions UseR August 2008
() Custom “nonlin” Functions UseR August 2008 1 / 17
◮ year of (first) marriage ◮ year and month of birth ◮ social class ◮ highest level of education attained ◮ year highest level of education was attained
() Custom “nonlin” Functions UseR August 2008 2 / 17
itβ
◮ need custom "nonlin" function to specify “log-excess” terms
() Custom “nonlin” Functions UseR August 2008 3 / 17
() Custom “nonlin” Functions UseR August 2008 4 / 17
l )
r)
l and α∗ r instead. In LogExcess define
() Custom “nonlin” Functions UseR August 2008 5 / 17
() Custom “nonlin” Functions UseR August 2008 6 / 17
() Custom “nonlin” Functions UseR August 2008 7 / 17
() Custom “nonlin” Functions UseR August 2008 8 / 17
Call: gnm(formula = marriages/lives ~ LogExcess(age, side = "left") + LogExcess(age, side = "right"), family = binomial, data = fulldata, weights = lives, start = c(-20, 3, 0, 3, 0)) Deviance Residuals: Min 1Q Median 3Q Max
4.0483 Estimate Std. Error z value Pr(>|z|) (Intercept)
NA NA NA LogExcess(age, side = "left")beta 3.6928 NA NA NA LogExcess(age, side = "left")alpha
NA NA NA LogExcess(age, side = "right")beta 24.8623 NA NA NA LogExcess(age, side = "right")alpha 4.0247 NA NA NA
Residual deviance: 12553 on 31004 degrees of freedom AIC: 12748 Number of iterations: 76
() Custom “nonlin” Functions UseR August 2008 9 / 17
10 20 30 40 50 0.00 0.04 0.08 0.12 Age Probability of Marriage
() Custom “nonlin” Functions UseR August 2008 10 / 17
10 20 30 40 50 0.00 0.04 0.08 0.12 Age Probability of Marriage 10 20 30 40 50 0.00 0.04 0.08 0.12 Age Probability of Marriage
() Custom “nonlin” Functions UseR August 2008 10 / 17
10 20 30 40 50 0.00 0.04 0.08 0.12 Age Probability of Marriage 10 20 30 40 50 0.00 0.04 0.08 0.12 Age Probability of Marriage 10 20 30 40 50 0.00 0.04 0.08 0.12 Age Probability of Marriage
() Custom “nonlin” Functions UseR August 2008 10 / 17
() Custom “nonlin” Functions UseR August 2008 11 / 17
Age (years) Probability of Marriage αL ν αR expit(γ)
() Custom “nonlin” Functions UseR August 2008 12 / 17
−2.09 → −1.95 0.00 0.05 0.10 0.15
25.39 → → 28
0.34 → 0.15
−0.14 → → 0.035 10 20 30 40 50
4.02 → 20 0.00 0.05 0.10 0.15 10 20 30 40 50
Perturbed Model Re−fitted Model Age (years) Probability of Marriage
() Custom “nonlin” Functions UseR August 2008 13 / 17
Call: gnm(formula = marriages/lives ~ Bell(age), family = binomial, data = fulldata, weights = lives, start = c(NA, 26, 0.2, NA, NA)) Deviance Residuals: Min 1Q Median 3Q Max
4.0483 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept)
0.03313 -63.225 < 2e-16 Bell(age)peak 25.39354 0.30405 83.517 < 2e-16 Bell(age)fallOff 0.32917 0.09065 3.631 0.000282 Bell(age)leftAdj
0.89350
Bell(age)rightAdj 4.02470 1.73753 2.316 0.020540 (Dispersion parameter for binomial family taken to be 1) Residual deviance: 12553 on 31004 degrees of freedom AIC: 12748 Number of iterations: 14
() Custom “nonlin” Functions UseR August 2008 14 / 17
◮ use simpler model with infinite right endpoint
◮ extend model to allow ν to depend on covariates
() Custom “nonlin” Functions UseR August 2008 15 / 17
15 20 25 30 35 40 45 0.00 0.05 0.10 0.15 0.20 Age (years) Probability of marriage 10 20 30 40 50 0.0 0.2 0.4 0.6 0.8 1.0 Age (years) Proportion never married
Education level (years)
8 11 14 15 16 17
() Custom “nonlin” Functions UseR August 2008 16 / 17
() Custom “nonlin” Functions UseR August 2008 17 / 17