Title: | Toolkit for Item Factor Analysis with 'OpenMx' |
---|---|
Description: | Tools, tutorials, and demos of Item Factor Analysis using 'OpenMx'. |
Authors: | Joshua N. Pritikin [cre, aut] |
Maintainer: | Joshua N. Pritikin <[email protected]> |
License: | AGPL (>= 3) |
Version: | 0.20 |
Built: | 2024-10-26 03:41:10 UTC |
Source: | https://github.com/jpritikin/ifatools |
Adds exploratory factors to a single factor model
addExploratoryFactors(model, toAdd, ..., addUniquenessPrior = TRUE)
addExploratoryFactors(model, toAdd, ..., addUniquenessPrior = TRUE)
model |
a single factor (possibly multigroup) model |
toAdd |
the number of factors to add |
... |
Not used. Forces remaining arguments to be specified by name. |
addUniquenessPrior |
whether to add a uniqueness prior to the model (default TRUE) |
WARNING: This function is under development. The API may change in a future release.
iccPlot(grp, itemName, ..., width = 3, dataBins = 11, basis = c(1), factor = 1)
iccPlot(grp, itemName, ..., width = 3, dataBins = 11, basis = c(1), factor = 1)
grp |
an IFA group |
itemName |
name of item to plot |
... |
Not used. Forces remaining arguments to be specified by name. |
width |
sets the x axis to [-width,width] |
dataBins |
number of partitions for the latent scores |
basis |
the basis vector in the latent space |
factor |
the score to use (TODO: should be a function of the basis vector?) |
A Shiny app to experiment with item models
itemModelExplorer()
itemModelExplorer()
## Not run: itemModelExplorer() # will launch a browser in RStudio ## End(Not run)
## Not run: itemModelExplorer() # will launch a browser in RStudio ## End(Not run)
Categories are placed at the mean score of the examinees who picked that category.
itemResponseMap(grp, ..., factor = 1)
itemResponseMap(grp, ..., factor = 1)
grp |
an IFA group |
... |
Not used. Forces remaining arguments to be specified by name. |
factor |
which factor to plot (defaults to 1) |
A data.frame of the raw data backing the plot. Item outcomes without any observations are omitted.
A Shiny app for building IFA models
modelBuilder()
modelBuilder()
## Not run: modelBuilder() # will launch a browser in RStudio ## End(Not run)
## Not run: modelBuilder() # will launch a browser in RStudio ## End(Not run)
For multidimensional items, you will need to supply a basis vector. This vector is normalized to unit length.
plotInformation(grp, ..., width = 3, showTotal = FALSE, basis = c(1))
plotInformation(grp, ..., width = 3, showTotal = FALSE, basis = c(1))
grp |
an IFA group |
... |
Not used. Forces remaining arguments to be specified by name. |
width |
the plot will span from -width to width |
showTotal |
whether to plot the total item information |
basis |
the basis vector (for multidimensional items) |
The reference group is fixed to a zero mean and identity covariance matrix.
replicateModelBy( tmpl, fullData, mMat, covMat, ..., splitCol = "population", refGroup = "general", split = TRUE, compressData = TRUE )
replicateModelBy( tmpl, fullData, mMat, covMat, ..., splitCol = "population", refGroup = "general", split = TRUE, compressData = TRUE )
tmpl |
an OpenMx model |
fullData |
the complete data including the column indicating group membership |
mMat |
an MxMatrix for latent means |
covMat |
an MxMatrix for latent covariance |
... |
Not used. Forces remaining arguments to be specified by name. |
splitCol |
the name of the column used to indicate group membership |
refGroup |
the name of the reference group |
split |
whether to split the data (defaults to TRUE) |
compressData |
whether to apply compressDataFrame (defaults to TRUE) |
Plot expected and observed table from SitemFit
SitemPlot(sout, itemName, ..., showSampleSize = TRUE)
SitemPlot(sout, itemName, ..., showSampleSize = TRUE)
sout |
output from SitemFit |
itemName |
name of item to plot |
... |
Not used. Forces remaining arguments to be specified by name. |
showSampleSize |
whether to show the sample size at the top of the plot |
To prevent Heywood cases, Bock, Gibbons, & Muraki (1988) suggested a beta prior on the uniqueness (Equations 43-46). The analytic gradient and Hessian are included for quick optimization using Newton-Raphson.
uniquenessPrior(model, numFactors, strength = 0.1, name = "uniquenessPrior")
uniquenessPrior(model, numFactors, strength = 0.1, name = "uniquenessPrior")
model |
an mxModel |
numFactors |
the number of factors. All items are assumed to have the same number of factors. |
strength |
the strength of the prior |
name |
the name of the mxModel that is returned |
To reproduce these derivatives in maxima for the case
of 2 slopes (c
and d
), use the following code:
f(c,d) := -p*log(1-(c^2 / (c^2+d^2+1) + (d^2 / (c^2+d^2+1))));
diff(f(c,d), d),radcan;
diff(diff(f(c,d), d),d),radcan;
The general pattern is given in Bock, Gibbons, & Muraki.
an mxModel that evaluates to the prior density in deviance units
Bock, R. D., Gibbons, R., & Muraki, E. (1988). Full-information item factor analysis. Applied Psychological Measurement, 12(3), 261-280.
numItems <- 6 spec <- list() spec[1:numItems] <- list(rpf.drm(factors=2)) names(spec) <- paste0("i", 1:numItems) item <- mxMatrix(name="item", free=TRUE, values=mxSimplify2Array(lapply(spec, rpf.rparam))) item$labels[1:2,] <- paste0('p',1:(numItems * 2)) data <- rpf.sample(100, spec, item$values) # use a larger sample size m1 <- mxModel(model="m1", item, mxData(observed=data, type="raw"), mxExpectationBA81(spec), mxFitFunctionML()) up <- uniquenessPrior(m1, 2) container <- mxModel("container", m1, up, mxFitFunctionMultigroup(c("m1", "uniquenessPrior")), mxComputeSequence(list( mxComputeOnce('fitfunction', c('fit','gradient')), mxComputeReportDeriv()))) container <- mxRun(container) container$output$fit container$output$gradient
numItems <- 6 spec <- list() spec[1:numItems] <- list(rpf.drm(factors=2)) names(spec) <- paste0("i", 1:numItems) item <- mxMatrix(name="item", free=TRUE, values=mxSimplify2Array(lapply(spec, rpf.rparam))) item$labels[1:2,] <- paste0('p',1:(numItems * 2)) data <- rpf.sample(100, spec, item$values) # use a larger sample size m1 <- mxModel(model="m1", item, mxData(observed=data, type="raw"), mxExpectationBA81(spec), mxFitFunctionML()) up <- uniquenessPrior(m1, 2) container <- mxModel("container", m1, up, mxFitFunctionMultigroup(c("m1", "uniquenessPrior")), mxComputeSequence(list( mxComputeOnce('fitfunction', c('fit','gradient')), mxComputeReportDeriv()))) container <- mxRun(container) container$output$fit container$output$gradient
The returned model evaluates to the fit of the priors in deviance (-2 log likelihood) units. The analytic gradient and Hessian are included for quick optimization using Newton-Raphson.
univariatePrior(type, labels, mode, strength = NULL, name = "univariatePrior")
univariatePrior(type, labels, mode, strength = NULL, name = "univariatePrior")
type |
one of c("lnorm","beta","logit-norm") |
labels |
a vector of parameters to which to apply the prior density |
mode |
the mode of the prior density |
strength |
a prior-specific strength (optional) |
name |
the name of the mxModel returned |
Priors of type 'beta' and 'logit-norm' are commonly used for the lower asymptote parameter of the 3PL model. Both of these priors assume that the parameter is in logit units. The 'lnorm' prior can be used for slope parameters.
an mxModel that evaluates to the prior density in deviance units
model <- univariatePrior("logit-norm", "x1", -1) model$priorParam$values[1,1] <- -.6 model <- mxRun(model) model$output$fit model$output$gradient model$output$hessian
model <- univariatePrior("logit-norm", "x1", -1) model$priorParam$values[1,1] <- -.6 model <- mxRun(model) model$output$fit model$output$gradient model$output$hessian