HV_test {diagL1}R Documentation

Homogeneity of Variance Tests for Linear L1 Models

Description

Homogeneity of Variance Tests for Linear L1 Models

Usage

HV_test(y, x, groups, alpha = 0.05, tolerance = 0.001, max_iteration = 2000)

Arguments

y

A vector with response variables.

x

A matrix with a single explanatory variable.

groups

Vector containing the group index to which the observation belongs.

alpha

Significance level of the test, must be between 0 and 1.

tolerance

threshold that determines when the iterative algorithm should stop (for regL1_het).

max_iteration

maximum number of iterations (for regL1_het).

Details

The 3 statistics to test homogeneity of variance are discussed in Rodrigues (2024), for more details see this reference. In practice, use the HV_LRT statistic results. If possible, use the HV_LRT statistic with a critical value obtained via bootstrap simulation.

Value

A list with results from 3 homogeneity of variance tests

alpha

alpha argument.

asymptotic_critical_value

asymptotic alpha-based test critical value.

HV_LRT

LF1 statistic value using MLE (Maximum Likelihood Estimator).

HV_max_lambda_ratio

p-value of LF1 statistic using MLE.

HV_max_log_lambda_ratio

LF1 statistic value using ROS (Residuals Order Statistics).

number_of_groups

number of groups.

N

overall sample size.

lambda_heteroscedastic

heteroscedastic estimation of the scaling parameters.

lambda_homocedastic

homoscedastic estimation of the scale parameter.

References

Rodrigues, K. A. S. (2024). Analysis of the adjustment of the L1 regression model. Phd dissertation, University of São Paulo, BR.

Examples


set.seed(123)
x1 = matrix(rnorm(20), ncol = 1)
y1 = x1 + rlaplace(20, 0, 1)
x2 = matrix(rnorm(20), ncol = 1)
y2 = x2 + rlaplace(20, 0, 1.5)
x3 = matrix(rnorm(20), ncol = 1)
y3 = x3 + rlaplace(20, 0, 2)
x4 = matrix(rnorm(20), ncol = 1)
y4 = x4 + rlaplace(20, 0, 2.5)
x5 = matrix(rnorm(20), ncol = 1)
y5 = x5 + rlaplace(20, 0, 3)

y = c(y1, y2, y3, y4, y5)
x = rbind(x1, x2, x3, x4, x5)
group_index = c(rep(1,20),rep(2,20),rep(3,20),rep(4,20),rep(5,20))

# Application of the homogeneity of variance test
test_result = HV_test(y, x, group_index)
test_result



[Package diagL1 version 1.0.0 Index]