GeneralizedLinearRegression#
- class causalpy.pymc_models.GeneralizedLinearRegression[source]#
Curated generalized linear regression with outcome-scale
musemantics.Builds
eta = X @ beta, applies the configured inverse link to obtain response-scalemu, and wires a family-specificy_hatlikelihood.Supported canonical family/link pairs are Gaussian/identity, Poisson/log, Negative Binomial/log, and Bernoulli/logit. Non-Gaussian families skip Bayesian \(R^2\) scoring because
score()returnsNone.- Parameters:
family (
Literal['gaussian','poisson','negative_binomial','bernoulli']) – Response family. Defaults to"gaussian". The canonical inverse link for the family is exposed read-only vialink.sample_kwargs (
dict[str,Any] |None) – Keyword arguments forwarded topymc.sample().priors (
dict[str,Any] |None) – User priors merged over family defaults. Negative Binomial models accept an"alpha"dispersion prior. Customy_hatoverrides are supported only for the Gaussian family.
Methods
Register a dimension coordinate with the model.
GeneralizedLinearRegression.add_coords(coords, *)Vectorized version of
Model.add_coord.Add a random graph variable to the named variables of the model.
Define the generalized linear regression PyMC graph.
Check that the logp is defined and finite at the starting point.
Compiled log probability density hessian function.
Compiled log probability density gradient function.
Compiles a PyTensor function.
Compiled log probability density function.
Clone the model.
Create a
TensorVariablethat will be used as the random variable's "value" in log-likelihood graphs.GeneralizedLinearRegression.d2logp([vars, ...])Hessian of the models log-probability w.r.t.
GeneralizedLinearRegression.debug([point, ...])Debug model function at point.
GeneralizedLinearRegression.dlogp([vars, ...])Gradient of the models log-probability w.r.t.
Evaluate shapes of untransformed AND transformed free variables.
GeneralizedLinearRegression.fit(X, y[, coords])Validate the outcome against the family support, then fit.
Compute the initial point of the model.
GeneralizedLinearRegression.logp([vars, ...])Elemwise log-probability of the model.
Compile a PyTensor function that computes logp and gradient.
Create a TensorVariable for an observed random variable.
Check if name has prefix and adds if needed.
Check if name has prefix and deletes if needed.
Compute the log probability of point for all random variables in the model.
GeneralizedLinearRegression.predict(X[, ...])Predict data given input data X.
Print posterior summaries for regression coefficients and auxiliaries.
Generate priors dynamically based on the input data.
GeneralizedLinearRegression.profile(outs, *)Compile and profile a PyTensor function which returns
outsand takes values of model vars as a dict as an argument.Register a data variable with the model.
Register an (un)observed random variable with the model.
Clone and replace random variables in graphs with their value variables.
GeneralizedLinearRegression.score(X, y[, coords])Score Bayesian \(R^2\) for Gaussian models; skip for other families.
GeneralizedLinearRegression.set_data(name, ...)Change the values of a data variable in the model.
GeneralizedLinearRegression.set_dim(name, ...)Update a mutable dimension.
Set an initial value (strategy) for a random variable.
GeneralizedLinearRegression.to_graphviz(*[, ...])Produce a graphviz Digraph from a PyMC model.
Attributes
basic_RVsList of random variables the model is defined in terms of.
continuous_value_varsAll the continuous value variables in the model.
coordsCoordinate values for model dimensions.
datalogpPyTensor scalar of log-probability of the observed variables and potential terms.
default_priorsdim_lengthsThe symbolic lengths of dimensions in the model.
discrete_value_varsAll the discrete value variables in the model.
familyCurated response family for the built-in GLM.
isrootlinkRead-only canonical inverse link for
family.observedlogpPyTensor scalar of log-probability of the observed variables.
parentpotentiallogpPyTensor scalar of log-probability of the Potential terms.
prefixrootunobserved_RVsList of all random variables, including deterministic ones.
unobserved_value_varsList of all random variables (including untransformed projections), as well as deterministics used as inputs and outputs of the model's log-likelihood graph.
value_varsList of unobserved random variables used as inputs to the model's log-likelihood (which excludes deterministics).
varlogpPyTensor scalar of log-probability of the unobserved random variables (excluding deterministic).
varlogp_nojacPyTensor scalar of log-probability of the unobserved random variables (excluding deterministic) without jacobian term.
- __init__(family='gaussian', sample_kwargs=None, priors=None)[source]#
- Parameters:
sample_kwargs (
dict[str,Any] |None) – Dictionary of kwargs that get unpacked and passed to thepymc.sample()function. Defaults to an empty dictionary if None.priors (
dict[str,Any] |None) – Dictionary of priors for the model. Defaults to None, in which case default priors are used.family (Literal['gaussian', 'poisson', 'negative_binomial', 'bernoulli'])
- Return type:
None
- classmethod __new__(*args, **kwargs)#