
Tables of a mixture-of-regressions fit
Source:R/mixture-regression-methods.R
get_results.latents_mixture_regression.RdTables of a mixture-of-regressions fit
Usage
# S3 method for class 'latents_mixture_regression'
get_results(
x,
what = "coefficients",
level = 0.95,
vcov_type = NULL,
data = NULL,
truth = NULL,
by = c("class", "group_class"),
...
)
# S3 method for class 'latents_mixture_regression'
as.data.frame(
x,
row.names = NULL,
optional = FALSE,
what = "coefficients",
level = 0.95,
vcov_type = NULL,
...
)
# S3 method for class 'latents_mixture_regression'
coef(object, ...)
# S3 method for class 'latents_mixture_regression'
vcov(object, type = NULL, ...)
# S3 method for class 'latents_mixture_regression'
confint(object, parm, level = 0.95, ...)
# S3 method for class 'latents_mixture_regression'
logLik(object, ...)
# S3 method for class 'latents_mixture_regression'
nobs(object, ...)Arguments
- x
A fit from
mixture_regression().- what
The table to return; see Tables.
"all"returns every table in a named list.- level
Confidence level for the intervals.
- vcov_type
NULLfor the covariance stored with the fit, or"observed","robust"or"opg"to recompute it.- data, truth
For
what = "recovery": the data frame the model was fitted to and the name of its column holding a known classification.- by
For
what = "recovery":"class", or"group_class"for the group classes of a two-level fit.- ...
Unused.
- row.names, optional
Unused; part of the generic.
- object
A fit from
mixture_regression().- type
Covariance type for
vcov(); asvcov_type.- parm
Parameter names or positions; all by default.
Tables
coefficientsOne row per class and regression term:
class("common"for a shared term),term,estimate,std_error,statistic(Wald z),p_value,conf_low,conf_high,p_adjusted(Benjamini-Hochberg across the non-intercept rows;NAfor intercepts) and, for the binomial and Poisson families,exp_estimate(odds or rate ratio). For the ordinal family each class's thresholds lead its rows as terms"threshold:<lower>|<upper>"(delta-method errors; nop_adjustedorexp_estimate), andexp_estimateof a slope is the cumulative odds ratio of a higher category.classesOne row per class:
share(mean posterior),count(summed posterior),n_assigned(modal assignment),mean_posterior(average posterior of the units assigned to it);sigmaandsigma_std_errorfor the Gaussian family;priorandprior_std_errorwhen membership has no covariates. Units are groups underclass_level = "group".membershipOne row per multinomial-logit coefficient:
model("class"or"group_class"),class,term,reference, the Wald columns andodds_ratio. In the two-level model the class intercepts are per group class,(Intercept):group_class_h.group_classesTwo-level model: one row per group class and class, with the model-implied class
probability, thegroup_share,n_groups_assigned, andstd_errorof the probability when membership has no covariates.fitOne row: log likelihood, parameter count,
aic,bic(penalized by the number of independent units: rows, or groups wheniddefines them),bic_rows(always by rows, as flexmix reports it),sabic,icl, relativeentropy(andgroup_entropy), the smallest class share, convergence and start replication.assignmentsOne row per data row used:
row(its position in the supplied data), theidcolumn, modalclass, itsposterior, and oneprobability_class_kcolumn per class; two-level fits addgroup_classandgroup_posterior.groupsOne row per group (
class_level = "group"or the two-level model): its size, modal class or group class, and posterior probabilities.fittedOne row per data row:
observed, the posterior-weightedfittedmean,fitted_modal(the modal class's mean),residualandclass.startsOne row per start: its log likelihood, convergence, iterations,
stage("screened": stopped after the 50-iteration screening because better starts existed;"completed": run to convergence ormax_iter), whether it degenerated, and which one was selected.n_best_replicatedcounts completed starts only.classificationOne row per assigned (modal) class and class: the
mean_posteriorprobability ofclassamong the units assigned toassigned, andn_assigned. Its diagonal is each class's average posterior probability; values near one mean well-separated classes.recoveryNeeds
dataandtruth: the modal classes cross-tabulated against a known classification, one row per assigned class and true value, with the countnand itsshareof the assigned class. Group-level underclass_level = "group"orby = "group_class", wheretruthmust be constant within groups.
Examples
fit <- mixture_regression(score ~ hours, data = study_hours, n_classes = 2,
n_starts = 3, seed = 1)
get_results(fit, "coefficients")
#> Regression coefficients (95% CI)
#>
#> Class Term Estimate 95% CI p
#> ------- --------- -------- -------------- -----
#> Class 1 Intercept 34.35 [32.94, 35.76] <.001
#> Class 1 hours 4.57 [ 4.36, 4.77] <.001
#> Class 2 Intercept 54.90 [52.75, 57.04] <.001
#> Class 2 hours 0.81 [ 0.48, 1.14] <.001
get_results(fit, "fit")
#> Model fit
#>
#> Family gaussian
#> Nesting observation
#> Classes 2
#> Group classes 1
#> Observations 900
#> Parameters 7
#> Log likelihood -3144.01
#> AIC 6302.01
#> BIC 6335.63
#> SABIC 6313.40
#> ICL 7030.59
#> Entropy 0.443
#> Smallest class 43.6%
#> Converged yes
get_results(fit, "coefficients", vcov_type = "robust")
#> Regression coefficients (95% CI)
#>
#> Class Term Estimate 95% CI p
#> ------- --------- -------- -------------- -----
#> Class 1 Intercept 34.35 [32.77, 35.94] <.001
#> Class 1 hours 4.57 [ 4.34, 4.79] <.001
#> Class 2 Intercept 54.90 [52.71, 57.08] <.001
#> Class 2 hours 0.81 [ 0.46, 1.15] <.001
get_results(fit, "recovery", data = study_hours, truth = "strategy")
#> Recovery of a known classification
#>
#> Assigned strategy Rows Share of assigned
#> -------- -------- ---- -----------------
#> Class 1 deep 448 0.782
#> Class 2 deep 49 0.150
#> Class 1 surface 125 0.218
#> Class 2 surface 278 0.850