valreg: Function to validate a regression model

View source: R/valreg.R

valregR Documentation

Function to validate a regression model

Description

Function to validate a regression model

Usage

valreg(
  reg,
  verbose = TRUE,
  nvar = 5,
  boot = TRUE,
  alpha = 0.05,
  conf.level = 0.95,
  plot = FALSE,
  data = c(),
  raintest_alpha = 0.05,
  dwtest_alpha = 0.03,
  shapiro_alpha = 0.05,
  bptest_alpha = 0.05
)

Arguments

reg

A regression model

verbose

To see the detailed balance sheet

nvar

The maximum number of variables allowed.

boot

For checking the model by bootstrap with bootreg() (FALSE or TRUE)

alpha

Maximum value accepted for the p-values of the model and its coefficients.

conf.level

Confidence interval accepted to validate the regression model by bootstrap.

plot

For seeing the graphical analysis of bootreg() (FALSE or TRUE)

data

optional, the data.frame of data if complex model.

raintest_alpha

Minimal value of p-value accepted for Rainbow test

dwtest_alpha

Minimal value of p-value accepted for Durbin-Watson test

shapiro_alpha

Minimal value of p-value accepted for Shapiro-Wilk test

bptest_alpha

Minimal value of p-value accepted for Breush-Pagan test

Value

This function allows to run all the tests necessary to validate a regression model (check the normal distribution of the residuals, avoid leverage effects, control the variance of the residuals...).

valreg will therefore validate the regression model, control the p-values and, possibly (boot argument), control the reliability by bootstrap with the bootreg function.

Examples

#Example 1
data(iris)
reg <- lm(Sepal.Length~.,data=iris[,1:4])
valreg(reg,verbose=TRUE)
#Example 2
data(airquality)
reg <- lm(Wind~Temp,data=airquality)
valreg(reg,verbose=TRUE)
#Example 3
data(mtcars)
reg <- lm(cyl~gear,data=mtcars)
valreg(reg,verbose=TRUE,boot=TRUE)
#Example 4
data(iris)
reg <- lm(Petal.Width~Petal.Length,data=iris[iris$Species=="virginica",])
valreg(reg,verbose=TRUE,boot=TRUE,plot=TRUE)
plot(reg)
#Example 5
data(mtcars);
reg<- lm(cyl~disp+hp,data=mtcars);
corrigraph(mtcars,"cyl");
valreg(reg, verbose=TRUE, plot=TRUE)

Antoine-Masse/KefiR documentation built on Feb. 22, 2024, 5:54 a.m.