InstrumentalVariableRegression#
- class causalpy.pymc_models.InstrumentalVariableRegression[source]#
Custom PyMC model for instrumental linear regression
Methods
Registers a dimension coordinate with the model.
Vectorized version of
Model.add_coord.Add a random graph variable to the named variables of the model.
Specify model with treatment regression and focal regression data and priors
Check that the starting values for MCMC do not cause the relevant log probability to evaluate to something invalid (e.g. Inf or NaN).
Compiled log probability density hessian function.
Compiled log probability density gradient function.
Compiles an PyTensor function
Compiled log probability density function.
Create a
TensorVariablethat will be used as the random variable's "value" in log-likelihood graphs.Hessian of the models log-probability w.r.t.
Debug model function at point.
InstrumentalVariableRegression.dlogp([vars, ...])Gradient of the models log-probability w.r.t.
Evaluates shapes of untransformed AND transformed free variables.
InstrumentalVariableRegression.fit(X, Z, y, ...)Draw samples from posterior distribution and potentially from the prior and posterior predictive distributions.
Computes the initial point of the model.
InstrumentalVariableRegression.logp([vars, ...])Elemwise log-probability of the model.
Compile an PyTensor function that computes logp and gradient.
Create a TensorVariable for an observed random variable.
Checks if name has prefix and adds if needed
Checks if name has prefix and deletes if needed
Computes the log probability of point for all random variables in the model.
Predict data given input data X
Compiles and profiles an 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.
InstrumentalVariableRegression.sample_predictive_distribution([...])Function to sample the Multivariate Normal posterior predictive Likelihood term in the IV class.
Score the Bayesian \(R^2\) given inputs
Xand outputsy.Changes the values of a data variable in the model.
InstrumentalVariableRegression.set_dim(name, ...)Update a mutable dimension.
Sets an initial value (strategy) for a random variable.
Produce a graphviz Digraph from a PyMC model.
Update point a with b, without overwriting existing keys.
Attributes
basic_RVsList of random variables the model is defined in terms of (which excludes deterministics).
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
dim_lengthsThe symbolic lengths of dimensions in the model.
discrete_value_varsAll the discrete value variables in the model
isrootobservedlogpPyTensor 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.