## ----preliminaries, include=FALSE--------------------------------------------- library("psychotree") knitr::opts_chunk$set( engine = "R", collapse = TRUE, comment = "##", message = FALSE, warning = FALSE, echo = TRUE ) ## ----prep_install, eval=FALSE------------------------------------------------- # install.packages("psychotree") ## ----prep_library------------------------------------------------------------- library("psychotree") ## ----prep_data---------------------------------------------------------------- data("SPISA", package = "psychotree") ## ----recode, eval=FALSE------------------------------------------------------- # mydata$resp <- as.matrix(mydata[ , 1:5]) ## ----recode2, eval=FALSE------------------------------------------------------ # mydata <- mydata[ , -(1:5)] ## ----fit_raschtree, eval=FALSE------------------------------------------------ # my_first_raschtree <- raschtree(spisa ~ age + gender + # semester + elite + spon, data = SPISA) ## ----fit_raschtree_minsize---------------------------------------------------- my_first_raschtree <- raschtree(spisa ~ age + gender + semester + elite + spon, data = SPISA, minsize = 30) ## ----plot_raschtree, fig.height=6, fig.width=14------------------------------- plot(my_first_raschtree) ## ----plot_raschtree_col, fig.height=6, fig.width=14--------------------------- plot(my_first_raschtree, col = rep(palette.colors(5), each = 9)) ## ----coef_raschtree----------------------------------------------------------- coef(my_first_raschtree, node = 4) ## ----itempar_raschtree-------------------------------------------------------- itempar(my_first_raschtree, node = 4) ## ----eval=FALSE--------------------------------------------------------------- # install.packages("stablelearner") ## ----eval=FALSE--------------------------------------------------------------- # library("stablelearner") ## ----eval=FALSE--------------------------------------------------------------- # set.seed(4321) # my_first_raschtree_st <- stabletree(my_first_raschtree, B = 50) ## ----stabletree_fit, include=FALSE-------------------------------------------- if(require("stablelearner", quietly = TRUE)) { set.seed(4321) my_first_raschtree_st <- stabletree(my_first_raschtree, B = 50) spon1 <- summary(my_first_raschtree_st)$vstab["spon", 1] spon3 <- summary(my_first_raschtree_st)$vstab["spon", 3] } else { my_first_raschtree_st <- matrix(1) spon1 <- spon3 <- 0 } ## ----stabletree_summary------------------------------------------------------- summary(my_first_raschtree_st) ## ----stabletree_barplot, fig.height=6, fig.width=6---------------------------- barplot(my_first_raschtree_st) ## ----stabletree_image, fig.height=6, fig.width=6------------------------------ image(my_first_raschtree_st) ## ----stabletree_plot, fig.width=10, fig.height=10----------------------------- plot(my_first_raschtree_st)