Title: | Semi-Parametric Factor Analysis |
---|---|
Description: | Estimation, scoring, and plotting functions for the semi-parametric factor model proposed by Liu & Wang (2022) <doi:10.1007/s11336-021-09832-8> and Liu & Wang (2023) <arXiv:2303.10079>. Both the conditional densities of observed responses given the latent factors and the joint density of latent factors are estimated non-parametrically. Functional parameters are approximated by smoothing splines, whose coefficients are estimated by penalized maximum likelihood using an expectation-maximization (EM) algorithm. E- and M-steps can be parallelized on multi-thread computing platforms that support 'OpenMP'. Both continuous and unordered categorical response variables are supported. |
Authors: | Yang Liu [cre, aut], Weimeng Wang [aut, ctb] |
Maintainer: | Yang Liu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0 |
Built: | 2024-10-26 04:25:06 UTC |
Source: | https://github.com/cran/spfa |
The package provides estimation, scoring, and plotting functions for the semiparametric parametric factor model proposed by Liu & Wang (2022; 2023). Both the conditional densities of observed responses given the latent factors and the joint density of latent factors are estimated nonparametrically. Functional parameters are approximated by smoothing splines, whose coefficients are estimated by penalized maximum likelihood using an expectation-maximization (EM) algorithm. E- and M-steps can be parallelized on multi-thread computing platforms that support OpenMP. Both continuous and unordered categorical response variables are supported.
Computing EAP scores
fscores( data, fit, dimension = rep(0, ncol(data)), discrete = rep(FALSE, ncol(data)), normal = TRUE, control = list() )
fscores( data, fit, dimension = rep(0, ncol(data)), discrete = rep(FALSE, ncol(data)), normal = TRUE, control = list() )
data |
data to be scored |
fit |
the function return from fitting a |
dimension |
a vector of integers containing indicators of the latent factor. The default is rep(0, ncol(data)) indicating all item loads on the same latent factor. |
discrete |
a vector of |
normal |
a logical value |
control |
a list of technical control variables. See |
EAP scores for the fitted spfa model and reliability
RT <- spfa::simdata[,1:8] myeaps <- fscores(data = RT, fit = spfa::spfa_example, dimension = rep( 0, ncol(RT)), discrete = rep(FALSE, ncol(RT) ))
RT <- spfa::simdata[,1:8] myeaps <- fscores(data = RT, fit = spfa::spfa_example, dimension = rep( 0, ncol(RT)), discrete = rep(FALSE, ncol(RT) ))
For continuous response data use plotitem.cont
whereas discrete response data use plotitem.disc
. For joint continuous and discrete data, use plotgroup
.
plotitem.cont( param, nquad = 21, npoints = 101, xlim = c(-2.5, 2.5), ylim = c(0, 1), normal = TRUE, FUN = NULL, plot = TRUE, type = "contour", ... ) plotitem.disc( param, ncat, npoints = 101, xlim = c(-2.5, 2.5), normal = TRUE, FUN = NULL, plot = TRUE, col = 1:ncat, lty = rep(1, ncat), ... ) plotgroup( param, nquad = 21, npoints = 101, lim = c(-2.5, 2.5), normal = TRUE, plot = TRUE, type = "contour", ... )
plotitem.cont( param, nquad = 21, npoints = 101, xlim = c(-2.5, 2.5), ylim = c(0, 1), normal = TRUE, FUN = NULL, plot = TRUE, type = "contour", ... ) plotitem.disc( param, ncat, npoints = 101, xlim = c(-2.5, 2.5), normal = TRUE, FUN = NULL, plot = TRUE, col = 1:ncat, lty = rep(1, ncat), ... ) plotgroup( param, nquad = 21, npoints = 101, lim = c(-2.5, 2.5), normal = TRUE, plot = TRUE, type = "contour", ... )
param |
parameter vector estimated from |
nquad |
an integer value of number of quadrature points. Default is 21 |
npoints |
an integer value of number of x and y levels in the plot |
xlim |
the x limits of the plot. Two numerical values indicating the lower and upper limits |
ylim |
the y limits of the plot. Two numerical values indicating the lower and upper limits of the density. Note y is rescaled to a uniform [0,1] distribution. |
normal |
a logical value |
FUN |
a user supplied function to rescale. |
plot |
a logical value |
type |
the type of plot to be visualized. The default is the contour plot |
... |
|
ncat |
an integer value indicating the number of categories for the discrete item. |
col |
color of the line. |
lty |
line type |
lim |
limit |
plots. Item level perspective and contour plot
# Contour plot of the first item plotitem.cont(spfa::spfa_example$par[[1]])
# Contour plot of the first item plotitem.cont(spfa::spfa_example$par[[1]])
There are 16 columns with 1000 rows. The first 8 columns contain continuous item response time data and the last 8 columns with discrete item responses. Among the discrete items, there are 4 dichotomous and 4 four-category ones.
spfa
fits a unidimensional or two-dimension factor analysis spfa model
using penalized maximum likelihood estimation. A unidimensional spfa model can
handle discrete response data (i.e., item responses including binary responses
and polytomous responses) or continuous response data (e.g., response time).
A two-dimensional spfa
model can only handle simple structure model
with two latent factors load to continuous and discrete response data, respectively.
spfa( data, dimension = rep(0, ncol(data)), discrete = rep(FALSE, ncol(data)), control = list() )
spfa( data, dimension = rep(0, ncol(data)), discrete = rep(FALSE, ncol(data)), control = list() )
data |
a matrix that consists of item responses with missing data coded as |
dimension |
a vector of integers containing indicators of the latent factor. The default is |
discrete |
a vector of |
control |
a list containing technical parameters for estimation. May be:
|
a list including spfa model parameter estimates and marginal log-likelihood.
Liu, Y., & Wang, W. (2022). Semiparametric Factor Analysis for Item-Level Response Time Data. Psychometrika, 87(2), 666–692. doi:10.1007/s11336-021-09832-8
Liu, Y., & Wang, W. (2023). What Can We Learn from a Semiparametric Factor Analysis of Item Responses and Response Time? An Illustration with the PISA 2015 Data. Retrieved from https://arxiv.org/abs/2303.10079
# load item response time data RT <- spfa::simdata[,1:8] # Fit a unidimensional spfa model with continuous data (Response time) spfa_example <- spfa(data = RT, dimension = rep(0, ncol(RT)), discrete = rep(FALSE, ncol(RT))) # In the spfa pacakge, the output of spfa_example can be directly extracted. # See example code below: spfa::spfa_example$shortpar # Visualize the result for item 1 as an example plotitem.cont(spfa::spfa_example$par[[1]])
# load item response time data RT <- spfa::simdata[,1:8] # Fit a unidimensional spfa model with continuous data (Response time) spfa_example <- spfa(data = RT, dimension = rep(0, ncol(RT)), discrete = rep(FALSE, ncol(RT))) # In the spfa pacakge, the output of spfa_example can be directly extracted. # See example code below: spfa::spfa_example$shortpar # Visualize the result for item 1 as an example plotitem.cont(spfa::spfa_example$par[[1]])
An R object containing an example output from fitting an spfa model using the following code: # RT <- spfa::simdata[,1:8] # spfa_example <- spfa(data = RT, dimension = rep(0, ncol(RT)), discrete = rep(FALSE, ncol(RT)))