[−][src]Function arima::acf::ar
pub fn ar<T: Float + From<u32> + From<f64> + Into<f64> + Copy + AddAssign>(
x: &[T],
order: Option<usize>
) -> Result<(Vec<T>, T), ArimaError>
Calculate the auto-regressive coefficients of a time series of length n.
If you already calculated the auto-correlation coefficients (ACF), consider
using ar_rho
instead.
Arguments
&x
- Reference to input vector slice of length n.order
- Order of the AR model.
Returns
- Output vector of length order containing the AR coefficients.
Example
use arima::acf; let x = [1.0, 1.2, 1.4, 1.6]; let (ar, _var) = acf::ar(&x, Some(2)).unwrap(); assert!((ar[0] - 0.3466667).abs() < 1.0e-7); assert!((ar[1] - -0.3866667).abs() < 1.0e-7);