---
title: "GRShiny"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{GRShiny}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  eval = T,
  collapse = TRUE,
  out.width = "50%",
  fig.width = 7,
  comment = "#>"
)
```

```{r setup}
library(GRShiny)
```

<!-- badges: start -->
  [![CRAN status](https://www.r-pkg.org/badges/version/GRShiny)](https://CRAN.R-project.org/package=GRShiny)
<!-- badges: end -->

## GRM data simulation

### Item parameters for graded response model

```{r}
item_pars <- genIRTpar(nitem = 10, ncat = 3, nfac = 1)
```

### Individual true latent traits

```{r}
true_theta <- genTheta(nsample = 500, nfac = 1)
```

### GRM data

```{r}
grm_dt <- genData(eta = true_theta, ipar = item_pars)
```

## GRM data simulation

### Generate lavaan syntax

```{r}
lav_syn <- genLavSyn(dat = grm_dt, nfac = 1)
```

### Conduct GRM with two different estimators

```{r}
grm.fit <- runGRM(dat = grm_dt, lav.syntax = lav_syn, estimator = "WL")
```

## Results

### parameter estimates

```{r}
extract_est(grm.fit)
```

### IRT plots

```{r}
ICCplot(grm.fit, 1)
ESplot(grm.fit , 1)
infoPlot(grm.fit, 1)
FSplot(grm.fit)
```


## Launch app

```{r eval = F}
startGRshiny()
```
