phit

Functions and methods

phit provides 235 functions in the Phit namespace, the fit and table objects the models return, and the CsvReader class. Each name links to its reference entry. Import functions with use function Phit\{...};.

Models

Function Purpose
fit_ols() Fit a linear model from a formula, like R’s lm().
fit_generalized_linear() Fit a Gaussian, binomial, or Poisson GLM from a formula, like R’s glm().
model_matrix() Build the numeric design of a formula, like R’s model.matrix().
predict() Predict new data from a formula fit, with standard errors or intervals.
fit_ols_matrix() Fit a linear model by least squares on a numeric design.
fit_logistic_matrix() Fit a binomial logit model on a numeric design.
fit_probit_matrix() Fit a binomial probit model on a numeric design.
fit_poisson_matrix() Fit a Poisson log-link model on a numeric design.
summary() Print a model fit as R’s print(summary(fit)) does.
tidy() Return a fit’s coefficient table as columns, like broom’s tidy().

Mixed models

Function Purpose
fit_mixed_gaussian() Fit a Gaussian mixed model from an lme4 formula, like lme4::lmer().
fit_mixed_logistic() Fit a binomial logit model with one random intercept from a formula, like lme4::glmer().
fit_mixed_gaussian_matrix() Fit a Gaussian mixed model on a numeric design with explicit random terms.
fit_mixed_gaussian_intercept_matrix() Fit a Gaussian model with one random intercept by ML on a numeric design.
fit_mixed_logistic_matrix() Fit a binomial logit model with one random intercept on a numeric design.

Descriptive statistics and optimization

Function Purpose
stat_mean() Arithmetic mean.
stat_median() Median.
stat_var() Sample or population variance.
stat_sd() Sample or population standard deviation.
stat_quantile() One sample quantile, R type 7.
stat_quantile_array() Several sample quantiles from one sort, R type 7.
stat_weighted_mean() Weighted mean.
stat_weighted_var() Weighted variance with frequency, reliability, or population weights.
stat_cov() Sample or population covariance of two aligned arrays.
stat_cor() Pearson correlation of two aligned arrays.
stat_density() Kernel density estimate, like R’s density().
stat_bw_nrd0() Silverman’s rule-of-thumb bandwidth, like R’s bw.nrd0().
stat_bw_nrd() Scott’s variation of the rule-of-thumb bandwidth, like R’s bw.nrd().
stat_approx() Linear or step interpolation, like R’s approx().
stat_ecdf() Empirical CDF at given points.
optimize() Minimize or maximize a function on an interval, like R’s optimize().
uniroot() Find a root of a function on an interval, like R’s uniroot().

Posterior draws

Function Purpose
draws_moments() Weighted mean and covariance of posterior draws.
draws_covariance_map() Matrix that maps one covariance to another.
draws_affine() Apply an affine transformation to every draw.

Sampling

Function Purpose
dist_uniform_rng() Seeded uniform samples.
dist_categorical_rng() Seeded category indices drawn with given probabilities.
dist_categorical_rows_rng() One seeded category index per row of probabilities.
permutation_rng() A seeded random permutation or sample without replacement.
dist_{family}_rng() Seeded samples from one of the 13 parameterizations below.

CSV input

Function Purpose
read_csv() Read a delimited text file into typed columns.
CsvReader Class: read a CSV file a chunk of rows at a time.

Distributions

Each family has these functions, in scalar form and with an _array suffix over a list of points. Discrete families have pmf and logpmf in place of pdf and logpdf.

Family pdf / pmf logpdf / logpmf cdf logcdf sf logsf quantile rng
Normal pdf logpdf cdf logcdf sf logsf quantile rng
Student’s t pdf logpdf cdf logcdf sf logsf quantile rng
Chi-square pdf logpdf cdf logcdf sf logsf quantile rng
F pdf logpdf cdf logcdf sf logsf quantile rng
Beta pdf logpdf cdf logcdf sf logsf quantile rng
Gamma pdf logpdf cdf logcdf sf logsf quantile rng
Exponential pdf logpdf cdf logcdf sf logsf quantile rng
Log-normal pdf logpdf cdf logcdf sf logsf quantile rng
Logistic pdf logpdf cdf logcdf sf logsf quantile rng
Binomial pmf logpmf cdf logcdf sf logsf quantile rng
Poisson pmf logpmf cdf logcdf sf logsf quantile rng
Negative binomial (size, prob) pmf logpmf cdf logcdf sf logsf quantile rng
Negative binomial (size, mu) pmf logpmf cdf logcdf sf logsf quantile rng