PTMLocScale

Contents

PTMLocScale#

class liesel_ptm.PTMLocScale(knots, y, normalization_tau2, transition_width=0.3, scale_after_transformation=False, scaling_factor=None, shape_param_prior=ShapePrior.RANDOM_WALK)[source]#

Bases: object

Penalized transformation model for location and scale.

Parameters:
  • knots (Any) – The knots used to the define the transformation function.

  • y (Any) – The observed response variable.

  • normalization_tau2 (Var) – The variance parameter \(\tau^2_\delta\) for the prior of the transformation function’s shape parameters.

  • transition_width (float) – The width of the transition segment of the transformation function. A number larger than 0, indicating the length in terms of a multiple of the range of interior knots. Called \(\lambda\). (default: 0.3)

  • scale_after_transformation (bool) – Whether to scale the response variable after the transformation. It is not avisable to switch this to True. (default: False)

  • scaling_factor (Optional[Var]) – The scaling factor \(\omega\) for the transformation function. If None, the scaling factor will be fixed to one. (default: None)

  • shape_param_prior (ShapePrior) – The prior distribution for the shape parameter. (default: <ShapePrior.RANDOM_WALK: 1>)

Methods

all_parameter_names

all_sampled_parameter_names

build_graph

Builds the model graph.

from_nparam

Initializes a penalized transformation model automatically from the desired number of shape parameters.

new_from_graph

Given a Liesel model graph, this creates a new PTMLocScale with updated knots.

optimize_knots

Finds good knots for the transformation function.

setup_engine_builder

Prepares a liesel.goose.EngineBuilder for MCMC sampling.

waic

Assembles a pd.DataFrame that gives information on the widely applicable information criterion for this model.

Attributes

knots

The knots of the transformation function's spline segment.

transition_width

The transition width.

loc_model

Predictor for the location model part.

log_scale_model

Predictor for the log scale model part.

scale_model

The exponential of log_scale_model.

normalization_tau2

The hyperparameter \(\tau^2_\delta\).

scale_after_transformation

Whether to scale the response variable after the transformation.

scaling_factor

The scaling factor \(\omega\) for the transformation function.

shape_param_prior

The prior distribution for the shape parameter.

loc_intercept

Intercept \(\beta_0\) of the location model part.

scale_intercept_exp

Exponential of the intercept \(\exp(\gamma_0)\) of the scale model part.

loc

The response's location, including an intercept.

scale

The response's scale, including an intercept.

residuals

The residuals.

normalization

Organizes the transformation model part \(h(\varepsilon\)).

z_deriv

Derivative of \(h(\varepsilon)\) with respect to the response.

z

Variable for the transformation model part \(h(\varepsilon\)).

refdist

The reference distribution, currently fixed to the standard normal distribution.

response

Response variable.

intercept_names

Names of the intercept nodes.