Learn R Programming

qad (version 1.0.1)

predict.qad: Predict conditional probabilities

Description

The function predict.qad() can be utilized to predict the probabilities of the event that Y lies in specific intervals given X=x, or vice versa. Additionally, the mass of the conditional distribution functions are plotted. The prediction can be computed in the sample setting as well as in the copula setting (pseudo-observation in the unit square).

Usage

# S3 method for qad
predict(
  object,
  values,
  conditioned = "x1",
  nr_intervals = NULL,
  prediction_interval = NULL,
  copula = FALSE,
  pred_plot = FALSE,
  panel.grid = TRUE,
  ...
)

Arguments

object

an object of class 'qad', which determines the underlying checkerboard aggregation.

values

a vector containing the x or the y values for which the conditional probabilities should be predicted.

conditioned

a character specifying on which variable is conditioned. Options are "x1" (default) or "x2".

nr_intervals

an integer, which determines a different number of intervals for the prediction (only possible in the copula setting).

prediction_interval

a vector specifying the interval boundaries for which the conditional probability is computed. Options are NULL (default) to predict the conditional probabilites for all intervals or a vector c(lower_boundary, upper_boundary) indicating the boundaries.

copula

a logical (default =FALSE) determining whether the empirical checkerboard copula is used or the retransformed data.

pred_plot

a logical indicating if the conditional probabilites are plotted.

panel.grid

a logical indicating whether the panel.grid is plotted.

...

some methods for this generic require additional arguments. None are used in this method.

Value

a list containing a data.frame with the interval boundaries and the prediction probabilities and a plot depicting the mass of the conditional distributions functions.

Examples

Run this code
# NOT RUN {
set.seed(1)
n <- 100
x <- runif(n, -4 ,4)
y <- x^2 + rnorm(n, 0, 1)
sample <- data.frame(x, y)

##(Not Run)
qad.fit <- qad(sample)
predict.qad(qad.fit, values = c(-2,0.6), conditioned = "x1", pred_plot = TRUE)
predict.qad(qad.fit, values = c(1,9), conditioned = "x2", pred_plot = TRUE)
predict.qad(qad.fit, values = c(-2,0.6), conditioned = "x1", pred_plot = FALSE,
        nr_intervals = 4)
predict.qad(qad.fit, values = c(-2,0.6), conditioned = "x1", pred_plot = FALSE,
            prediction_interval = c(4,6))
predict.qad(qad.fit, values = c(4,0.6), conditioned = "x2", pred_plot = FALSE,
            prediction_interval = c(2,3))

qad.pred <- predict.qad(qad.fit, values = c(-2,0.6), conditioned = "x1", pred_plot = FALSE)
qad.pred$prediction
qad.pred$plot


# }

Run the code above in your browser using DataLab