Programming

Estimating a 2-PL Model in Julia (Part 2)

E-Step M-Step Estimating a 2-PL Model with EM in Julia Find \(\bar r_{jk}\) and \(\bar n_k\) Solve estimating equations Iterations Stopping criteria Benchmarking Remark \[ \newcommand{\bv}[1]{\boldsymbol{\mathbf{#1}}} \]

Using cmdstanr in SimDesign

library(SimDesign) library(cmdstanr) [Update: Use parallel computing with two cores.] Adapted from https://cran.r-project.org/web/packages/SimDesign/vignettes/SimDesign-intro.html See https://mc-stan.org/cmdstanr/articles/cmdstanr.html for using cmdstanr Design <- createDesign(sample_size = c(30, 60, 120, 240), distribution = c('norm', 'chi')) Design ## # A tibble: 8 × 2 ## sample_size distribution ## <dbl> <chr> ## 1 30 norm ## 2 60 norm ## 3 120 norm ## 4 240 norm ## 5 30 chi ## 6 60 chi ## 7 120 chi ## 8 240 chi Generate <- function(condition, fixed_objects = NULL) { N <- condition$sample_size dist <- condition$distribution if(dist == 'norm'){ dat <- rnorm(N, mean = 3) } else if(dist == 'chi'){ dat <- rchisq(N, df = 3) } dat } Define Bayes estimator of the mean with STAN

Piping with `magrittr`

I have just spent a semester teaching multilevel modeling, and in the R codes I provided, I usually use the pipe operator (%>%). For example, to compute the cluster means, we can do