## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") has_erm <- requireNamespace("eRm", quietly = TRUE) ## ----ppass-------------------------------------------------------------------- library(PP) data(fourpl_df) res <- PPass(fourpl_df, items = 3:14, thres = attr(fourpl_df, "diffpar"), slopes = attr(fourpl_df, "slopes"), lowerA = attr(fourpl_df, "lowerA")) res ## ----summary------------------------------------------------------------------ s <- summary(res) ## ----plot, fig.width = 6, fig.height = 4.5, fig.alt = "lz* of every person against the WLE estimate, flagged persons highlighted and labelled with their id"---- plot(res, label = "id") ## ----df----------------------------------------------------------------------- res[res$sex == "w" & res$status == "ok", c("id", "estimate", "SE", "lzstar")][1:5, ] knitr::kable(head(as.data.frame(res)[, c("id", "sex", "estimate", "SE", "lzstar", "infit")]), digits = 3) ## ----jk----------------------------------------------------------------------- head(JKpp(res)$estimates) ## ----erm-note, echo = FALSE, results = "asis", eval = !has_erm---------------- # cat("*The eRm package is not installed, so the code of this section is shown without results.*\n") ## ----rm, eval = has_erm------------------------------------------------------- library(eRm) rm1 <- RM(raschdat1) res_rm <- PPass(rm1) res_rm ## ----rm-mle, eval = has_erm--------------------------------------------------- res_mle <- PPass(rm1, type = "mle", fitindices = "lzstar") pp <- person.parameter(rm1) ok <- res_mle$status == "ok" max(abs(res_mle$estimate[ok] - pp$theta.table[ok, "Person Parameter"])) ## ----pcm, eval = has_erm------------------------------------------------------ set.seed(2751) thres <- rbind(c(-2, -1.2, -0.5, 0), c(-1, 0.3, 1, 1.5), c(0.5, NA, NA, 2)) x <- sim_gpcm(thres = thres, alpha = 1, theta = rnorm(300)) res_pcm <- PPass(PCM(x), type = "map") summary(res_pcm$estimate) ## ----lpcm, eval = has_erm----------------------------------------------------- x2 <- sim_gpcm(thres = thres, alpha = 1, theta = rnorm(300, 0.5)) lpcm <- LPCM(cbind(x, x2), mpoints = 2, groupvec = rep(1:2, 150)) res_lpcm <- PPass(lpcm) res_lpcm ## ----pv, eval = has_erm------------------------------------------------------- set.seed(1) pv <- PV(res_pcm, npv = 5) head(pv$pvdraws, 3)