VI_MODEL-cash-null_resid: Generate null residuals from a null model

VI_MODEL$null_residR Documentation

Generate null residuals from a null model

Description

This function uses the data and the null model to generate null residuals. The null residuals are generated by first regressing random noises on the original regressors, then multiply the obtained residuals by original RSS divided by the current RSS. The results are the null residuals.

Arguments

dat

Data frame. A data frame that used to fit the model.

mod

Linear Model. The null model.

test

Boolean. Whether or not to use test on the newly generated data.

Value

A data frame with updated y, .resid, and potentially updated test result.

Examples


# Instantiate
x <- rand_uniform()
e <- rand_normal()
test <- vi_model(prm = list(x = x, e = e),
                 prm_type = list(x = "r", e = "r"),
                 formula = y ~ 1 + x + x^2 + e,
                 null_formula = y ~ x,
                 alt_formula = y ~ x + I(x^2))

dat <- test$gen(10)
test$null_resid(dat, test$fit(dat), test = TRUE)

TengMCing/visage documentation built on Aug. 28, 2024, 3:27 p.m.