cvlldiff {modeLLtest} | R Documentation |
Cross-Validated Difference in Means (CVDM) Test with Vector Imputs
Description
Applies cross-validated log-likelihood to test between two methods of estimating a formula. The output identifies the vector from the more appropriate model.
Please cite:
Desmarais, B. A., & Harden, J. J. (2014). An Unbiased Model Comparison Test Using Cross-Validation. Quality & Quantity, 48(4), 2155-2173. doi: 10.1007/s11135-013-9884-7
Usage
cvlldiff(vector1, vector2, df)
Arguments
vector1 |
A numeric vector of cross-validated log-likelihoods. |
vector2 |
A numeric vector of cross-validated log-likelihoods. |
df |
A value of the degrees of freedom in the models. |
Details
This function implements the cross-validated difference in means (CVDM) test between two vectors of cross-validated log-likelihoods. A positive test statistic supports the method that produced the first vector and a negative test statistic supports the second.
Value
An object of class cvlldiff
computed by the cross-validated log likelihood
difference in means test (CVDM). The test statistic object is the Cross-Validated
Johnson's t-test. A positive test statistic supports the first method and a negative test
statistic supports the second.See cvdm_object
for more details.
References
Desmarais, B. A., & Harden, J. J. (2014). An Unbiased Model Comparison Test Using Cross-Validation. Quality & Quantity, 48(4), 2155-2173. doi: 10.1007/s11135-013-9884-7
Examples
set.seed(123456)
b0 <- .2 # True value for the intercept
b1 <- .5 # True value for the slope
n <- 500 # Sample size
X <- runif(n, -1, 1)
Y <- b0 + b1 * X + rnorm(n, 0, 1) # N(0, 1 error)
cvll_ols <- cvll(Y ~ X, data.frame(cbind(Y, X)), method = "OLS")
cvll_mr <- cvll(Y ~ X, data.frame(cbind(Y, X)), method = "MR")
obj_compare <- cvlldiff(cvll_ols$cvll, cvll_mr$cvll, cvll_ols$df)