PanelRegression.plot_trajectories#
- PanelRegression.plot_trajectories(units=None, n_sample=10, select='random', show_mean=True, hdi_prob=0.94)[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], optional) – Specific unit IDs to plot. If provided, ignores n_sample and select.
n_sample (int, default=10) – Number of units to sample if units not specified.
select ({"random", "extreme", "high_variance"}, default="random") – 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, default=True) – Whether to show the overall mean trajectory.
hdi_prob (float, default=0.94) – Probability mass for the HDI credible interval (Bayesian models only). Common values are 0.94 (default) or 0.89.
- 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)