-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
129 lines (91 loc) · 4.3 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# penfa
<!-- badges: start -->
[![minimal R
version](https://img.shields.io/badge/R%3E%3D-3.5.0-6666ff.svg)](https://cran.r-project.org/)
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Last-changedate](https://img.shields.io/badge/last%20change-`r gsub('-', '--', Sys.Date())`-brightgreen.svg)](https://github.com/egeminiani/penfa/commits/main)
[![Website](https://img.shields.io/badge/website-penfa-orange.svg?colorB=E91E63)](https://egeminiani.github.io/penfa/)
[![Licence](https://img.shields.io/badge/licence-GPL--3-orange.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
[![R-CMD-check](https://github.com/egeminiani/penfa/workflows/R-CMD-check/badge.svg)](https://github.com/egeminiani/penfa/actions)
<!-- badges: end -->
### 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:
``` r
install.packages("penfa")
```
And the development version from [GitHub](https://github.com/) with:
``` r
# 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).
```{r data}
library(penfa)
data(ccdata)
```
<font size="4">**Step 1**</font> : specify the model syntax
```{r 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'
```
<font size="4">**Step 2**</font>: fit the model
```{r fit}
alasso_fit <- penfa(model = syntax,
data = ccdata,
std.lv = TRUE,
pen.shrink = "alasso")
```
```{r show}
alasso_fit
```
<font size="4">**Step 3**</font>: inspect the results
```{r summary}
summary(alasso_fit)
```
### Vignettes and Tutorials
* See `vignette("automatic-tuning-selection")` for the estimation of a penalized
factor model with lasso and alasso penalties. The tuning parameter producing the
optimal amount of sparsity in the factor loading matrix is found through the
automatic tuning procedure.
* See `vignette("grid-search-tuning-selection")` for the estimation of a
penalized factor model with scad and mcp penalties. A grid search is conducted,
and the optimal tuning parameter is the one generating the penalized model with
the lowest GBIC (Generalized Bayesian Information Criterion).
* See ["multiple-group-analysis"](https://egeminiani.github.io/penfa/articles/articles/multiple-group-analysis.html) for the estimation of a multiple-group penalized factor model
with the alasso penalty. This model encourages sparsity in the loading matrices
and cross-group invariance of loadings and intercepts. The automatic multiple
tuning parameter procedure is employed for finding the optimal tuning parameter
vector.
* See ["plotting-penalty-matrix"](https://egeminiani.github.io/penfa/articles/articles/plotting-penalty-matrix.html) for details on how to produce interactive plots of the penalty matrices.
### Literature
* Geminiani, E., Marra, G., & Moustaki, I. (2021). "Single- and Multiple-Group
Penalized Factor Analysis: A Trust-Region Algorithm Approach with Integrated
Automatic Multiple Tuning Parameter Selection." Psychometrika, 86(1), 65-95. [https://doi.org/10.1007/s11336-021-09751-8](https://doi.org/10.1007/s11336-021-09751-8)
* Geminiani, E. (2020). "A Penalized Likelihood-Based Framework for Single and
Multiple-Group Factor Analysis Models." PhD thesis, University of Bologna.
[http://amsdottorato.unibo.it/9355/](http://amsdottorato.unibo.it/9355/).
### How to cite
```{r citation, echo=FALSE}
print(citation("penfa"), bibtex = TRUE)
```