little_test | R Documentation |
Carry out Little's test of MCAR
little_test(X, alpha, type = "mean&cov")
X |
The dataset with incomplete data, where all the pairs of variables are observed together. |
alpha |
The nominal level of the test. |
type |
Determines the test statistic to use, based on the discussion in Section 5 in \insertCiteBB2024;textualMCARtest.
The default option is "mean&cov", and uses the test statistic |
A Boolean, where TRUE stands for reject MCAR. This is computed by comparing the p-value of Little's test,
found by comparing the log likelihood ratio statistic to the chi-squared distribution with the appropriate number
of degrees of freedom, with the nominal level alpha
. Described in \insertCiteLittle1988;textualMCARtest.
BB2024MCARtest
\insertRefLittle1988MCARtest
library(MASS)
alpha = 0.05
n = 200
SigmaS=list() #Random 2x2 correlation matrices (necessarily consistent)
for(j in 1:3){
x=runif(2,min=-1,max=1); y=runif(2,min=-1,max=1)
SigmaS[[j]]=cov2cor(x%*%t(x) + y%*%t(y))
}
X1 = mvrnorm(n, c(0,0), SigmaS[[1]])
X2 = mvrnorm(n, c(0,0), SigmaS[[2]])
X3 = mvrnorm(n, c(0,0), SigmaS[[3]])
columns = c("X1","X2","X3")
X = data.frame(matrix(nrow = 3*n, ncol = 3))
X[1:n, c("X1", "X2")] = X1
X[(n+1):(2*n), c("X2", "X3")] = X2
X[(2*n+1):(3*n), c("X1", "X3")] = X3
X = as.matrix(X)
little_test(X, alpha)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.