forecast.stree: Predict method for STREE Model Fits

Description Usage Arguments Details Value See Also Examples

View source: R/forecast.R

Description

Predicted values based on RTREE model object.

Usage

1
2
  ## S3 method for class 'stree'
forecast(object, newdata, ...)

Arguments

object

Object of class inheriting from "stree"

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.stree

Details

forecast.stree produces predicted values, obtained by evaluating the function stree in the frame newdata.

Value

predictor

result of prediction for each row.

node

each value matches the ordinal number of terminal node.

See Also

The model fitting function stree

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# load "macs" library
library("macs")
set.seed(1234)
data <- data.frame(r = runif(1000, 1, 10), c = rbinom(1000, 1, 0.5),
                   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 <-  stree(data, family = "likelihood")
result

# predictions
forecast(result, data[1:10, 3:9])

macs documentation built on Oct. 9, 2019, 5:05 p.m.

Related to forecast.stree in macs...