R

Visuliaztion of Item Information Curves In R

Item Information Curve This blog is to show a new way to display item information curves using ggridges package. The ridge plot could show the IIF plots very clear when you have a large number of items. ggplot(item_information_all %>% filter(item %in% 17:22)) + aes(x = factor, y = item, height = info, group = item, color = as.factor(item), fill = as.factor(item)) + ggridges::geom_ridgeline(alpha = 0.75) + ggtitle("Peer Social Capital: Information Functions") + theme_ridges()

[Manual]Using Jags and R2jags in R

This post is aimed to introduce the basics of using jags in R programming. Jags is a frequently used program for conducting Bayesian statistics.Most of information below is borrowed from Jeromy Anglim’s Blog. I will keep editing this post if I found more resources about jags. What is JAGS? JAGS stands for Just Another Gibbs Sampler. To quote the program author, Martyn Plummer, “It is a program for analysis of Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation…” It uses a dialect of the BUGS language, similar but a little different to OpenBUGS and WinBUGS.

Introduce Descrepancy Measures

Descrepancy Measures This Blog is the notes for my recent project about reliability and model checking. Next I want to organize a little about one important concept in model checking - discrepancy measures. Descrepancy Measures \(\chi^2\) measures for item-pairs (Chen & Thissen, 1997) \[ X^2_{jj'}=\sum_{k=0}^{1} \sum_{k'=0}^{1} \frac{(n_{kk'}-E(n_{kk'}))^2}{E(n_{kk'})} \] \(G^2\) for item pairs \[ G^2_{jj'}=-2\sum_{k=0}^{1} \sum_{k'=0}^{1} \ln \frac{E(n_{kk'})}{n_{kk'}} \] model-based covariance (MBC; Reckase, 1997) \[ COV_{jj'} = \frac{\sum_{i=1}^{N}(X_{ij}-\overline{X_j})(X_{ij'}-\overline{X_{j'}}) }{N} \\ MBC_{jj'} = \frac{\sum_{i=1}^{N}(X_{ij}-E(X_{ij}))(X_{ij'}-E(X_{ij'}))}{N} \]

How to do Data Cleaning in R

Libraries Step 1: Import Data Step 2: Initial Check Step 2.1: check variables step 2.2: check missing values and ranges step 2.3: check first and last cases Step 3: Select and rename Variables Step 4: Remove missing values This blog is trying to elaborate steps for cleaning the data. Since datasets varied, this blog could not cover all. Depedent on the data you’re using, different methods should be used.

Updating R Version Without missing packages

After updating to new R version (4.5) from old version, you have to re-install all packages by default. However, there’re some solution for that. Unix (MacOs, Linux) 1.Create a new folder in home directory to store the packages. Sometimes, you need to change the permission level for this folder, or R may not have access to write this folder. Rlibs is a special folder where you can store all you packages.

How to use Lavaan for Confirmatory Factor Analysis

This is one of my homework in Structural Equation Modeling in Fall 2017. Dr. Templin provided a excelent example showing how to perform Confirmatory Factor Analysis (CFA) using Lavaan Package. I elaborated each step as following. First, load packages needed: If you don’t have the packages installed below, please use install.packages() to install them. library(tidyverse) library(lavaan) #library(semPlot) library(psych) library(knitr) library(kableExtra) 0. Background CFA on Attitude towards Inclusive Education Survey (N = 507) The affective dimension of attitudes subscale includes 6 items on a 6-point likert scale (1 = Strongly Agree, 6 = Strongly Disagree), measuring teachers’ feelings and emotions associated with inclusive education: