Fit PSD model with VI algorithm, and use the loss function as a stopping criterion.
Arguments
- G
The I x J matrix of counts; all entries of G should be taken from {0,1,2}.
- K
An integer 2 or greater giving the matrix rank.
- epsilon
Convergence criterion.
- maxiter
The maximum number of iterations.
Value
A List with the following parameters:
P
The population scale matrix of the individuals.
F
The gene scale matrix of the populations.
Loss
A vector represents the value of the loss function which records once for 10 iterations.
Iterations
An integer represents the number of iterations.
Examples
G <- matrix(c(0,0,1, 0,2,1, 1,0,1, 0,1,0, 1,0,0), 3, 5)
psd_fit_vi(G, 2, 1e-5, 10)
#> $P
#> [,1] [,2]
#> [1,] 0.6126433 0.3873567
#> [2,] 0.3363156 0.6636844
#> [3,] 0.4785760 0.5214240
#>
#> $F
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 0.3064798 0.3920361 0.4563244 0.2652133 0.3508395
#> [2,] 0.2939170 0.6020971 0.3475661 0.3334554 0.2535043
#>
#> $Loss
#> [1] -1.772244
#>
#> $Iterations
#> [1] 10
#>