# `Spatex.Regression.OLS`
[🔗](https://github.com/CountlinkX-Solutions/spatex/blob/v0.2.1/lib/spatex/regression/ols.ex#L1)

Result of `Spatex.Regression.ols/3`: coefficients, inference and diagnostics, with the
attribute names of `spreg.OLS` (spreg 1.9.1) in snake_case.

Matrices (`vm`, `xtx`, `xtxi`) are lists of rows. Tests that spreg reports as `(statistic,
p-value)` are `{statistic, p}` tuples; those it reports as dictionaries are maps with spreg's
keys. Fields for diagnostics that were not requested are `nil`. Non-finite numbers are the
atoms `:nan`, `:infinity` and `:neg_infinity`.

## Fields

  * `n`, `k` - observations and columns of the final design (the constant included).
  * `betas`, `vm`, `std_err`, `t_stat` (`[{t, p}]`), `predy`, `u`, `utu`.
  * `sig2` (the estimator the options chose), `sig2n` (`utu / n`), `sig2n_k` (`utu / (n - k)`),
    `sig2ml` (`sig2n`), `mean_y`, `std_y`, `r2`, `ar2`, `xtx`, `xtxi`.
  * `f_stat` (`{f, p}`), `logll`, `aic`, `schwarz`, `condition_number` (spreg's `mulColli`),
    `jarque_bera` (`%{df, jb, pvalue}`), `breusch_pagan` (`%{df, bp, pvalue}`),
    `koenker_bassett` (`%{df, kb, pvalue}`) - with `nonspat_diag: true` (the default).
  * `white` - `%{df, wh, pvalue}`, `{:not_computed, :multicollinearity}` or `nil`.
  * `vif` - per column `{vif, tolerance}`, `nil` for the constant (zero variance).
  * `lm_error`, `lm_lag`, `rlm_error`, `rlm_lag`, `lm_sarma` and the Koley-Bera tests `lm_wx`,
    `lm_spdurbin`, `rlm_wx`, `rlm_durlag`, `lm_slxerr` - `{statistic, p}` with `spat_diag: true`.
  * `moran_res` - `{i, z, p}`, Moran's I of the residuals, with `moran: true`.
  * `robust` (`nil | :white | :hac`), `name_x`, `name_y`, `warnings`.

# `pair`

```elixir
@type pair() :: {value(), value()}
```

# `t`

```elixir
@type t() :: %Spatex.Regression.OLS{
  aic: value() | nil,
  ar2: value(),
  betas: [value()],
  breusch_pagan: map() | nil,
  condition_number: value() | nil,
  f_stat: pair() | nil,
  jarque_bera: map() | nil,
  k: pos_integer(),
  koenker_bassett: map() | nil,
  lm_error: pair() | nil,
  lm_lag: pair() | nil,
  lm_sarma: pair() | nil,
  lm_slxerr: pair() | nil,
  lm_spdurbin: pair() | nil,
  lm_wx: pair() | nil,
  logll: value() | nil,
  mean_y: value(),
  moran_res: {value(), value(), value()} | nil,
  n: pos_integer(),
  name_x: [String.t()],
  name_y: String.t(),
  predy: [value()],
  r2: value(),
  rlm_durlag: pair() | nil,
  rlm_error: pair() | nil,
  rlm_lag: pair() | nil,
  rlm_wx: pair() | nil,
  robust: nil | :white | :hac,
  schwarz: value() | nil,
  sig2: value(),
  sig2ml: value() | nil,
  sig2n: value(),
  sig2n_k: value(),
  std_err: [value()],
  std_y: value(),
  t_stat: [pair()],
  u: [value()],
  utu: value(),
  vif: [{value(), value()} | nil] | nil,
  vm: [[value()]],
  warnings: [String.t()],
  white: map() | {:not_computed, :multicollinearity} | nil,
  xtx: [[value()]],
  xtxi: [[value()]]
}
```

# `value`

```elixir
@type value() :: float() | :nan | :infinity | :neg_infinity
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
