cp_validation_fit {gspcr}R Documentation

Compute fit measure(s) on the validation data set

Description

Given a training and validation data set, it computes a target fit measure on the validation data set.

Usage

cp_validation_fit(y_train, y_valid, X_train, X_valid, fam, fit_measure)

Arguments

y_train

numeric vector or factor of dependent variable values from the training set

y_valid

numeric vector or factor of dependent variable values from the validation set

X_train

n \times p data.frame of independent variables (factors allowed) from the training set. Can also be set to NULL to obtain the log-likelihood of the new data under the null model.

X_valid

n \times p data.frame of independent variables (factors allowed) from the validation set. If X_train is set to NULL to obtain the log-likelihood of the new data under the null model, X_valid is ignored.

fam

character vector of length 1 storing the description of the error distribution and link function to be used in the model (see cv_gspcr() for the list of possible options)

fit_measure

character vector indicating which fit measure should be computed (see cv_gspcr() for the list of possible options)

Details

The validation data set can be specified to be the same as the training data set if desired.

Value

numeric vector of length 1 storing the requested fit measure

Author(s)

Edoardo Costantini, 2023

Examples

# Example inputs
y_train = mtcars[1:20, 1]
y_valid = mtcars[-c(1:20), 1]
X_train = mtcars[1:20, -1]
X_valid = mtcars[-c(1:20), -1]
fam = "gaussian"
fit_measure = "BIC"

# Use the function
cp_validation_fit(y_train, y_valid, X_train, X_valid, fam, fit_measure)


[Package gspcr version 0.9.5 Index]