Skip to content

Distribution functions and moments

In the app: Help → Help contents, Distribution functions and moments.

Formulas (derived series, equations, measurement maps and model text) can use distribution functions named as in MATLAB and Dynare: normpdf, normcdf and norminv (x, then optionally mu and sigma: normcdf(x) is the standard normal), tpdf, tcdf and tinv (x, df), chi2pdf, chi2cdf and chi2inv (x, df), fpdf, fcdf and finv (x, d1, d2), gampdf, gamcdf and gaminv (x, a, b: shape a and scale b, so the mean is a*b, as in MATLAB), betapdf, betacdf and betainv (x, a, b), lognpdf, logncdf and logninv (x, mu, sigma of log x), unifpdf, unifcdf and unifinv (x, a, b, default 0 and 1), exppdf, expcdf and expinv (x, mu: the mean, not the rate), poisspdf and poisscdf (k, lambda), binopdf and binocdf (k, n, p), and erf and erfc. The inv functions are quantiles: norminv(0.975) is 1.96; poissinv (p, lambda) and binoinv (p, n, p) are MATLAB's, the smallest integer k with cdf(k) >= p, and have no derivative (a model cannot be linearised through them). Arguments may be expressions and parameters, and models using these functions are linearised with their exact derivatives; where no derivative is offered (in the degrees of freedom of t, chi-squared and F, the shape parameters of gamma and beta, a binomial's n), linearisation stops with a message rather than an approximation. Dynare and IRIS files can use normcdf, normpdf and erf; the others cannot be exported to them.

Moving-window statistics look back over the last n periods, within each entity of a panel: movavg(x, n), movsum, movsd, movvar, movmin and movmax, and between two series movcov(x, y, n), movcorr(x, y, n) and movbeta(y, x, n), the slope of a rolling regression of y on x. They are missing until a full window of data is there, and variances use n - 1. Centred windows put the window around t: cmovavg(x, 5) uses x[+2] ... x[-2] (an even n one more lag than leads), and every moving function has one (cmovsum ... cmovbeta); a model reads their leads as leads. Expanding windows use every period up to t, within each entity: cumavg(x), cumsum, cumsd, cumvar, cummin, cummax, cumcov(x, y), cumcorr(x, y) and cumbeta(y, x), as pandas' expanding(); they work on data only, not in models.

Where the latest value stands in its window, for surveillance charts and alerts: movzscore(x, n) is (x - mean) / standard deviation over the last n periods; movrzscore(x, n) the robust form, (x - median) / (1.4826 x the median absolute deviation), which a single outlier in the window hardly moves; movpctrank(x, n) the percentile rank of x among the n values of its window, itself included, from 100/n for the smallest to 100 for the largest, tied values sharing the average of their ranks (100 (below + (equal + 1) / 2) / n); and movquantile(x, n, q) the q quantile of the window (0.5 the median). Like the other moving functions they are missing until the window is full or when a value in it is missing, and a constant window's z-score is missing. expzscore(x), exprzscore(x) and exppctrank(x) use every period up to t (data only). Against a fixed reference period, use pymetrix.heatmap.normalise(data, series, reference=("2010", "2019")).

For a dataset, describe() gives count, mean, standard deviation, percentiles, skewness and excess kurtosis (bias-corrected, as pandas and Excel compute them; 0 for a normal); corr() Pearson, Spearman or Kendall correlations; cov() covariances; partial_corr() correlations holding other series constant; crosscorrelogram() the correlations of x(t) with y(t+k) at leads and lags; and autocov() the autocovariances of a series.

See also

References

  • Johnson, N. L., Kotz, S. and Balakrishnan, N. (1994). Continuous Univariate Distributions, 2nd ed. (search)
  • Joanes, D. N. and Gill, C. A. (1998). Comparing measures of sample skewness and kurtosis. The Statistician 47(1), 183-189. (search)
  • Box, G. E. P., Jenkins, G. M., Reinsel, G. C. and Ljung, G. M. (2015). Time Series Analysis, 5th ed., chapter 12 (cross-correlations). (search)