% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RFok.R
\name{predict.rfok}
\alias{predict.rfok}
\title{Predict method for rfok}
\usage{
\method{predict}{rfok}(
  object,
  newdata = NULL,
  samples = 1000,
  conf = NULL,
  smoothing = TRUE,
  eps = 0,
  ...
)
}
\arguments{
\item{object}{Object returned by \code{rfok()}}

\item{newdata}{a data frame or matrix of new data}

\item{samples}{Number of samples from the predictive distribution.}

\item{conf}{a vector of levels for desired confidence intervals. Ignored unless samples is NULL.}

\item{smoothing}{logical; should conformity scores be sampled or smoothed (using quantiles)}

\item{eps}{Tolerance for nearest neighbor approach. When \code{eps = 0}, exact nearest neighbors are used.}

\item{...}{Additional, ignored, parameters}
}
\value{
A matrix of predictions with 1 column per test point.
}
\description{
A conformal RF based on Johansson et al. (2014). Rather than using a traditional calibration set, conformal intervals are constructed using out-of-bag samples for each tree. K-nearest neighbors is used to calibrate the prediction intervals for each prediction location.
}
\details{
Prediction intervals are constructed by estimating a local scale for each
prediction point using the \code{k} nearest training observations. The
conformal margin of error is the requested quantile of the training
non-conformity scores multiplied by this local scale.

If \code{samples = NULL}, the function returns point predictions and margins
of error for the confidence levels supplied in \code{conf}. For example,
\code{conf = 0.95} uses the 0.95 quantile of the non-conformity scores.

If \code{samples} is a positive integer, the function returns simulated
predictive samples. When \code{smoothing = TRUE}, signed non-conformity scores
are generated using quantiles of the symmetrized empirical distribution. When
\code{smoothing = FALSE}, non-conformity scores are sampled directly with
replacement and assigned random signs.
}
\examples{
# Friedman function
f <-  function(x){
  10 * sin(pi * x[1] * x[2]) + 20 * (x[3] - 0.5)^2 + 10 * x[4] + 5 * x[5]
}
X <- matrix(runif(250), nrow=50, ncol=5)
y <- apply(X, 1, f)
fit <- rfok(X, y)

Xnew <- matrix(runif(250), nrow=50, ncol=5)
predict(fit, Xnew)
}
