RegressionOutput

Struct RegressionOutput 

Source
pub struct RegressionOutput {
Show 23 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>,
}
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

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)

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 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.