pymc.model.transform.conditioning.change_value_transforms#
- pymc.model.transform.conditioning.change_value_transforms(model, vars_to_transforms)[source]#
Change the value variables transforms in the model.
- Parameters:
- model
Model
- vars_to_transforms
Dict
Dictionary that maps RVs to new transforms to be applied to the respective value variables
- model
- Returns:
- new_model
Model
Model with the updated transformed value variables
- new_model
Examples
Extract untransformed space Hessian after finding transformed space MAP
import pymc as pm from pymc.distributions.transforms import logodds from pymc.model.transform.conditioning import change_value_transforms with pm.Model() as base_m: p = pm.Uniform("p", 0, 1, default_transform=None) w = pm.Binomial("w", n=9, p=p, observed=6) with change_value_transforms(base_m, {"p": logodds}) as transformed_p: mean_q = pm.find_MAP() with change_value_transforms(transformed_p, {"p": None}) as untransformed_p: new_p = untransformed_p["p"] std_q = ((1 / pm.find_hessian(mean_q, vars=[new_p])) ** 0.5)[0] print(f" Mean, Standard deviation\\np {mean_q['p']:.2}, {std_q[0]:.2}") # Mean, Standard deviation # p 0.67, 0.16