Learn R Programming

eRm (version 0.15-6)

NonparametricTests: A Function to Perform Nonparametric Rasch Model Tests

Description

A variety of nonparametric tests as proposed by Ponocny (2001), Koller and Hatzinger (2012), and an exact version of the Martin-Löf test are implemented. The function operates on random binary matrices that have been generated using an MCMC algorithm (Verhelst, 2008) from the RaschSampler package (Hatzinger, Mair, and Verhelst, 2009).

Usage

NPtest(obj, n = NULL, method = "T1", ...)

Arguments

obj
A binary data matrix (or data frame) or an object containing the output from the RaschSampler package.
n
If obj is a matrix or a data frame, n is the number of sampled matrices (default is 500)
method
One of the test statistics. See Details below.
...
Further arguments according to method. See Details below. Additionally, the sampling routine can be controlled by specifying burn_in, step, and seed (for details see below and

Value

  • Depending on the method argument, a list is returned which has one of the following classes: 'T1obj', 'T1mobj', 'T1lobj', 'Tmdobj', 'T2obj', 'T2mobj', 'T4obj', 'T10obj', 'T11obj', or 'Tpbisobj'. The main output element is prop giving the one-sided $p$-value, i.e., the number of statistics from the sampled matrices which are equal or exceed the statistic based on the observed data. For $T_1$, $T_{1m}$, and $T_{1l}$, prop is a vector. For the Martin-Löf test, the returned object is of class 'MLobj'. Besides other elements, it contains a prop vector and MLres, the output object from the asymptotic Martin-Löf test on the input data.

encoding

UTF-8

Details

The function uses the RaschSampler package, which is now packaged with eRm for convenience. It can, of course, still be accessed and downloaded separately via CRAN. As an input the user has to supply either a binary data matrix or a RaschSampler output object. If the input is a data matrix, the RaschSampler is called with default values (i.e., rsctrl(burn_in = 256, n_eff = n, step = 32), see rsctrl), where n corresponds to n_eff (the default number of sampled matrices is 500). By default, the starting values for the random number generators (seed) are chosen randomly using system time. Methods other than those listed below can easily be implemented using the RaschSampler package directly. The currently implemented methods (following Ponocny's notation of $T$-statistics) and their options are: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

References

Ponocny, I. (2001). Nonparametric goodness-of-fit tests for the Rasch model. Psychometrika, 66(3), 437--459. http://dx.doi.org/10.1007/BF02294444 Verhelst, N. D. (2008). An efficient MCMC algorithm to sample binary matrices with fixed marginals. Psychometrika, 73(4), 705--728. http://dx.doi.org/10.1007/s11336-008-9062-3 Verhelst, N., Hatzinger, R., & Mair, P. (2007). The Rasch sampler. Journal of Statistical Software, 20(4), 1--14. http://www.jstatsoft.org/v20/i04 Koller, I., & Hatzinger, R. (2013). Nonparametric tests for the Rasch model: Explanation, development, and application of quasi-exact tests for small samples. Interstat, 11, 1--16. http://interstat.statjournals.net/YEAR/2013/abstracts/1311002.php Koller, I., Maier, M. J., & Hatzinger, R. (2015). An Empirical Power Analysis of Quasi-Exact Tests for the Rasch Model: Measurement Invariance in Small Samples. Methodology, 11(2), 45--54. http://dx.doi.org/10.1027/1614-2241/a000090

Examples

Run this code
### Preparation:

# data for examples below
X <- raschdat1

# generate 100 random matrices based on original data matrix
rmat <- rsampler(X, rsctrl(burn_in = 100, n_eff = 100, seed = 123))

## the following examples can also directly be used by setting
## rmat <- raschdat1
## without calling rsampler() first, e.g.,
t1 <- NPtest(raschdat1, n = 100, method = "T1")


### Examples ###################################################################

###--- T1 ----------------------------------------------------------------------
t1 <- NPtest(rmat, method = "T1")
# choose a different alpha for selecting displayed values
print(t1, alpha = 0.01)


###--- T2 ----------------------------------------------------------------------
t21 <- NPtest(rmat, method = "T2", idx = 1:5, burn_in = 100, step = 20,
              seed = 7654321, RSinfo = TRUE)
# default stat is variance
t21

t22 <- NPtest(rmat, method = "T2", stat = "mad1",
              idx = c(1, 22, 5, 27, 6, 9, 11))
t22


###--- T4 ----------------------------------------------------------------------
age <- sample(20:90, 100, replace = TRUE)
# group MUST be a logical vector
# (value of TRUE is used for group selection)
age <- age < 30
t41 <- NPtest(rmat, method = "T4", idx = 1:3, group = age)
t41

sex <- gl(2, 50)
# group can also be a logical expression (generating a vector)
t42 <- NPtest(rmat, method = "T4", idx = c(1, 4, 5, 6), group = sex == 1)
t42


###--- T10 ---------------------------------------------------------------------
t101 <- NPtest(rmat, method = "T10")       # default split criterion is "median"
t101

split <- runif(100)
t102 <- NPtest(rmat, method = "T10", splitcr = split > 0.5)
t102

t103 <- NPtest(rmat, method = "T10", splitcr = sex)
t103


###--- T11 ---------------------------------------------------------------------
t11 <- NPtest(rmat, method = "T11")
t11


###--- Tpbis -------------------------------------------------------------------
tpb <- NPtest(X[, 1:5], method = "Tpbis", idxt = 1, idxs = 2:5)
tpb


###--- Martin-Löf --------------------------------------------------------------
# takes a while ...
split <- rep(1:3, each = 10)
NPtest(raschdat1, n = 100, method = "MLoef", splitcr = split)

Run the code above in your browser using DataLab