[This article was first published on Yet Another Blog in Statistical Computing » S+/R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
library(party)
df1 <- read.csv("credit_count.csv")
df2 <- df1[df1$CARDHLDR == 1, ]
mdl <- mob(DEFAULT ~ MAJORDRG + MINORDRG + INCOME + OWNRENT | AGE + SELFEMPL, data = df2, family = binomial(), control = mob_control(minsplit = 1000), model = glinearModel)
print(mdl)
#1) AGE <= 22.91667; criterion = 1, statistic = 48.255
# 2)* weights = 1116
#Terminal node model
#Binomial GLM with coefficients:
#(Intercept) MAJORDRG MINORDRG INCOME OWNRENT
# -0.6651905 0.0633978 0.5182472 -0.0006038 0.3071785
#
#1) AGE > 22.91667
# 3)* weights = 9383
#Terminal node model
#Binomial GLM with coefficients:
#(Intercept) MAJORDRG MINORDRG INCOME OWNRENT
# -1.4117010 0.2262091 0.2067880 -0.0003822 -0.2127193
### TEST FOR STRUCTURAL CHANGE ###
sctest(mdl, node = 1)
# AGE SELFEMPL
#statistic 4.825458e+01 20.88612025
#p.value 1.527484e-07 0.04273836
summary(mdl, node = 2)
#Coefficients:
# Estimate Std. Error z value Pr(>|z|)
#(Intercept) -0.6651905 0.2817480 -2.361 0.018229 *
#MAJORDRG 0.0633978 0.3487305 0.182 0.855743
#MINORDRG 0.5182472 0.2347656 2.208 0.027278 *
#INCOME -0.0006038 0.0001639 -3.685 0.000229 ***
#OWNRENT 0.3071785 0.2028491 1.514 0.129945
summary(mdl, node = 3)
#Coefficients:
# Estimate Std. Error z value Pr(>|z|)
#(Intercept) -1.412e+00 1.002e-01 -14.093 < 2e-16 ***
#MAJORDRG 2.262e-01 7.067e-02 3.201 0.00137 **
#MINORDRG 2.068e-01 4.925e-02 4.199 2.68e-05 ***
#INCOME -3.822e-04 4.186e-05 -9.131 < 2e-16 ***
#OWNRENT -2.127e-01 7.755e-02 -2.743 0.00609 **
To leave a comment for the author, please follow the link and comment on their blog: Yet Another Blog in Statistical Computing » S+/R.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
