I was talking to a colleague about modeling nominal outcomes in STAN, and wrote up this example. Just put it here in case it’s helpful for anyone (probably myself in the future).

In this post, I demonstrate why rescaling a coefficient (i.e., multiplied/divided by a constant) is different from “standardizing” a coefficient (i.e., multiplied/divided by the sample standard deviation, which is a random variable) in SEM.

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}}} \]

Import Data Two-Parameter Logistic Model Estimation with mirt in R Marginal Maximum Likelihood (MML) Estimation Implement MML Estimation in Julia Import R data Compute marginal loglikelihood Optimization Benchmarking The semester is finally over, and for some reason, I wanted to consolidate my understanding of some psychometric models, perhaps because I’ll be teaching a graduate measurement class soon.

Load Packages An Example Multilevel Model Nakagawa-Johnson-Schielzeth \(R^2\) Right-Sterba \(R^2\) Confidence Intervals for \(R^2\) Parametric Bootstrap Bias-corrected estimate Confidence intervals Residual Bootstrap Confidence Intervals Bootstrap CI With Transformation Conclusion Load Packages library(lme4) ## Loading required package: Matrix library(MuMIn) # for computing multilevel R-squared library(r2mlm) # another package for R-squared ## Loading required package: nlme ## ## Attaching package: 'nlme' ## The following object is masked from 'package:lme4': ## ## lmList ## Registered S3 method overwritten by 'parameters': ## method from ## format.

Load Packages Data Hypothetical Research Question Distinguishable Dyads Indistinguishable Dyads Model Comparison Using SEM Distinguishable Dyads Indistinguishable Dyads Every time I teach multilevel modeling (MLM) at USC, I have students interested in running the actor partner independence model (APIM) using dyadic model.

I was working on an extension to the two-stage path analysis Lai & Hsiao (2021) related to integrative data analysis, and ran into an issue described in Davoudzadeh et al.

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

Load Required Packages Data Description Data Import Mixed ANOVA ANOVA Table Plot Sample Result Reporting Load Required Packages library(afex) ## Loading required package: lme4 ## Loading required package: Matrix ## ************ ## Welcome to afex.

One thing that I always felt uncomfortable in multilevel modeling (MLM) is the concept of a unit-specific (US)/subject-specific model vs. a population-average (PA) model. I’ve come across it several times, but for some reason I haven’t really made an effort to fully understand it.

© 2022 Hok Chio (Mark) Lai

Powered by the Academic theme for Hugo.