fit_lm {ARTtransfer} | R Documentation |
fit_lm: Linear Regression Wrapper for the ARTtransfer package
Description
This function fits a linear regression model using 'lm()' and returns the coefficients, deviance on a validation set, and predictions on a test set. It is specifically designed for use in the 'ART' adaptive and robust transfer learning framework.
Usage
fit_lm(X, y, X_val, y_val, X_test, min_prod = 1e-05, max_prod = 1 - 1e-05, ...)
Arguments
X |
A matrix of predictors for the training set. |
y |
A vector of responses for the training set. |
X_val |
A matrix of predictors for the validation set. If 'NULL', deviance is not calculated. |
y_val |
A vector of responses for the validation set. If 'NULL', deviance is not calculated. |
X_test |
A matrix of predictors for the test set. If 'NULL', predictions are not generated. |
min_prod |
A numeric value indicating the minimum probability bound for predictions (not used in this function but passed for compatibility). Default is '1e-5'. |
max_prod |
A numeric value indicating the maximum probability bound for predictions (not used in this function but passed for compatibility). Default is '1-1e-5'. |
... |
Additional arguments passed to the function (currently unused). |
Value
A list containing:
dev |
The mean squared error (deviance) on the validation set if provided, otherwise 'NULL'. |
pred |
The predictions on the test set if 'X_test' is provided, otherwise 'NULL'. |
coef |
The fitted coefficients of the linear model. |
Examples
# Fit a linear model with validation and test data
X_train <- matrix(rnorm(100 * 5), 100, 5)
y_train <- X_train %*% rnorm(5) + rnorm(100)
X_val <- matrix(rnorm(50 * 5), 50, 5)
y_val <- X_val %*% rnorm(5) + rnorm(50)
X_test <- matrix(rnorm(20 * 5), 20, 5)
fit <- fit_lm(X_train, y_train, X_val, y_val, X_test)