knitr::opts_chunk$set(echo = TRUE)

Introduction

This tutorial is created using R markdown and knitr. It illustrates how to use the GDINA R pacakge (version r packageVersion("GDINA")) to estimate the G-DINA model.

Model Estimation

The following code estimates the G-DINA model.

library(GDINA)

# A simulated data in GDINA package
dat <- sim10GDINA$simdat
Q <- sim10GDINA$simQ

# Estimating GDINA model
est <- GDINA(dat = dat, Q = Q, model = "GDINA")

Summary Information

The following code extracts the summary information from GDINA estimates.

#####################################
#
#      Summary Information
# 
#####################################
# print estimation information
est

# summary information
summary(est)

AIC(est) #AIC
BIC(est) #BIC
logLik(est) #log-likelihood value
deviance(est) # deviance: -2 log-likelihood
npar(est) # number of parameters
nobs(est) # number of observations

The estimated latent class size can be obtained by

extract(est,"posterior.prob")

The tetrachoric correlation between attributes can be calculated by

# psych package needs to be installed
library(psych)
psych::tetrachoric(x = extract(est,"attributepattern"),
                   weight = extract(est,"posterior.prob"))

You can use extract with argument discrim to extract discrimination indices. The first column gives $P(1)-P(0)$ and the second column gives the GDINA discrimination index.

# discrimination indices
extract(est, "discrim")

Model Fit Evaluation

For test level model data fit, use modelfit function:

modelfit(est)

itemfit function also provide test level model fit information:

ift <- itemfit(est)
ift

itemfit also provide item-level fit information:

summary(ift)

Model Parameters

#####################################
#
#      structural parameters
# 
#####################################

The following code gives the item probalities of each reduced latent classes. As shown below, the probability of answering item 1 correctly for individuals who do not master the required attribute is r coef(est)[[1]][1], and the probability of answering item 1 correctly for individuals who master the required attribute is r coef(est)[[1]][2]:

coef(est) # item probabilities of success for each reduced latent class

The following code gives the item probalities of each reduced latent classes with standard errors.

coef(est, withSE = TRUE) # item probabilities of success & standard errors

The following code gives delta parameters.

coef(est, what = "delta") # delta parameters

The following code gives delta parameters with standard errors.

coef(est, what = "delta", withSE = TRUE) # delta parameters

The following code gives $P(0)$ and 1-$P(0)$, which is guessing and slipping parameters.

coef(est, what = "gs") # guessing and slip parameters

The following code gives guessing and slipping parameters with standard errors.

coef(est, what = "gs", withSE = TRUE) # guessing and slip parameters & standard errors

# Estimated proportions of latent classes

The following code gives the proportions of each latent classes. As you can see, the estimated proportion of individuals in the population who do not master any attribute (i.e., 000) is r coef(est,"lambda")[1]:

coef(est,"lambda")
# success probabilities for each latent class

The following code gives item success probabilities for all latent classes,

coef(est,"LCprob")

#####################################
#
#      person parameters
# 
#####################################

The following code returns EAP estimates of attribute patterns (for the first six individuals). As you can see, the EAP estimate of attribute profile for the first individual is (r personparm(est)[1,]):

head(personparm(est)) # EAP estimates of attribute profiles

By specifying what argument, the following code gives MAP estimates of attribute patterns (for the first six individuals).

head(personparm(est, what = "MAP")) # MAP estimates of attribute profiles

The following code extracts MLE estimates of attribute patterns (for the first six individuals).

head(personparm(est, what = "MLE")) # MLE estimates of attribute profiles

Some Plots

#####################################
#
#           Plots
# 
#####################################

#plot item response functions for item 10

The following code gives item response functions of item 10.

plot(est, item = 10)

The following code gives item response functions of item 10 with error bars.

plot(est, item = 10, withSE = TRUE) # with error bars

The following code plots mastery probabilities of three attributes for individuals 1,20 and 50.

#plot mastery probability for individuals 1, 20 and 50
plot(est, what = "mp", person = c(1, 20, 50))

Advanced Topics

#####################################
#
#      Advanced elements
# 
#####################################

head(indlogLik(est)) # individual log-likelihood
head(indlogPost(est)) # individual log-posterior
extract(est,"designmatrix") #design matrix
extract(est,"linkfunc") #link functions

sessionInfo()


Wenchao-Ma/GDINA documentation built on Nov. 13, 2022, 5:35 a.m.