Skip to contents

Fit PSD model with SQP algorithm, and use the loss function as a stopping criterion.

Usage

psd_fit_sqp(G, K, epsilon = 1e-05, maxiter = 50, initem = 100)

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.

initem

A number of iterations when using EM algorithm for initialization.

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_sqp(G, 2, 1e-5, 10, 10)
#> $P
#>             [,1]        [,2]
#> [1,] 0.000000001 0.999999999
#> [2,] 0.999999999 0.000000001
#> [3,] 0.310834358 0.689165642
#> 
#> $F
#>             [,1]  [,2]        [,3]        [,4]        [,5]
#> [1,] 0.000000001 1e+00 0.000000001 0.413499269 0.000000001
#> [2,] 0.276563636 1e-09 0.573743072 0.000000001 0.311695728
#> 
#> $Loss
#> [1] -0.7595456 -0.7074246
#> 
#> $Iterations
#> [1] 20
#>