knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

penfa

minimal R
version lifecycle Last-changedate Website Licence R-CMD-check

Overview

An R package for estimating single- and multiple-group penalized factor models via a trust-region algorithm with integrated automatic multiple tuning parameter selection (Geminiani et al., 2021). Supported penalties include lasso, adaptive lasso, scad, mcp, and ridge.

Installation

You can install the released version of penfa from CRAN with:

install.packages("penfa")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("egeminiani/penfa")

Example

This is a basic example showing how to fit a PENalized Factor Analysis model with the alasso penalty and the automatic tuning procedure. A shrinkage penalty is applied to the whole factor loading matrix.

Let's load the data (see ?ccdata for details).

library(penfa)
data(ccdata)

Step 1 : specify the model syntax

syntax = 'help  =~   h1 + h2 + h3 + h4 + h5 + h6 + h7 + 0*v1 + v2 + v3 + v4 + v5
          voice =~ 0*h1 + h2 + h3 + h4 + h5 + h6 + h7 +   v1 + v2 + v3 + v4 + v5'

Step 2: fit the model

alasso_fit <- penfa(model  = syntax,
                    data   = ccdata,
                    std.lv = TRUE,
                    pen.shrink = "alasso")
alasso_fit

Step 3: inspect the results

summary(alasso_fit)

Vignettes and Tutorials

Literature

How to cite

print(citation("penfa"), bibtex = TRUE)


egeminiani/penfa documentation built on Dec. 20, 2021, 3:22 a.m.