pub struct Fit<'a, M, F> where
    M: Glm,
    F: Float
{ pub result: Array1<F>, pub options: FitOptions<F>, pub model_like: F, pub n_iter: usize, pub n_steps: usize, /* private fields */ }
Expand description

the result of a successful GLM fit

Fields

result: Array1<F>

The parameter values that maximize the likelihood as given by the IRLS regression.

options: FitOptions<F>

The options used for this fit.

model_like: F

The value of the likelihood function for the fit result.

n_iter: usize

The number of overall iterations taken in the IRLS.

n_steps: usize

The number of steps taken in the algorithm, which includes step halving.

Implementations

Returns the Akaike information criterion for the model fit.

Returns the Bayesian information criterion for the model fit.

The covariance matrix estimated by the Fisher information and the dispersion parameter (for families with a free scale). The matrix is cached to avoid repeating the potentially expensive matrix inversion.

Returns the deviance of the fit: twice the difference between the saturated likelihood and the model likelihood. Asymptotically this fits a chi-squared distribution with self.ndf() degrees of freedom. Note that the regularized likelihood is used here.

The dispersion parameter(typically denoted phi) which relates the variance of the y values with the variance of the response distribution: Var[y] = phi * Var[mu]. Identically one for logistic, binomial, and Poisson regression. For others (linear, gamma) the dispersion parameter is estimated from the data. This is equal to the total deviance divided by the degrees of freedom. For OLS linear regression this is equal to the sum of (y_i - mu_i)^2 / (n-p), an estimate of sigma^2; with no covariates it is equal to the sample variance.

👎 Deprecated since 0.0.10:

use predict() instead

Returns the fisher information (the negative hessian of the likelihood) at the parameter values given. The regularization is included.

Perform a likelihood-ratio test, returning the statistic -2*ln(L_0/L) where L_0 is the likelihood of the best-fit null model (with no parameters but the intercept) and L is the likelihood of the fit result. The number of degrees of freedom of this statistic, equal to the number of parameters fixed to zero to form the null model, is test_ndf(). By Wilks’ theorem this statistic is asymptotically chi-squared distributed with this number of degrees of freedom.

Perform a likelihood-ratio test against a general alternative model, not necessarily a null model. The alternative model is regularized the same way that the regression resulting in this fit was. The degrees of freedom cannot be generally inferred.

Returns the residual degrees of freedom in the model, i.e. the number of data points minus the number of parameters. Not to be confused with test_ndf(), the degrees of freedom in the statistical tests of the fit.

Returns the likelihood given the null model, which fixes all parameters to zero except the intercept (if it is used). A total of test_ndf() parameters are constrained.

Returns the expected value of Y given the input data X. This data need not be the training data, so an option for linear offsets is provided. Panics if the number of covariates in the data matrix is not consistent with the training set. The data matrix may need to be padded by ones if it is not part of a Model. The utility::one_pad() function facilitates this.

Return the deviance residuals for each point in the training data. Equal to sign(y-E[y|x])*sqrt(-2*(L[y|x] - L_sat[y])). This is usually a better choice for non-linear models. NaNs might be possible if L[y|x] > L_sat[y] due to floating-point operations. These are not checked or clipped right now.

Return the standardized deviance residuals, also known as the “internally studentized deviance residuals”. This is generally applicable for outlier detection, although the influence of each point on the fit is only approximately accounted for. d / sqrt(phi * (1 - h)) where d is the deviance residual, phi is the dispersion (e.g. sigma^2 for linear regression, 1 for logistic regression), and h is the leverage.

Return the partial residuals.

Return the Pearson residuals for each point in the training data. This is equal to (y - E[y])/sqrt(V(E[y])), where V is the variance function. These are not scaled by the sample standard deviation for families with a free dispersion parameter like linear regression.

Return the standardized Pearson residuals for every observation. Also known as the “internally studentized Pearson residuals”. (y - E[y]) / (sqrt(Var[y] * (1 - h))) where h is a vector representing the leverage for each observation.

Return the response residuals, or fitting deviation, for each data point in the fit; that is, the difference y - E[y|x] where the expectation value is the y value predicted by the model given x.

Return the studentized residuals, which are the changes in the fit likelihood resulting from leaving each observation out. This is a robust and general method for outlier detection, although a one-step approximation is used to avoid re-fitting the model completely for each observation. If the linear errors are standard normally distributed then this statistic should follow a t-distribution with self.ndf() - 1 degrees of freedom.

Returns the working residuals d\eta/d\mu * (y - E{y|x}). This should be equal to the response residuals divided by the variance function (as opposed to the square root of the variance as in the Pearson residuals).

Returns the score function (the gradient of the likelihood) at the parameter values given. It should be zero within FPE at the minimized result.

Returns the score test statistic. This statistic is asymptotically chi-squared distributed with test_ndf() degrees of freedom.

Returns the score test statistic compared to another set of model parameters, not necessarily a null model. The degrees of freedom cannot be generally inferred.

The degrees of freedom for the likelihood ratio test, the score test, and the Wald test. Not to be confused with ndf(), the degrees of freedom in the model fit.

Returns the Wald test statistic compared to a null model with only an intercept (if one is used). This statistic is asymptotically chi-squared distributed with test_ndf() degrees of freedom.

Returns the Wald test statistic compared to another specified model fit instead of the null model. The degrees of freedom cannot be generally inferred.

Returns the signed square root of the Wald test statistic for each parameter. Since it does not account for covariance between the parameters it may not be accurate.

Specialized functions for OLS.

Returns the coefficient of multiple correlation, R^2.

Returns the residual sum of squares, i.e. the sum of the squared residuals.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.