step4vglm.RdSelect a formula-based model by AIC.
step4(object, ...)
step4vglm(object, scope, direction = c("both", "backward", "forward"),
trace = 1, keep = NULL, steps = 1000, k = 2, ...)an object of class "vglm".
This is used as the initial model in the stepwise search.
See step.
See step.
any additional arguments to
extractAIC.vglm,
drop1.vglm and
add1.vglm.
The results are placed in the post slot of the
stepwise-selected model that is returned.
There are up to two additional components.
There is an "anova"
component corresponding to the steps taken in the search,
as well as a "keep" component if the keep= argument
was supplied in the call.
This function is a direct adaptation of
step
for vglm-class objects.
Since step is not generic,
the name step4() was adopted
and it is generic, as well as being S4 rather than S3.
It is the intent that this function should work as similar as
possible to step.
Internally, the methods function for vglm-class
objects calls add1.vglm and
drop1.vglm
repeatedly.
data("backPain2", package = "VGAM")
summary(backPain2)
#> x2 x3 x4 pain
#> 1:39 1:21 1:64 worse : 5
#> 2:62 2:52 2:37 same :14
#> 3:28 slight.improvement :18
#> moderate.improvement:20
#> marked.improvement :28
#> complete.relief :16
fit1 <- vglm(pain ~ x2 + x3 + x4 + x2:x3 + x2:x4 + x3:x4,
propodds, data = backPain2)
spom1 <- step4(fit1)
#> Start: AIC=340.44
#> pain ~ x2 + x3 + x4 + x2:x3 + x2:x4 + x3:x4
#>
#> Df Deviance AIC
#> - x3:x4 2 312.79 336.79
#> - x2:x4 1 313.06 339.06
#> - x2:x3 2 316.00 339.99
#> <none> 312.44 340.44
#>
#> Step: AIC=336.79
#> pain ~ x2 + x3 + x4 + x2:x3 + x2:x4
#>
#> Df Deviance AIC
#> - x2:x4 1 313.24 335.24
#> - x2:x3 2 316.28 336.28
#> <none> 312.79 336.79
#>
#> Step: AIC=335.24
#> pain ~ x2 + x3 + x4 + x2:x3
#>
#> Df Deviance AIC
#> - x2:x3 2 316.40 334.40
#> <none> 313.24 335.24
#> - x4 1 320.79 340.79
#>
#> Step: AIC=334.4
#> pain ~ x2 + x3 + x4
#>
#> Df Deviance AIC
#> <none> 316.40 334.40
#> - x3 2 321.53 335.53
#> - x4 1 322.58 338.58
#> - x2 1 330.48 346.48
summary(spom1)
#>
#> Call:
#> vglm(formula = pain ~ x2 + x3 + x4, family = propodds, data = backPain2)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept):1 5.4102 0.7247 7.466 8.29e-14 ***
#> (Intercept):2 3.8365 0.5955 6.442 1.18e-10 ***
#> (Intercept):3 2.8387 0.5479 5.181 2.21e-07 ***
#> (Intercept):4 1.8598 0.5080 3.661 0.000251 ***
#> (Intercept):5 0.0968 0.4758 0.203 0.838768
#> x22 -1.4657 0.3968 -3.694 0.000221 ***
#> x32 -1.0318 0.4839 -2.132 0.032975 *
#> x33 -1.1021 0.5373 -2.051 0.040227 *
#> x42 -0.9241 0.3804 -2.429 0.015130 *
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Number of linear predictors: 5
#>
#> Names of linear predictors: logitlink(P[Y>=2]), logitlink(P[Y>=3]),
#> logitlink(P[Y>=4]), logitlink(P[Y>=5]), logitlink(P[Y>=6])
#>
#> Residual deviance: 316.4004 on 496 degrees of freedom
#>
#> Log-likelihood: -158.2002 on 496 degrees of freedom
#>
#> Number of Fisher scoring iterations: 5
#>
#> No Hauck-Donner effect found in any of the estimates
#>
#>
#> Exponentiated coefficients:
#> x22 x32 x33 x42
#> 0.2309154 0.3563712 0.3321658 0.3968965
spom1@post$anova
#> Step Df Deviance Resid. Df Resid. Dev AIC
#> 1 NA NA 491 312.4383 340.4383
#> 2 - x3:x4 2 0.3553795 493 312.7936 336.7936
#> 3 - x2:x4 1 0.4467099 494 313.2403 335.2403
#> 4 - x2:x3 2 3.1600873 496 316.4004 334.4004