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.27841707 0.25554005 0.05242565 0.14296483 0.78425812 0.28618333 #> [31] 0.72179842 0.09802332 0.06144728 0.22374946 0.09800902 0.53182173 #> [37] 0.93530377 0.51202852 0.37055602 0.85106334 0.04609644 0.98703668 #> [43] 0.22863402 0.12381552 0.99320093 0.47693027 0.08265538 0.14353951 #> [49] 0.01579340 0.38243380 0.99614789 0.99825216 0.99814743 0.67104672 #> [55] 0.98281330 0.94071589 0.99398258 0.99856138 0.93164035 0.96125117 #> [61] 0.58145088 0.67293900 0.68297806 0.58495478 0.97827508 0.99192093 #> [67] 0.97127922 0.99922992 0.86419947 0.61564622 0.96674102 0.99831556 #> [73] 0.89700915 0.99414123 0.97738842 0.53365408 0.99951701 0.94910389 #> [79] 0.18756743 0.99952218 0.96305936 0.99904148 0.98025812 0.98593437 #> [85] 0.77213987 0.98638238 0.45803224 0.88812174 0.99605438 0.87878950 #> [91] 0.74778978 0.99742784 0.99941649 0.99666526 0.94726915 0.71056668 #> [97] 0.98118510 0.93036429 0.99689897 0.98154305 #> #> $converge #> [1] -170.6140 -168.0292 -165.5816 -163.3307 -161.5313 -160.4184 -159.9220 #> [8] -159.7544 -159.7020 -159.6811 -159.6686 -159.6589 -159.6507 -159.6437 #> [15] -159.6376 -159.6324 -159.6278 -159.6237 -159.6202 -159.6171 -159.6144 #> [22] -159.6121 -159.6100 -159.6082 -159.6066 -159.6051 -159.6039 -159.6028 #> [29] -159.6018 -159.6009 -159.6002 -159.5995 -159.5989 -159.5984 -159.5979 #> [36] -159.5975 -159.5971 -159.5967 -159.5964 -159.5962 -159.5959 -159.5957 #> [43] -159.5955 -159.5954 -159.5952 -159.5951 -159.5950 -159.5949 -159.5948 #> #> $estim0 #> p0 mean0 sd0 p1 mean1 sd1 #> 1 1 1.093033 1.396384 0 NaN NaN #> #> $estim1 #> p0 mean0 sd0 p1 mean1 sd1 #> 1 0.2924392 -0.01872826 0.9130687 0.7075608 2.048717 0.9995859 #> #> $loglik0 #> [1] -175.2639 #> #> $loglik1 #> [1] -159.5948 #> #> $lrts #> [1] 31.33817 #>