Learn R Programming

vinereg (version 0.5.0)

predict.vinereg: Predict conditional mean and quantiles from a D-vine regression model

Description

Predict conditional mean and quantiles from a D-vine regression model

Usage

# S3 method for vinereg
predict(object, newdata, alpha = 0.5, uscale = FALSE,
  ...)

# S3 method for vinereg fitted(object, alpha = 0.5, ...)

Arguments

object

an object of class vinereg.

newdata

matrix of covariate values for which to predict the quantile.

alpha

vector of quantile levels; NA predicts the mean based on an average of the 1:10 / 11-quantiles.

uscale

if TRUE input (newdata) and output is on copula scale.

...

unused.

Value

A data.frame of quantiles where each column corresponds to one value of alpha.

See Also

vinereg

Examples

Run this code
# NOT RUN {
# simulate data
x <- matrix(rnorm(300), 100, 2)
y <- x %*% c(1, -2)
dat <- data.frame(y = y, x = x, z = as.factor(rbinom(100, 2, 0.5)))

# fit vine regression model
(fit <- vinereg(y ~ ., dat))

# inspect model
summary(fit)
plot_effects(fit)

# model predictions
mu_hat  <- predict(fit, newdata = dat, alpha = NA)          # mean
med_hat <- predict(fit, newdata = dat, alpha = 0.5)         # median

# observed vs predicted
plot(cbind(y, mu_hat))

## fixed variable order (no selection)
(fit <- vinereg(y ~ ., dat, order = c("x.2", "x.1", "z.1")))

# }

Run the code above in your browser using DataLab