lpme
: R Packge for Dealing with Latent Predictor Measurement Error Under Identification Restrictions
Installation | Key Functions | References
lpme
is an R package that provides tools for analyzing latent variable models with measurement error correction, using bootstrapping techniques for inference.
Within an R
session, you can install the development version of lpme
from GitHub with:
# install.packages("devtools")
devtools::install_github("cjerzak/lpme/lpme-software")
lpme_OneRun
performs a single run of latent variable analysis with measurement error correction (no bootstrapping; 1 split sample partition):
# Generate data
Yobs <- rnorm(1000)
ObservablesMat <- matrix(sample(c(0,1), 1000*10, replace = T), ncol = 10)
# One run of latent error correction method
lpme::lpme_OneRun(Yobs, ObservablesMat,
MakeObservablesGroupings = FALSE, seed = runif(1, 1, 10000))
lpme
implements a bootstrap analysis for latent variable models with measurement error correction. We average over nPartition
split sample partitions.
# Generate data
Yobs <- rnorm(1000)
ObservablesMat <- matrix(sample(c(0,1), 1000*10, replace = T), ncol = 10)
# Latent error correction method, with partitioning and bootstrap
results <- lpme::lpme(Yobs, ObservablesMat,
MakeObservablesGroupings = FALSE, nBoot = 32L, nPartition = 10L,
bootBasis = 1:length(Yobs), ReturnIntermediaries = TRUE,
seed = runif(1, 1, 10000))
#View the corrected IV coefficient and its standard error
print(c(results$Corrected_IVRegCoef, results$Corrected_IVRegSE))
Contributions to latenterror are welcome! Feel free to submit a pull request or open an issue.
We thank Guilherme Duarte, Jeff Lewis, Umberto Mignozzetti, Aaron Pancost, Erik Snowberg, Chris Tausanovitch, and participants of a panel at an MPSA panel for very helpful comments. We thank Major Valls for excellent research assistance.
Connor T. Jerzak, Stephen A. Jessee. Measurement Error in Latent Predictors: The Role of Identification Restrictions Working paper to be released summer 2024!