Description Usage Arguments Details Value See Also Examples
Predicted values based on RTREE model object.
1 2 |
object |
Object of class inheriting from |
newdata |
An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. |
... |
Further arguments to be passed to |
forecast.ctree
produces predicted values, obtained by evaluating
the function tarv
and rtree
in the frame newdata
.
predictor |
result of prediction for each row. |
node |
each value matches the ordinal number of terminal node. |
The model fitting function tarv
and rtree
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # load "macs" library
library("macs")
# construct RTREE model
set.seed(1234)
data <- data.frame(y = sample(1:3, 1000, replace = TRUE),
n = as.factor(sample(1:4, 1000, replace = TRUE,
prob = c(0.1, 0.3, 0.2, 0.4))),
o1 = sample(1:50, 1000, replace = TRUE),
o2 = sample(1:30, 1000, replace = TRUE),
o3 = sample(1:10, 1000, replace = TRUE),
o4 = sample(1:60, 1000, replace = TRUE),
o5 = sample(1:20, 1000, replace = TRUE),
o6 = sample(1:40, 1000, replace = TRUE))
head(data)
result <- rtree(data, method = "entropy", alpha = 0.01, cost = c(1, 1, 1))
result
# predictions
forecast(result, data[1:10, 2:8])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.