This function fits the semi-supervised Gaussian mixture model. It is called by fit.wrap.

fit.norm(y, z, it.em, epsilon)

Arguments

y

observations: numeric vector of length n

z

class labels: integer vector of length n, with entries 0, 1 and NA

it.em

(maximum) number of iterations in the EM algorithm: positive integer (defaults to 100)

epsilon

convergence criterion for the EM algorithm: non-negative numeric (defaults to 1e-04)

Value

This function returns the parameter estimates, the posterior probabilities, and the likelihood.

See also

This is an internal function. The user functions are mixtura and scrutor.

Examples

# data simulation n <- 100 z <- rep(0:1,each=n/2) y <- rnorm(n=n,mean=2*z,sd=1) z[(n/4):n] <- NA # model fitting fit.norm(y,z,it.em=100,epsilon=1e-04)
#> $posterior #> [1] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [7] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [13] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [19] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [25] 0.03144147 0.04478136 0.18046492 0.16252620 0.02587186 0.08152006 #> [31] 0.70868658 0.18666719 0.62952047 0.05271002 0.03096353 0.13841961 #> [37] 0.05270120 0.41289148 0.91296688 0.39244978 0.25774296 0.79723768 #> [43] 0.02237373 0.98361536 0.14206129 0.06898197 0.99163466 0.35717580 #> [49] 0.04337125 0.08190215 0.33790017 0.98159738 0.99536757 0.99796018 #> [55] 0.99783334 0.56802790 0.97801772 0.92045833 0.99263325 0.99833282 #> [61] 0.90789358 0.94877658 0.46590538 0.57027375 0.58224972 0.46974378 #> [67] 0.97193939 0.98998881 0.96247608 0.99912668 0.81505444 0.50390576 #> [73] 0.95629226 0.99803681 0.86000393 0.99283526 0.97074562 0.41480401 #> [79] 0.99946052 0.93205276 0.11215240 0.99946649 0.95125569 0.99890488 #> [85] 0.97460234 0.98216088 0.69303728 0.98275263 0.33869510 0.84777340 #> [91] 0.99525064 0.83497146 0.66200841 0.99695468 0.99934429 0.99601228 #> [97] 0.92951898 0.61568801 0.97584358 0.90612620 #> #> $converge #> [1] -169.9528 -167.3532 -165.0248 -162.8406 -160.9837 -159.7144 -159.0767 #> [8] -158.8436 -158.7768 -158.7600 -158.7557 -158.7542 -158.7534 -158.7528 #> [15] -158.7523 -158.7518 -158.7515 -158.7511 -158.7509 -158.7506 -158.7504 #> [22] -158.7502 -158.7500 -158.7499 -158.7498 -158.7496 -158.7495 #> #> $estim0 #> p0 mean0 sd0 p1 mean1 sd1 #> 1 1 1.081359 1.370147 0 NaN NaN #> #> $estim1 #> p0 mean0 sd0 p1 mean1 sd1 #> 1 0.3468634 0.05791743 0.8874206 0.6531366 2.119712 0.9561795 #> #> $loglik0 #> [1] -173.3711 #> #> $loglik1 #> [1] -158.7495 #> #> $lrts #> [1] 29.2432 #>