Predict method for the crtree function
# S3 method for crtree predict( object, pred_data = NULL, pred_cmd = "", conf_lev = 0.95, se = FALSE, dec = 3, envir = parent.frame(), ... )
object | Return value from |
---|---|
pred_data | Provide the dataframe to generate predictions (e.g., titanic). The dataset must contain all columns used in the estimation |
pred_cmd | Generate predictions using a command. For example, `pclass = levels(pclass)` would produce predictions for the different levels of factor `pclass`. To add another variable, create a vector of prediction strings, (e.g., c('pclass = levels(pclass)', 'age = seq(0,100,20)') |
conf_lev | Confidence level used to estimate confidence intervals (.95 is the default) |
se | Logical that indicates if prediction standard errors should be calculated (default = FALSE) |
dec | Number of decimals to show |
envir | Environment to extract data from |
... | further arguments passed to or from other methods |
See https://radiant-rstats.github.io/docs/model/crtree.html for an example in Radiant
crtree
to generate the result
summary.crtree
to summarize results
result <- crtree(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)")#> Classification and regression trees #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass, sex #> Prediction command : pclass = levels(pclass) #> #> sex pclass Prediction #> male 1st 0.205 #> male 2nd 0.205 #> male 3rd 0.205result <- crtree(titanic, "survived", "pclass", lev = "Yes") predict(result, pred_data = titanic) %>% head()#> Classification and regression trees #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass #> Prediction dataset : titanic #> #> pclass Prediction #> 1st 0.635 #> 1st 0.635 #> 1st 0.635 #> 1st 0.635 #> 1st 0.635 #> 1st 0.635