Skip to main content

RegressionOutput

Struct RegressionOutput 

Source
pub struct RegressionOutput {
Show 26 fields pub coefficients: Vec<f64>, pub std_errors: Vec<f64>, pub t_stats: Vec<f64>, pub p_values: Vec<f64>, pub conf_int_lower: Vec<f64>, pub conf_int_upper: Vec<f64>, pub r_squared: f64, pub adj_r_squared: f64, pub f_statistic: f64, pub f_p_value: f64, pub mse: f64, pub rmse: f64, pub mae: f64, pub std_error: f64, pub residuals: Vec<f64>, pub standardized_residuals: Vec<f64>, pub predictions: Vec<f64>, pub leverage: Vec<f64>, pub vif: Vec<VifResult>, pub n: usize, pub k: usize, pub df: usize, pub variable_names: Vec<String>, pub log_likelihood: f64, pub aic: f64, pub bic: f64,
}
Expand description

Complete output from OLS regression.

Contains all coefficients, statistics, diagnostics, and residuals from an Ordinary Least Squares regression.

§Example

let y = vec![1.0, 2.0, 3.0, 4.0, 5.0];
let x1 = vec![1.0, 2.0, 3.0, 4.0, 5.0];
let names = vec!["Intercept".to_string(), "X1".to_string()];

let result = ols_regression(&y, &[x1], &names).unwrap();
assert!(result.r_squared > 0.0);
assert_eq!(result.coefficients.len(), 2); // intercept + 1 predictor

// Save and load the model

Fields§

§coefficients: Vec<f64>

Regression coefficients (including intercept)

§std_errors: Vec<f64>

Standard errors of coefficients

§t_stats: Vec<f64>

t-statistics for coefficient significance tests

§p_values: Vec<f64>

Two-tailed p-values for coefficients

§conf_int_lower: Vec<f64>

Lower bounds of 95% confidence intervals

§conf_int_upper: Vec<f64>

Upper bounds of 95% confidence intervals

§r_squared: f64

R-squared (coefficient of determination)

§adj_r_squared: f64

Adjusted R-squared (accounts for number of predictors)

§f_statistic: f64

F-statistic for overall model significance

§f_p_value: f64

P-value for F-statistic

§mse: f64

Mean squared error of residuals

§rmse: f64

Root mean squared error (prediction error in original units)

§mae: f64

Mean absolute error of residuals

§std_error: f64

Standard error of the regression (residual standard deviation)

§residuals: Vec<f64>

Raw residuals (observed - predicted)

§standardized_residuals: Vec<f64>

Standardized residuals (accounting for leverage)

§predictions: Vec<f64>

Fitted/predicted values

§leverage: Vec<f64>

Leverage values for each observation (diagonal of hat matrix)

§vif: Vec<VifResult>

Variance Inflation Factors for detecting multicollinearity

§n: usize

Number of observations

§k: usize

Number of predictor variables (excluding intercept)

§df: usize

Degrees of freedom for residuals (n - k - 1)

§variable_names: Vec<String>

Names of variables (including intercept)

§log_likelihood: f64

Log-likelihood of the model (useful for AIC/BIC calculation and model comparison)

§aic: f64

Akaike Information Criterion (lower = better model, penalizes complexity)

§bic: f64

Bayesian Information Criterion (lower = better model, penalizes complexity more heavily than AIC)

Trait Implementations§

Source§

impl Clone for RegressionOutput

Source§

fn clone(&self) -> RegressionOutput

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RegressionOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RegressionOutput

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ModelLoad for RegressionOutput

Source§

fn load(path: &str) -> Result<Self>

Load a model from a file. Read more
Source§

fn from_serialized(model: SerializedModel) -> Result<Self>

Load a model from an already-deserialized wrapper. Read more
Source§

fn model_type() -> ModelType

Get the model type identifier. Read more
Source§

impl ModelSave for RegressionOutput

Source§

fn save_with_name(&self, path: &str, name: Option<String>) -> Result<()>

Save the model to a file with a custom name. Read more
Source§

fn model_type() -> ModelType

Get the model type identifier. Read more
Source§

fn save(&self, path: &str) -> Result<(), Error>

Save the model to a file. Read more
Source§

impl Serialize for RegressionOutput

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,