LF_test {diagL1}R Documentation

Lack of Fit Tests for Linear L1 Models

Description

Lack of Fit Tests for Linear L1 Models

Usage

LF_test(y, x, groups, alpha = 0.05)

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.

Details

The 3 statistics to test lack of fit are discussed in Rodrigues (2024), for more details see this reference. In practice, use the LF1_MLE statistic results. These tests were developed with just one explanatory variable in mind, which is why we include an error if there is more than one explanatory variable.

Value

A list with results from 3 lack of fit tests

alpha

alpha argument.

critical_value

alpha-based test critical value.

LF1_MLE

LF1 statistic value using MLE (Maximum Likelihood Estimator).

LF1_MLE

p-value of LF1 statistic using MLE.

LF1_ROS

LF1 statistic value using ROS (Residuals Order Statistics).

LF2

LF2 statistic value.

modelo_H0

model fitted under H0.

modelo_Ha

model fitted under Ha.

MLE

estimation of the scale parameter of the estimator model via MLE.

ROS

estimation of the scale parameter of the estimator model via ROS.

SAE_H0

SAE (Sum of Absolute Errors) of the adjusted model under H0.

SAE_Ha

SAE (Sum of Absolute Errors) of the adjusted model under Ha.

matrix_mean_x

average of the explanatory variable per group of observations.

number_of_groups

number of groups.

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, 5)
x2 = matrix(rnorm(20), ncol = 1)
y2 = x2 + rlaplace(20, 1, 5)
x3 = matrix(rnorm(20), ncol = 1)
y3 = x3 + rlaplace(20, 2, 5)
x4 = matrix(rnorm(20), ncol = 1)
y4 = x4 + rlaplace(20, 3, 5)
x5 = matrix(rnorm(20), ncol = 1)
y5 = x5 + rlaplace(20, 4, 5)

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 lack of fit test
test_result = LF_test(y, x, group_index)
test_result



[Package diagL1 version 1.0.0 Index]