-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
70 lines (54 loc) · 1.73 KB
/
Copy pathREADME.Rmd
File metadata and controls
70 lines (54 loc) · 1.73 KB
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
---
title: Multi-Study Factor Regression (MSRF)
author:
- Roberta De Vito
- Alejandra Avalos-Pacheco
- Jörg Schantz
---
Fit the Multi-Study Factor Regression model via the [ECM algorithm](https://doi.org/10.1002/sim.70108).
## Fitting the MSFR model via the ECM Algorithm
The following example illustrates how to fit the MSFR model via the ECM Algorithm,
using a data set generating from a simulation scenario.
### Getting the data
```{r help2, eval = FALSE}
library(MSFR)
data(Scenario1_MSFR)
```
### Obtaining suitable starting values for model parameters
Then we get inizialization for model parameters, with k=3 common
factors and j_s=[1,1] study-specific factors for two studies (S=2).
```{r, starting values, eval = FALSE}
start_value <- start_msfa(X_s, B_s, k, j_s, constraint = "block_lower2", method = "adhoc")
```
### Fitting the model via ECM
Now we can proceed for estimating the model parameters via the ECM algorithm
```{r get estimate, eval = FALSE}
ECM_MSFR <- ecm_msfr(X_s, B_s, start=start_value, nIt = 10000, trace = FALSE)
```
The estimated matrix of common loadings
```{r get common, eval = FALSE}
Phi <- ECM_MSFR$Phi
```
The estimated matrix of study-specific loadings
```{r get spec, eval = FALSE}
Lambda_1 <- ECM_MSFR$Lambda_s[[1]]
Lambda_2 <- ECM_MSFR$Lambda_s[[2]]
```
The estimated idiosyncratic error matrices
```{r get errors, eval = FALSE}
Psi_1 <- ECM_MSFR$Psi_s[[1]]
Psi_2 <- ECM_MSFR$Psi_s[[2]]
```
The estimated matrix of regression coefficients for covariates effect can be visualized
```{r get cov, eval = FALSE}
Beta <- ECM_MSFR$Beta
```
### Visualisation of the each output matrices
```{r, eval = FALSE}
heat_plot(Phi)
heat_plot(Lambda_1)
heat_plot(Lambda_2)
heat_plot(Psi_1)
heat_plot(Psi_2)
heat_plot(Beta)
```