plot_singlefit: Plot true and estimated parameters.

Description Usage Arguments Examples

Description

Plot estimates from a single fit using jags and stan (or estimates and true values). Only two object of jags.samp/stan.samp/true.par are allowed.

Usage

1
2
plot_singlefit(N, J, S, model, jags.samp, stan.samp, true.par,
  traitItem = rep(1, J), revItem = rep(1, J))

Arguments

N

number of participants

J

number of items

S

number of latent processes to be measured

model

either "2012" or "ext"

jags.samp

a fitted mcmc.list from JAGS

stan.samp

a fitted Stan array

true.par

a list with true values for beta and theta

traitItem

if more than a single trait is measured, items measuring different traits are shown in different colors

revItem

if specified, reversed items are shown as different points

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
# generate data (Boeckenholt, 2012)
N <- 40; J <- 30; n.trait <- 3
traitItem=rep(1:n.trait, each=J/n.trait)
betas <- cbind(runif(J,0,1),
              runif(J,0,1),
              rnorm(J,0,2))
              
# analyze and plot
gen <- generate_irtree_2012(N=N, J=J, betas=betas, traitItem=traitItem, prop.rev=.5)
fit <- fit_irtree(gen$X, gen$revItem, gen$traitItem, fitModel="2012",
                 M= 500, n.chains=4, thin=1, fitMethod="jags", format="jags")
plot_singlefit(N, J, 2+n.trait, "2012", jags.samp=fit, revItem=gen$revItem,traitItem=gen$traitItem,
               true.par=list(theta=gen$theta, betas=gen$betas))
               
# check with stan
fit2 <- fit_irtree(gen$X, gen$revItem, gen$traitItem, fitModel="2012",
                  M= 500, n.chains=4, thin=1, fitMethod="stan", format="jags")
plot_singlefit(N, J, 2+n.trait, "2012", jags.samp=fit, stan=fit2, 
               revItem=gen$revItem,traitItem=gen$traitItem)

## End(Not run)

hplieninger/mpt2irt documentation built on May 17, 2019, 4:54 p.m.