This package offers implementation of analytical and sampling-based power analyses for the Wald, LR, score, and gradient tests in the frameworks of linear hypotheses and marginal maximum likelihood estimation. The methods are described in our paper (Zimmer et al. (2022), https://doi.org/10.1007/s11336-022-09883-5).

You can install the CRAN version using:

`install.packages("irtpwr")`

Or, you can install the development version of irtpwr from GitHub with:

```
# install.packages('devtools')
::install_github("flxzimmer/irtpwr", build_vignettes = TRUE) devtools
```

We can load the irtpwr package using:

```
library(irtpwr)
library(mirt)
#> Loading required package: stats4
#> Loading required package: lattice
```

We want to know the power and the required sample size for a test of the Rasch vs 2PL model. We use the LSAT 7 data set which is included the mirt package.

As a first step, we load the data set and fit a 2PL model.

```
<- expand.table(LSAT7)
dat <- mirt(dat, 1, verbose = FALSE) mirtfit
```

The 2PL parameters are then used as parameters for the alternative hypothesis in our hypothesis definition.

`<- setup.hypothesis(type = "1PLvs2PL", altpars = mirtfit) hyp `

We can now perform the power analysis. We want to determine the sample size necessary for a power of .8 while using an alpha level of .05.

```
<- irtpwr(hyp = hyp, power = 0.8, alpha = 0.05)
res summary(res)
#>
#> Sample sizes for power = 0.8 (alpha = 0.05):
#>
#> Statistic N
#> Wald 1134
#> LR 887
#> Score 932
#> Gradient 778
#>
#> Method: Analytical
```

Here we see that the gradient statistic would be the most efficient to test our hypothesis: We would need a sample size of 778 to reach our desired power.

We can also plot the power curves to get a more detailed look on the relationships between sample size and power:

`plot(res)`

Further documentation on how to use the package is found in the package vignettes:

- The vignette “demo” gives an introduction of basic features,
- “adding_hypotheses” gives a tutorial on setting up custom hypotheses,
- “hypothesis_templates” includes some templates for hypothesis objects that can be altered for your specific use case.

If the vignettes were included during installation (for example using the methods above), they can be accessed via:

`browsevignettes("irtpwr")`