Package 'MTest'

Title: A Procedure for Multicollinearity Testing using Bootstrap
Description: Functions for detecting multicollinearity. This test gives statistical support to two of the most famous methods for detecting multicollinearity in applied work: Klein’s rule and Variance Inflation Factor (VIF). See the URL for the papers associated with this package, as for instance, Morales-Oñate and Morales-Oñate (2015) <doi:10.33333/rp.vol51n2.05>.
Authors: Víctor Morales-Oñate [aut, cre] , Bolívar Morales-Oñate [aut]
Maintainer: Víctor Morales-Oñate <[email protected]>
License: GPL (>= 3)
Version: 1.0.1
Built: 2024-10-29 03:30:37 UTC
Source: https://github.com/vmoprojs/mtest

Help Index


MTest

Description

MTest is a nonparametric test based on bootstrap for detecting multicollinearity. This test gives statistical support to two of the most famous methods for detecting multicollinearity in applied work: Klein’s rule and Variance Inflation Factor (VIF for essential multicollinearity).

Usage

MTest(object, nboot = 100,
                  nsam = NULL,trace = FALSE,seed = NULL,
                  valor_vif = 0.9)

Arguments

object

an object representing a model of an appropriate class (mainly "lm"). This is used as the model in MTest.

nboot

Numeric; number of bootstrap iterations to obtain the probability distribution of R squared (global and auxiliar).

nsam

Numeric; sample size for bootstrap samples.

trace

Logical; prints iteration process.

seed

Numeric; seed value for the bootstrap in nboot parameter.

valor_vif

Numeric; value to be compared in kleins rule.

Details

MTest generates a bootstrap distribution for the coefficient of determination which lets the researcher assess multicollinearity by setting a statistical significance α\alpha, or more precisely, an achieved significance level (ASL) for a given threshold.

Consider the regression model

Yi=β0X0i+β1X1i++βpXpi+uiY_i = \beta_0X_{0i} + \beta_1X_{1i} + \cdots+ \beta_pX_{pi} +u_i

where i=1,...,ni = 1,...,n, Xj,iX_{j,i} are the predictors with j=1,...,pj = 1,...,p, X0=1X_0 = 1 for all ii and uiu_i is the gaussian error term.

In order to describe Klein's rule and VIF methods, we need to define auxiliary regressions associated to model. An example of an auxiliary regressions is:

X2i=γ1X1i+γ3X3i++γpXpi+ui.X_{2i} = \gamma_1X_{1i} + \gamma_3X_{3i} + \cdots+ \gamma_pX_{pi} +u_i.

In general, there are pp auxiliary regressions and the dependent variable is omitted in each auxiliary regression. Let Rg2R_{g}^{2} be the coefficient of determination of the model and Rj2R_{j}^{2} the jthj\text{th} coefficient of determination of the jthj\text{th} auxiliary regression.

Value

Returns an object of class MTest. An object of class MTest is a list containing at most the following components:

pval_vif

p values for vif test;

pval_klein

p values for klein test;

Bvals

A nboot×(p+1)nboot \times (p+1) matrix where rows are the number of bootstap samples and the columns are Rgboot2R_{g_{boot}}^{2} and Rjboot2R_{j_{boot}}^{2} which are estimates of estimates of Rg2R_{g}^{2} and Rj2R_{j}^{2}, see Section Details

vif.tot

Observed VIF values;

R.tot

Observed Rg2R_{g}^{2} and Rj2R_{j}^{2} values;

nsam

sample size used in bootstrap procedure.

Author(s)

Víctor Morales Oñate, [email protected], https://sites.google.com/site/moralesonatevictor/,https://www.linkedin.com/in/vmoralesonate/ Bolívar Morales Oñate, [email protected], https://sites.google.com/site/moralesonatevictor/

References

Morales-Oñate, V., and Morales-Oñate, B. (2023). MTest: a Bootstrap Test for Multicollinearity. Revista Politécnica, 51(2), 53–62. doi:10.33333/rp.vol51n2.05

Examples

library(MTest)
data(simDataMTest)
m1 <- lm(y~.,data = simDataMTest)

boot.sol <- MTest(m1,trace=FALSE,seed = 1,nboot = 50)
boot.sol$pval_vif
boot.sol$pval_klein
head(boot.sol$Bvals)
print(boot.sol)

pairwiseKStest

Description

Returns the pp-value of the columns of X (pairwisely).

Usage

pairwiseKStest(X,alternative="greater")

Arguments

X

Numeric; a matrix (Bvals output from MTest function) whose columns are to be compared.

alternative

String; letter of the value, but the argument name must be given in full. See ‘ks.test’ for the meanings of the possible values.

Details

Using a pairwise Kolmogorov-Smirnov (KS) test of a given matrix X. In particular, if X is the Bvals output from MTest function, pairwiseKStest establishes a guide for an educated removal of variables that are causing multicolli-nearity.

Note that the matrix Bnboot×(p+1)B_{n_{boot}\times (p+1)} (which is Bvals output from MTest function) allow us to inspect results in detail and make further tests such as boxplots, pariwise Kolmogorov-Smirnov (KS) of the predictors and so on.

Value

Returns an object of class pairwiseKStest. An object of class pairwiseKStest is a list containing at most the following components:

KSpwMatrix

pp-values matrix of pairwise KS testing;

alternative

Character; indicates the alternative hypothesis.

Suggestion

Character; indicates row sums (or col sums) of KSpwMatrix suggesting the removal order in case that is the strategy for dealing with multicollinearity.

Author(s)

Víctor Morales Oñate, [email protected], https://sites.google.com/site/moralesonatevictor/,https://www.linkedin.com/in/vmoralesonate/ Bolívar Morales Oñate, [email protected], https://sites.google.com/site/moralesonatevictor/

References

Morales-Oñate, V., and Morales-Oñate, B. (2023). MTest: a Bootstrap Test for Multicollinearity. Revista Politécnica, 51(2), 53–62. doi:10.33333/rp.vol51n2.05

Examples

library(MTest)
data(simDataMTest)
pairwiseKStest(X=simDataMTest)

Simulated data for MTest

Description

This data set helps testing functions in MTest package, the generating process is documented in the reference.

Usage

simDataMTest

Format

A dataframe containing 10000 observations and four columns.

References

Morales-Oñate, V., and Morales-Oñate, B. (2023). MTest: a Bootstrap Test for Multicollinearity. Revista Politécnica, 51(2), 53–62. doi:10.33333/rp.vol51n2.05