| Title: | Statistical Power Simulation for Testing the Rasch Model |
|---|---|
| Description: | Statistical power simulation for testing the Rasch Model based on a three-way analysis of variance design with mixed classification. |
| Authors: | Takuya Yanagida [cre, aut], Jan Steinfeld [aut], Thomas Kiefer [ctb] |
| Maintainer: | Takuya Yanagida <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1-4 |
| Built: | 2026-05-21 07:55:49 UTC |
| Source: | https://github.com/cran/pwrRasch |
A dataset containing the test data of 300 childen (drawn randomly from the original dataset). The variables are as follows:
aid_st2aid_st2
A data frame with 300 rows and 28 variables:
ID: ID variable of each testee
age_in_month: the age of the testee in month
sex: gender of the testee
country: country of the testee
stage: stage of the data collection
it1...it18: items of the subtest 2
This function applies the three-way analysis of variance with mixed classification for testing the Rasch model.
aov.rasch( data, group = "group", person = "person", item = "item", response = "response", output = TRUE )aov.rasch( data, group = "group", person = "person", item = "item", response = "response", output = TRUE )
data |
A data frame in which the variables specified in the model will be found. Note that data needs to be in 'long' format. |
group |
Column name of the data frame containing the grouping variable. |
person |
Column name of the data frame containing the person number variable. |
item |
Column name of the data frame containing the item number variable. |
response |
Column name of the data frame containing the response variable. |
output |
If |
The F-test in a three-way analysis of variance design (A > B) x C with mixed classification (fixed factor A = subgroup, random factor B = testees, and fixed factor C = items) is used to test the Rasch model. Rasch model fitting means that there is no interaction A x C. A statistically significant interaction A x C indicates differential item functioning (DIF) of the items with respect of the two groups of testees Note, if a main effect of A (subgroup) exists, an artificially high type I risk of the A x C interaction F-test results - that is, the approach works as long as no statistically significant main effect of A occurs. Note that in case of unbalanced groups computation can take a long time.
Returns an ANOVA table
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
Kubinger, K. D., Rasch, D., & Yanagida, T. (2009). On designing data-sampling for Rasch model calibrating an achievement test. Psychology Science Quarterly, 51, 370-384.
Kubinger, K. D., Rasch, D., & Yanagida, T. (2011). A new approach for testing the Rasch model. Educational Research and Evaluation, 17, 321-333.
## Not run: # simulate Rasch model based data # 100 persons, 20 items, dat <- simul.rasch(100, items = seq(-3, 3, length.out = 20)) # reshape simulated data into 'long' format with balanced assignment # of testees into two subgroups dat.long <- reshape.rasch(dat, group = rep(0:1, each = nrow(dat) / 2)) # apply three-way analysis of variance with mixed classification for testing the Rasch model aov.rasch(dat.long) # extract variable names of items vnames <- grep("it", names(aid_st2), value = TRUE) # reshape aid subtest 2 data into 'long' format with split criterium sex aid_long.sex <- reshape.rasch(aid_st2[, vnames], group = aid_st2[, "sex"]) # apply three-way analysis of variance with mixed classification for testing the Rasch model aov.rasch(aid_long.sex) ## End(Not run)## Not run: # simulate Rasch model based data # 100 persons, 20 items, dat <- simul.rasch(100, items = seq(-3, 3, length.out = 20)) # reshape simulated data into 'long' format with balanced assignment # of testees into two subgroups dat.long <- reshape.rasch(dat, group = rep(0:1, each = nrow(dat) / 2)) # apply three-way analysis of variance with mixed classification for testing the Rasch model aov.rasch(dat.long) # extract variable names of items vnames <- grep("it", names(aid_st2), value = TRUE) # reshape aid subtest 2 data into 'long' format with split criterium sex aid_long.sex <- reshape.rasch(aid_st2[, vnames], group = aid_st2[, "sex"]) # apply three-way analysis of variance with mixed classification for testing the Rasch model aov.rasch(aid_long.sex) ## End(Not run)
This function builds a table of DIF items specified in the pwrrasch object
itemtable(object, all = FALSE, digits = 2)itemtable(object, all = FALSE, digits = 2)
object |
|
all |
If |
digits |
Integer indicating the number of decimal places. |
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 100 simres <- pwr.rasch(100, ipar = list(ipar1, ipar2)) itemtable(simres) ## End(Not run)## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 100 simres <- pwr.rasch(100, ipar = list(ipar1, ipar2)) itemtable(simres) ## End(Not run)
Generic plot function for the pwrrasch object, which
plots the statistical power curve relating statistical power to sample size
## S3 method for class 'pwrrasch' plot( x, plot.sig.level = TRUE, type = c("b", "b"), pch = c(19, 17), lty = c(1, 3), lwd = c(1, 1), legend = "topleft", bty = "o", ... )## S3 method for class 'pwrrasch' plot( x, plot.sig.level = TRUE, type = c("b", "b"), pch = c(19, 17), lty = c(1, 3), lwd = c(1, 1), legend = "topleft", bty = "o", ... )
x |
|
plot.sig.level |
If |
type |
Vector indicating type of plot for the statistica power curve and the type 1 risk curve. |
pch |
Vector indicating plotting symbol for the statistical power curve and the type 1 risk curve. |
lty |
Vector indicating line type for the statistical power curve and the type 1 risk curve. |
lwd |
Vector indicating line width for the statistical power curve and the type 1 risk curve. |
legend |
Location of the legend. If |
bty |
Type of box to be drawn around the legend. |
... |
Additional arguments affecting the summary produced. |
Graphical parameters are:
type The following values are possible: "p" for points,
"l" for lines, "b" for both point and lines
pch see points
lty Line types can be specified as an integer (0 = blank, 1 = solid,
2 = dashed, 3 = dotted, 4 = dotdash, 5 = longdash,
6 = twodash)
lwd Positive numbers indicating line widths
legend Either the x and y coordinates to be used to position the legend or
keyword from the list "bottomright", "bottom", "bottomleft",
"left", "topleft", "top", "topright", "right"
and "center"
bty Allowed values are "o" (draw box around legend) and "n" (do not draw box around legend).
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
Kubinger, K. D., Rasch, D., & Yanagida, T. (2009). On designing data-sampling for Rasch model calibrating an achievement test. Psychology Science Quarterly, 51, 370-384.
Kubinger, K. D., Rasch, D., & Yanagida, T. (2011). A new approach for testing the Rasch model. Educational Research and Evaluation, 17, 321-333.
## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 100, 200, 300, 400, 500 simres <- pwr.rasch(seq(100, 500, by = 100), ipar = list(ipar1, ipar2)) plot(simres) ## End(Not run)## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 100, 200, 300, 400, 500 simres <- pwr.rasch(seq(100, 500, by = 100), ipar = list(ipar1, ipar2)) plot(simres) ## End(Not run)
This function conducts a simulation to estimate statistical power of a Rasch model test for user-specified item and person parameters.
pwr.rasch( b, ipar = list(), design = NULL, ppar = list("rnorm(b, mean = 0, sd = 1.5)", "rnorm(b, mean = 0, sd = 1.5)"), runs = 1000, H0 = TRUE, sig.level = 0.05, method = c("loop", "vectorized"), output = TRUE )pwr.rasch( b, ipar = list(), design = NULL, ppar = list("rnorm(b, mean = 0, sd = 1.5)", "rnorm(b, mean = 0, sd = 1.5)"), runs = 1000, H0 = TRUE, sig.level = 0.05, method = c("loop", "vectorized"), output = TRUE )
b |
Either a vector or an integer indicating the number of observations in each group. |
ipar |
Item parameters in both groups specified in a list. |
design |
Test booklet design |
ppar |
Person parameters specified by a distribution for each group. |
runs |
Number of simulation runs. |
H0 |
If |
sig.level |
Nominal significance level. |
method |
Simulation method: for-loop or vectorized. |
output |
If |
The F-test in a three-way analysis of variance design (A > B) x C
with mixed classification (fixed factor A = subgroup, random factor B = testee,
and fixed factor C = items) is used to simulate statistical power of a
Rasch model test. This approach using a F-distributed statistic, where
the sample size directly affects the degree of freedom enables determination
of the sample size according to a given type I and type II risk, and according
to a certain effect of model misfit which is of practical relevance.
Note, that this approach works as long as there exists no main effect of
A (subgroup). Otherwise an artificially high type I risk of the A x C interaction
F-test results - that is, the approach works as long as no statistically significant
main effect of A occurs.
Returns a list with following entries:
b |
number of observations in each group |
ipar |
item parameters in both subgroups |
design |
test booklet design |
c |
number of items |
ppar |
distribution of person parameters |
runs |
number of simulation runs |
sig.level |
nominal significance level |
H0.AC.p |
p-values of the interaction A x C in the null hypothesis condition (if H0 = TRUE) |
H1.AC.p |
p-values of the interaction A x C in the alternative hypothesis condition |
power |
estimated statistical power |
type1 |
estimated significance level |
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
Kubinger, K. D., Rasch, D., & Yanagida, T. (2009). On designing data-sampling for Rasch model calibrating an achievement test. Psychology Science Quarterly, 51, 370-384.
Kubinger, K. D., Rasch, D., & Yanagida, T. (2011). A new approach for testing the Rasch model. Educational Research and Evaluation, 17, 321-333.
## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 200 pwr.rasch(200, ipar = list(ipar1, ipar2)) # simulation for b = 100, 200, 300, 400, 500 pwr.rasch(seq(100, 500, by = 100), ipar = list(ipar1, ipar2)) # simulation for b = 100, 200, 300, 400, 500 # uniform distribution [-3, 3] of person parameters pwr.rasch(200, ipar = list(ipar1, ipar2), ppar = list("runif(b, -3, 3)", "runif(b, -3, 3)")) ## End(Not run)## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 200 pwr.rasch(200, ipar = list(ipar1, ipar2)) # simulation for b = 100, 200, 300, 400, 500 pwr.rasch(seq(100, 500, by = 100), ipar = list(ipar1, ipar2)) # simulation for b = 100, 200, 300, 400, 500 # uniform distribution [-3, 3] of person parameters pwr.rasch(200, ipar = list(ipar1, ipar2), ppar = list("runif(b, -3, 3)", "runif(b, -3, 3)")) ## End(Not run)
Statistical power simulation for testing the Rasch Model based on a three-way analysis of variance design with mixed classification.
Takuya Yanagida [aut,cre] [email protected], Jan Steinfeld [aut] [email protected], Thomas Kiefer [ctb]
Maintainer: Takuya Yanagida <[email protected]>
Kubinger, K. D., Rasch, D., & Yanagida, T. (2009). On designing data-sampling for Rasch model calibrating an achievement test. Psychology Science Quarterly, 51, 370-384.
Kubinger, K. D., Rasch, D., & Yanagida, T. (2011). A new approach for testing the Rasch model. Educational Research and Evaluation, 17, 321-333.
Verhelst, N. D. (2008). An efficient MCMC algorithm to sample binary matrices with fixed marginals. Psychometrika, 73(4), 705-728.
Verhelst, N., Hatzinger, R., & Mair, P. (2007). The Rasch sampler. Journal of Statistical Software, 20(4), 1-14.
This function reshapes a matrix from 'wide' into a 'long' format. This is necessary for the three-way analysis of variance with mixed classification for testing the Rasch model.
reshape.rasch(data, group)reshape.rasch(data, group)
data |
Matrix or data frame in 'wide' format. |
group |
Vector which assigns each person to a certain subgroup (external split criterion). Note, that this function is restricted to A = 2 subgroups. |
In order to apply the three-way analysis of variance with mixed classification for testing the Rasch model, data need to be in 'long' format. That is, Rasch model data design is interpreted as a analysis of variance design (A > B) x C, where items are levels of a fixed factor C and the testees are levels of a random factor B, nested within a fixed factor A of different subgroups.
Returns a data frame with following entries:
group |
fixed factor A (subgroup) |
person |
random factor B (testees) |
item |
fixed factor C (items) |
response |
dependent variable, 0 (item not solved) and 1 (item solved) |
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
Kubinger, K. D., Rasch, D., & Yanagida, T. (2009). On designing data-sampling for Rasch model calibrating an achievement test. Psychology Science Quarterly, 51, 370-384.
Kubinger, K. D., Rasch, D., & Yanagida, T. (2011). A new approach for testing the Rasch model. Educational Research and Evaluation, 17, 321-333.
## Not run: # simulate Rasch model based data # 100 persons, 20 items, dat <- simul.rasch(100, items = seq(-3, 3, length.out = 20)) # reshape simulated data into 'long' format with balanced assignment # of testees into two subgroups. dat.long <- reshape.rasch(dat, group = rep(0:1, each = nrow(dat) / 2)) head(dat.long) # extract variable names of items vnames <- grep("it", names(aid_st2), value = TRUE) # reshape aid subtest 2 data into 'long' format with split criterium sex aid_long.sex <- reshape.rasch(aid_st2[, vnames], group = aid_st2[, "sex"]) ## End(Not run)## Not run: # simulate Rasch model based data # 100 persons, 20 items, dat <- simul.rasch(100, items = seq(-3, 3, length.out = 20)) # reshape simulated data into 'long' format with balanced assignment # of testees into two subgroups. dat.long <- reshape.rasch(dat, group = rep(0:1, each = nrow(dat) / 2)) head(dat.long) # extract variable names of items vnames <- grep("it", names(aid_st2), value = TRUE) # reshape aid subtest 2 data into 'long' format with split criterium sex aid_long.sex <- reshape.rasch(aid_st2[, vnames], group = aid_st2[, "sex"]) ## End(Not run)
This function simulates data according to the Rasch model based on user-specified item and person parameters and an optionally specified test booklet design.
simul.rasch(persons, items, design = NULL, sum0 = TRUE)simul.rasch(persons, items, design = NULL, sum0 = TRUE)
persons |
Either a vector of specified person parameters, an integer indicating the number of persons,
or a list with vectors of specified person parameters or integers corresponding to the
number of bookelts specified in |
items |
Either a vector of specified item parameters or an integer indicating the number of items. |
design |
Test booklet design matrix with 0 (item not administered) and 1 (item administered) entries. |
sum0 |
If |
If persons is an integer value, the corresponding parameter vector
is drawn from N(0, 1.5). If items is an integer value, the corresponding parameter vector
is equally spaced between [-3, 3]. Note that item parameters need to be normalized to sum-0.
This precondition can be overruled using argument sum0 = FALSE. If !is.null(design),
the integer value represents the number of persons in each booklet. Note that unequal number of persons
per booklet is specified in a list corresponding to the number of booklets.
Returns a 0-1 matrix according to the Rasch model.
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
Kubinger, K. D., Rasch, D., & Yanagida, T. (2009). On designing data-sampling for Rasch model calibrating an achievement test. Psychology Science Quarterly, 51, 370-384.
Kubinger, K. D., Rasch, D., & Yanagida, T. (2011). A new approach for testing the Rasch model. Educational Research and Evaluation, 17, 321-333.
## Not run: # simulate Rasch model based data # 100 persons, 20 items, # person parameter drawn from a normal distribution: N(0, 1.5) # item parameters equally spaced between [-3, 3] simul.rasch(100, items = 20) # simulate Rasch model based data # 100 persons, 17 items # person parameter drawn from a uniform distribution: U[-4, 4] # item parameters: [-4.0, -3.5, -3.0, ... , 3.0, 3.5, 4.0] simul.rasch(runif(100, -4, 4), items = seq(-4, 4, by = 0.5)) # specify test booklet design with three items design <- matrix(c(1, 1, 0, 1, 0, 1, 0, 1, 1), ncol = 3) # 100 persons in each booklet # person parameter drawn from a normal distribution: N(0, 1.5) # item parameters equally spaced between [-3, 3] simul.rasch(100, items = 3, design = design) # 100 persons in each booklet # person parameter drawn from a uniform distribution: U[-4, 4] # item parameters equally spaced between [-3, 3] simul.rasch(runif(100, -4, 4), items = 3, design = design) # 10 persons in booklet 1 / 20 persons in booklet 2 / 30 persons in booklet 3 # person parameter drawn from a normal distribution: N(0, 1.5) # item parameters equally spaced between [-3, 3] simul.rasch(list(10, 20, 30), items = 3, design = design) # 10 persons in booklet 1 / 20 persons in booklet 2 / 30 persons in booklet 3 # person parameter drawn from a uniform distribution: U[-4, 4] # item parameters equally spaced between [-4, 4] simul.rasch(list(runif(10, -4, 4), runif(20, -4, 4), runif(30, -4, 4)), items = seq(-4, 4, length.out = 3), design = design) ## End(Not run)## Not run: # simulate Rasch model based data # 100 persons, 20 items, # person parameter drawn from a normal distribution: N(0, 1.5) # item parameters equally spaced between [-3, 3] simul.rasch(100, items = 20) # simulate Rasch model based data # 100 persons, 17 items # person parameter drawn from a uniform distribution: U[-4, 4] # item parameters: [-4.0, -3.5, -3.0, ... , 3.0, 3.5, 4.0] simul.rasch(runif(100, -4, 4), items = seq(-4, 4, by = 0.5)) # specify test booklet design with three items design <- matrix(c(1, 1, 0, 1, 0, 1, 0, 1, 1), ncol = 3) # 100 persons in each booklet # person parameter drawn from a normal distribution: N(0, 1.5) # item parameters equally spaced between [-3, 3] simul.rasch(100, items = 3, design = design) # 100 persons in each booklet # person parameter drawn from a uniform distribution: U[-4, 4] # item parameters equally spaced between [-3, 3] simul.rasch(runif(100, -4, 4), items = 3, design = design) # 10 persons in booklet 1 / 20 persons in booklet 2 / 30 persons in booklet 3 # person parameter drawn from a normal distribution: N(0, 1.5) # item parameters equally spaced between [-3, 3] simul.rasch(list(10, 20, 30), items = 3, design = design) # 10 persons in booklet 1 / 20 persons in booklet 2 / 30 persons in booklet 3 # person parameter drawn from a uniform distribution: U[-4, 4] # item parameters equally spaced between [-4, 4] simul.rasch(list(runif(10, -4, 4), runif(20, -4, 4), runif(30, -4, 4)), items = seq(-4, 4, length.out = 3), design = design) ## End(Not run)
Generic summary function for the aovrasch object
## S3 method for class 'aovrasch' summary(object, ...)## S3 method for class 'aovrasch' summary(object, ...)
object |
|
... |
Additional arguments affecting the summary produced. |
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
## Not run: # simulate Rasch model based data # 100 persons, 20 items, dat <- simul.rasch(100, items = seq(-3, 3, length.out = 20)) # reshape simulated data into 'long' format with balanced assignment # of examinees into two subgroups. dat.long <- reshape.rasch(dat, group = rep(0:1, each = nrow(dat) / 2)) # apply three-way analysis of variance with mixed classification for testing the Rasch model. res <- aov.rasch(dat.long) summary(res) ## End(Not run)## Not run: # simulate Rasch model based data # 100 persons, 20 items, dat <- simul.rasch(100, items = seq(-3, 3, length.out = 20)) # reshape simulated data into 'long' format with balanced assignment # of examinees into two subgroups. dat.long <- reshape.rasch(dat, group = rep(0:1, each = nrow(dat) / 2)) # apply three-way analysis of variance with mixed classification for testing the Rasch model. res <- aov.rasch(dat.long) summary(res) ## End(Not run)
Generic summary function for the pwrrasch object
## S3 method for class 'pwrrasch' summary(object, ...)## S3 method for class 'pwrrasch' summary(object, ...)
object |
|
... |
Additional arguments affecting the summary produced. |
Takuya Yanagida [email protected], Jan Steinfeld [email protected]
## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[9] <- ipar1[12] ipar2[12] <- ipar1[9] # simulation for b = 100 simres <- pwr.rasch(100, ipar = list(ipar1, ipar2)) summary(simres) # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 100, 200, 300, 400, 500 simres <- pwr.rasch(seq(100, 500, by = 100), ipar = list(ipar1, ipar2)) summary(simres) ## End(Not run)## Not run: # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[9] <- ipar1[12] ipar2[12] <- ipar1[9] # simulation for b = 100 simres <- pwr.rasch(100, ipar = list(ipar1, ipar2)) summary(simres) # item parameters ipar2 <- ipar1 <- seq(-3, 3, length.out = 20) # model differential item function (DIF) ipar2[10] <- ipar1[11] ipar2[11] <- ipar1[10] # simulation for b = 100, 200, 300, 400, 500 simres <- pwr.rasch(seq(100, 500, by = 100), ipar = list(ipar1, ipar2)) summary(simres) ## End(Not run)