pub struct GlmmFit { /* private fields */ }Expand description
A fitted random-intercept generalized linear mixed model (GLMM),
g(E[yᵢⱼ | bⱼ]) = xᵢⱼᵀβ + bⱼ, bⱼ ~ N(0, σ_b²),
for a non-Gaussian conditional GlmmFamily (Poisson counts or Bernoulli
outcomes) — the generalized counterpart to
LinearMixedModel. The intractable integral over
the random effects is handled by the Laplace approximation: an inner
Newton loop finds each group’s conditional mode, and an outer Nelder–Mead
search maximizes the resulting approximate marginal likelihood over the fixed
effects β and the random-intercept standard deviation σ_b.
Fixed-effect standard errors come from the numerical observed information of
the Laplace log-likelihood. The random-intercept variance is reported as
σ_b; as it shrinks toward zero the model approaches the corresponding plain
GLM.
Implementations§
Source§impl GlmmFit
impl GlmmFit
Sourcepub fn new(
x: Array2<f64>,
y: Array1<f64>,
groups: &[usize],
family: GlmmFamily,
) -> Result<Self>
pub fn new( x: Array2<f64>, y: Array1<f64>, groups: &[usize], family: GlmmFamily, ) -> Result<Self>
Fit a random-intercept GLMM of y on fixed-effect design X with group
labels groups, under family, by Laplace-approximate maximum
likelihood.
X carries the fixed effects including an intercept.
§Errors
RegressionError::EmptyInput/RegressionError::ShapeMismatch.RegressionError::InvalidResponsefor out-of-support responses or fewer than two groups.RegressionError::NotConvergedif the optimizer fails to find a finite optimum.
Sourcepub fn family(&self) -> GlmmFamily
pub fn family(&self) -> GlmmFamily
The conditional family.
Sourcepub fn n_observations(&self) -> usize
pub fn n_observations(&self) -> usize
Number of observations.
Sourcepub fn n_parameters(&self) -> usize
pub fn n_parameters(&self) -> usize
Number of fixed-effect coefficients.
Sourcepub fn coefficients(&self) -> ArrayView1<'_, f64>
pub fn coefficients(&self) -> ArrayView1<'_, f64>
Fixed-effect coefficients β̂ (link scale).
Sourcepub fn group_variance(&self) -> f64
pub fn group_variance(&self) -> f64
Random-intercept variance σ̂_b².
Sourcepub fn covariance(&self) -> ArrayView2<'_, f64>
pub fn covariance(&self) -> ArrayView2<'_, f64>
Fixed-effect covariance (inverse observed information of the Laplace likelihood).
Sourcepub fn coefficient_standard_errors(&self) -> Array1<f64>
pub fn coefficient_standard_errors(&self) -> Array1<f64>
Fixed-effect standard errors.
Sourcepub fn random_effects(&self) -> ArrayView1<'_, f64>
pub fn random_effects(&self) -> ArrayView1<'_, f64>
Predicted (conditional-mode) random intercepts b̂_j, in densified group
order.
Sourcepub fn log_likelihood(&self) -> f64
pub fn log_likelihood(&self) -> f64
The Laplace-approximate log-likelihood at the estimate.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GlmmFit
impl RefUnwindSafe for GlmmFit
impl Send for GlmmFit
impl Sync for GlmmFit
impl Unpin for GlmmFit
impl UnsafeUnpin for GlmmFit
impl UnwindSafe for GlmmFit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.