## ------------------------------------------------------------------- #
## Example 1: Moderated effect of education on poverty
##
## The algorithm is used to find out whether the effect of high
## education 'EduHigh' on poverty 'Poor' is moderated by the civil
## status 'CivStat'. We specify two 'vc' terms in the logistic
## regression model for 'Poor': a first that accounts for the direct
## effect of 'CivStat' and a second that accounts for the moderation of
## 'CivStat' on the relation between 'EduHigh' and 'Poor'. We use here
## the 2-stage procedure with a partitioning- and a pruning stage as
## described in Buergin and Ritschard (2014b).
## ------------------------------------------------------------------- #
data(poverty)
poverty$EduHigh <- 1 * (poverty$Edu == "high")
## fit the model
model.Pov <-
tvcglm(Poor ~ -1 + vc(CivStat) + vc(CivStat, by = EduHigh) + NChild,
family = binomial(), data = poverty, subset = 1:200,
control = tvcm_control(verbose = TRUE, papply = lapply,
folds = folds_control(K = 1, type = "subsampling", seed = 7)))
## diagnosis
plot(model.Pov, "cv")
plot(model.Pov, "coef")
summary(model.Pov)
splitpath(model.Pov, steps = 1:3)
prunepath(model.Pov, steps = 1)
Run the code above in your browser using DataLab