regression¶
- class LinearRegression
Bases:
RegressionLinearRegressionobject.Methods¶
sample()It samples a sequence of observations from the full posterior distribution of regressors’ parameters \(\beta_j\) and
variance\(\sigma^2\).
See Also
- static sample(model: Model, n_iterations: int, burn_in_iterations: int, n_chains: int, seed: int | None = None) None
It samples a sequence of observations from the full posterior distribution of regressors’ parameters \(\beta_j\) and
variance\(\sigma^2\). Firstburn_in_iterationsare discarded since they may not accurately represent the desired distribution. For each variable, it generatesn_chainMarkov chains.Parameters¶
modelModelThe model with data, regressors, response variable and priors to be solved through Monte Carlo sampling.
n_iterationsintNumber of total sampling iteration for each chain. It must be a strictly positive integer.
burn_in_iterationsintNumber of burn-in iteration for each chain. It must be a positive integer or
0.n_chainsintNumber of chains. It must be a strictly positive integer.
seedint, optionalRandom seed to use for reproducibility of the sampling.
Raises
TypeErrorValueErrorIf
model.dataisNone,if
model.response_variableisNone,if
model.response_variableis not a column ofmodel.dataif
model.priorsisNone,if a
model.priorskey is not a column ofmodel.data,If
n_iterationsis equal to or less than0,if
burn_in_iterationsis less than0,if
n_chainsis equal to or less than0,if
seedis not between0and2**32 - 1.
Notes
The linear regression model of the response variable \(y\) with respect to regressors \(X\) is:
\[y \sim N(\mu, \sigma^2)\]\[\mu = \beta_0 + B X = \beta_0 + \sum_{j = 1}^m \beta_j x_j\]and the likelihood is:
\[p \left( y \left\vert B,\sigma^2 \right. \right) = \frac{1}{\sqrt{2 \pi \sigma^2}} \exp{- \frac{\left(y - \mu \right)^2}{2 \sigma^2}} .\]
- class Regression
Bases:
ABCRegressionobject.Abstract base class for creating regression objects.
See Also