Linear Model¤
stamox.regression.lm(data: Union[List, Tuple, pandas.core.frame.DataFrame, ArrayLike], formula = None, subset = None, weights = None, NA_action = 'drop', method = 'qr', dtype: dtype = <class 'jax.numpy.float64'>) -> OLSState
¤
    Fits a linear model using the given data and parameters.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| data | Union[List, Tuple, DataFrame, ArrayLike] | The data to fit the linear model with. | required | 
| formula | str | A formula for the linear model. Defaults to None. | None | 
| subset | list | A list of indices to use as a subset of the data. Defaults to None. | None | 
| weights | array-like | An array of weights to apply to the data. Defaults to None. | None | 
| NA_action | str | The action to take when encountering missing values. Defaults to "drop". | 'drop' | 
| method | str | The method to use for fitting the linear model. Defaults to "qr". | 'qr' | 
| dtype | jnp.float—— | The data type to use for the linear model. Defaults to jnp.float_. | <class 'jax.numpy.float64'> | 
Returns:
| Type | Description | 
|---|---|
| OLSState | The state of the fitted linear model. | 
Examples:
>>> from stamox.functions import lm
>>> import pandas as pd
>>> import numpy as np
>>> np.random.seed(42)
>>> X = np.random.uniform(size=(1000, 3))
>>> y = (
        3 * X[:, 0]
        + 2 * X[:, 1]
        - 7 * X[:, 2]
        + 1.
    )
>>> data = pd.DataFrame(
        np.concatenate([X, y.reshape((-1, 1))], axis=1),
        columns=["x1", "x2", "x3", "y"],
    )
>>> res = lm(data, "y ~ x1 + x2 + x3")
>>> res.coefs
Array([ 1., 3.,  2., -7.], dtype=float32)