PanelRegression.plot_trajectories#
- PanelRegression.plot_trajectories(units=None, n_sample=10, select='random', show_mean=True, hdi_prob=0.94, interval_type='mean')[source]#
Plot unit-level time series trajectories.
Shows actual vs fitted values for selected units over time. Useful for visualizing within-unit model fit and identifying problematic units.
- Parameters:
units (
list[str] |None) – Specific unit IDs to plot. If provided, ignores n_sample and select.n_sample (
int) – Number of units to sample if units not specified.select (
Literal['random','extreme','high_variance']) –Method for selecting units:
”random”: Random sample of units
”extreme”: Units with largest positive and negative effects
”high_variance”: Units with most within-unit variation
show_mean (
bool) – Whether to show the overall mean trajectory.hdi_prob (
float) – Probability mass for the HDI credible interval (Bayesian models only). Defaults toHDI_PROB(currently 0.94). Common alternative values are 0.89 or 0.5.interval_type (
Literal['mean','predictive']) –Which uncertainty interval to show for Bayesian models:
”mean”: HDI of posterior
mu(uncertainty in expected value)”predictive”: HDI of posterior predictive
y_hat(includes observation noise)
- Returns:
Figure and array of axes objects
- Return type:
tuple[plt.Figure, np.ndarray]
- Raises:
ValueError – If time_fe_variable is not provided (cannot plot trajectories without time)