stats/regress
src/stats/regress.tur
defn
ols
(ols [y :int xs :int names :int intercept? :int] :int)
Ordinary least squares.
Parameters
| y | :int float64 response column | |
| xs | :int cons list of float64 predictor columns | |
| names | :int cons list of :cstr, one per predictor | |
| intercept? | :int 1 to include intercept term, 0 to suppress |
Returns
:int ok-val wrapping an lm-fit handle, or err-val with message.
Example
(ols y-col (cons x1 (cons x2 0)) (cons "x1" (cons "x2" 0)) 1)
Since: ST7
defn
ols-frame
(ols-frame [f :int response-name :cstr predictor-names :int intercept? :int] :int)
OLS from a frame with named columns.
Parameters
| f | :int frame handle | |
| response-name | :cstr column name for y | |
| predictor-names | :int cons list of :cstr column names for xs | |
| intercept? | :int 1 for intercept, 0 to suppress |
Returns
:int result<lm-fit>
Since: ST7
defn
predict
(predict [fit :int new-xs :int] :int)
generate fitted values for new predictors.
Parameters
| fit | :int lm-fit handle | |
| new-xs | :int cons list of float64 columns (same order as in ols) |
Returns
:int float64 column of predictions.
Since: ST7
defn
predict-frame
(predict-frame [fit :int new-frame :int] :int)
generate predictions from a new frame.
Parameters
| fit | :int lm-fit handle | |
| new-frame | :int frame with the same predictor column names |
Returns
:int result<column<:float>>
Since: ST7
defn
diagnostics
(diagnostics [fit :int] :int)
per-observation diagnostics frame.
Parameters
| fit | :int lm-fit handle |
Returns
:int frame handle
Since: ST7