Description Usage Arguments Examples
Fit Mixture Distribution to Data and Evaluate Results
1 | mx_metafit(breaks, counts, parms, sd_min = 0, save.data = TRUE, ...)
|
breaks |
class boundaries of the data |
counts |
frequency of observations |
parms |
list of initial parameters for the mixture, or a suitable
|
sd_min |
lower boundary value for standard deviation and rate parameter |
save.data |
if data should be included in the returned object |
... |
additional arguments passed to |
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 | ## === preparation of data ===
zd <- 6:35
cutoff <- 6.0
counts <- c(155, 0, 8, 12, 17, 35, 37, 66, 42, 39, 13, 4, 4, 8, 19, 36,
80, 205, 188, 219, 170, 104, 32, 13, 12, 0, 3, 0, 0, 0)
breaks <- c(zd, (max(zd+1))) - cutoff
observations <- unbin(zd, counts) - cutoff
## === quick example ===
(comp <- mx_guess_components(observations, bw=2/3, mincut=0.9))
obj <- mxObj(comp, left="e")
ret <- mx_metafit(breaks, counts, obj)
summary(ret)
## === details ===
comp <- mx_guess_components(observations, bw=2/3, mincut=0.9)
comp # parameters of components in form of a data frame
obj <- mxObj(comp, left="n") ## all components normal
obj <- mxObj(comp, left="e") ## left component exponential (= default)
## base function, needs parms in correct format
ret <-fit_unimix(breaks, counts, parms=pstart(obj), type="enn")
## for more difficult cases, slower
ret <-fit_unimix(breaks, counts, parms=pstart(obj), type="enn",
method="BFGS",
control=list(maxit=1000, ndeps=rep(1e-4, length(pstart(obj)))))
## higher level function, determines type from start parameters
ret <- mx_metafit(breaks, counts, obj)
## --- evaluation of results --
coef(ret) # top-level mxObj-object, contains all weights
coef(ret@fit) # included mle2-object, last weight missing (sums up to 1.0)
summary(ret) # from bbe::mle
AIC(ret)
logLik(ret)
vcov(ret) # covariance matrix
cov2cor(vcov(ret)) # correlation matrix
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.