Skip to content
Snippets Groups Projects
Verified Commit a039f626 authored by Carolin Strobl's avatar Carolin Strobl Committed by GitLab UZH
Browse files

Delete Exercise_1_trees_SOLUTION.R

parent 322f449d
No related branches found
No related tags found
No related merge requests found
### R code from vignette source 'Exercise_1_trees_SOLUTION.Rnw'
###################################################
### code chunk number 1: Exercise_1_trees_SOLUTION.Rnw:49-50
###################################################
load("Covid_stress_data_subs.rdata")
###################################################
### code chunk number 2: Exercise_1_trees_SOLUTION.Rnw:55-56
###################################################
summary(dat_cvid)
###################################################
### code chunk number 3: Exercise_1_trees_SOLUTION.Rnw:63-65
###################################################
#install.packages("partykit")
library("partykit")
###################################################
### code chunk number 4: Exercise_1_trees_SOLUTION.Rnw:70-71
###################################################
my_ctree <- ctree(vaccWill ~ ., data = dat_cvid)
###################################################
### code chunk number 5: Exercise_1_trees_SOLUTION.Rnw:76-77
###################################################
plot(my_ctree)
###################################################
### code chunk number 6: Exercise_1_trees_SOLUTION.Rnw:90-93
###################################################
predicted <- predict(my_ctree, type = "response")
true <- dat_cvid$vaccWill
table(true, predicted)
###################################################
### code chunk number 7: Exercise_1_trees_SOLUTION.Rnw:104-106
###################################################
#install.packages("stablelearner")
library("stablelearner")
###################################################
### code chunk number 8: Exercise_1_trees_SOLUTION.Rnw:113-115
###################################################
set.seed(270312)
stab_my_ctree <- stabletree(my_ctree)
###################################################
### code chunk number 9: Exercise_1_trees_SOLUTION.Rnw:123-124 (eval = FALSE)
###################################################
## plot(stab_my_ctree, select = c("vaccAtt", "fearCorona", "compliance", "education"))
###################################################
### code chunk number 10: Exercise_1_trees_SOLUTION.Rnw:127-131 (eval = FALSE)
###################################################
## # show variable selection proportions
## barplot(stab_my_ctree)
## # illustrate variable selections of replications
## image(stab_my_ctree)
###################################################
### code chunk number 11: Exercise_1_trees_SOLUTION.Rnw:135-137
###################################################
# illustrate variable selections of replications
barplot(stab_my_ctree)
###################################################
### code chunk number 12: Exercise_1_trees_SOLUTION.Rnw:139-141
###################################################
# illustrate variable selections of replications
image(stab_my_ctree)
###################################################
### code chunk number 13: Exercise_1_trees_SOLUTION.Rnw:151-153
###################################################
# show graphical cutpoint analysis
plot(stab_my_ctree, select = c("vaccAtt", "fearCorona", "compliance", "education", "age", "trustInstitut"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment