Description Usage Arguments Details Value Examples
A convenience function to perform a k-fold cross-validation experiment and
obtain mean squared error of prediction. Most of the arguments are similar to
iprior()
and kernL()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Default S3 method:
iprior_cv(y, ..., folds = 2, par.cv = TRUE,
kernel = "linear", method = "direct", control = list(),
interactions = NULL, est.lambda = TRUE, est.hurst = FALSE,
est.lengthscale = FALSE, est.offset = FALSE, est.psi = TRUE,
fixed.hyp = NULL, lambda = 1, psi = 1, nystrom = FALSE,
nys.seed = NULL)
## S3 method for class 'formula'
iprior_cv(formula, data, folds = 2, one.lam = FALSE,
par.cv = TRUE, kernel = "linear", method = "direct",
control = list(), est.lambda = TRUE, est.hurst = FALSE,
est.lengthscale = FALSE, est.offset = FALSE, est.psi = TRUE,
fixed.hyp = NULL, lambda = 1, psi = 1, nystrom = FALSE,
nys.seed = NULL, ...)
|
y |
Vector of response variables |
... |
Only used when fitting using non-formula, enter the variables (vectors or matrices) separated by commas. |
folds |
The number of cross-validation folds. Set equal to sample size
or |
par.cv |
Logical. Multithreading to fit the models? Defaults to
|
kernel |
Character vector indicating the type of kernel for the variables. Available choices are:
The |
method |
The estimation method. One of:
|
control |
(Optional) A list of control options for the estimation procedure:
|
interactions |
Character vector to specify the interaction terms. When
using formulas, this is specified automatically, so is not required. Syntax
is |
est.lambda |
Logical. Estimate the scale parameters? Defaults to
|
est.hurst |
Logical. Estimate the Hurst coefficients for fBm kernels?
Defaults to |
est.lengthscale |
Logical. Estimate the lengthscales for SE kernels?
Defaults to |
est.offset |
Logical. Estimate the offsets for polynomial kernels?
Defaults to |
est.psi |
Logical. Estimate the error precision? Defaults to
|
fixed.hyp |
Logical. If |
lambda |
Initial/Default scale parameters. Relevant especially if
|
psi |
Initial/Default value for error precision. Relevant especially if
|
nystrom |
Either logical or an integer indicating the number of Nystrom
samples to take. Defaults to |
nys.seed |
The random seed for the Nystrom sampling. Defaults to
|
formula |
The formula to fit when using formula interface. |
data |
Data frame containing variables when using formula interface. |
one.lam |
Logical. When using formula input, this is a convenient way of
letting the function know to treat all variables as a single variable (i.e.
shared scale parameter). Defaults to |
Uses a multicore loop to fit the folds by default, set par.cv = FALSE
to not use multithreading.
An iprior_xv
object containing a data frame of the
cross-validated values such as the log-likelihood, training MSE and test
MSE.
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
# 5-fold CV experiment
(mod.cv <- iprior_cv(y ~ X, gen_smooth(100), kernel = "se", folds = 5))
# LOOCV experiment
(mod.cv <- iprior_cv(y ~ X, gen_smooth(100), kernel = "se", folds = Inf))
# Can also get root MSE
print(mod.cv, "RMSE")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.