Statistics API
On this page
Examples
These functions turn model results from phit and draws from CmdStanPHP into plots. Each returns an ordinary Plot or Compose, which any plot method can restyle. Fits are phit’s fit objects (Phit\Fit, from phit 0.6) or arrays in the same shape. Statistics describes the keys each one reads and shows each one.
Functions: coefplot() · residual_plot() · qq_plot() · fitted_plot() · scale_location_plot() · diagnostic_plots() · effect_plot() · predictions() · interval_plot() · marginal_means() · random_effects_plot()
coefplot()
coefplot(object|array $fits, mixed ...$options): PlotCoefficient plot of one fit, or of several keyed by label (dodged side by side).
residual_plot()
residual_plot(object|array $fit): PlotResiduals against fitted values, with a reference line at zero.
qq_plot()
qq_plot(object|array $fitOrValues, bool $standardize = false): PlotA normal QQ plot of a fit’s residuals, or of a list of values; standardize scales them first.
fitted_plot()
fitted_plot(object|array $fit, ?array $observed = null): PlotObserved against fitted values, with the identity line; observed defaults to fitted plus residuals.
scale_location_plot()
scale_location_plot(object|array $fit): PlotThe square root of the absolute residuals divided by sigma, against fitted values, as R’s plot(fit, 3).
diagnostic_plots()
diagnostic_plots(object|array $fit, mixed ...$options): Composeresidual_plot(), qq_plot(), scale_location_plot(), and fitted_plot() in a two-by-two grid.
effect_plot()
effect_plot(object|array $fit, mixed $data, string $x, mixed ...$options): PlotPredicted values with confidence bands as x varies (by levels of $by), other variables held at typical values.
predictions()
predictions(object|array $fit, array $grid, mixed ...$options): arrayThe predicted rows behind effect_plot() for a grid of rows, without plotting them: each row with estimate, lower, upper, and std_error.
interval_plot()
interval_plot(array $draws, mixed ...$options): PlotPosterior intervals from draws columns or a summary, as bayesplot’s mcmc_intervals.
marginal_means()
marginal_means( object|array $fit, mixed $data, string $factor, mixed ...$options,): PlotEstimated marginal means of a factor with confidence intervals, as emmeans.
random_effects_plot()
random_effects_plot(object|array $fit, mixed $data = null, mixed ...$options): PlotA caterpillar plot of a mixed model’s random effects with conditional intervals, as lme4’s dotplot(ranef()).