diagnose

diagnose(data=None, *columns, type='auto', by=None, z=Z_95, digits=2)

Survey precision diagnostics for one or more columns.

The headline diagnostics wrapper: for each selected column it auto-detects whether it is a point estimate (numeric, e.g. a 1-5 rating) or a proportion (categorical), and returns a tidy table of sample size, estimate, standard error, relative standard error and margin of error: the whole appendix “Data info” block as one call.

For numeric columns the estimate is the mean and the error is in rating points; for categorical columns the estimate is the largest answer category’s share, which gives a single concrete plus-or-minus percentage-point margin to quote (the largest category is also the worst case among the observed categories, so it is a sensible headline). The precision column is the five-band rating from rse_rating(). For the narrative bullet-point version see precision_summary().

Parameters

Name Type Description Default
data pandas.DataFrame A data frame. If omitted, the session default is used. None
*columns str or selector Columns to diagnose, e.g. starts_with("ratings_"), “demo_gender”. ()
type str Force the estimate type: “auto” (default, detect per column), “mean” or “prop”. 'auto'
by str or list of str Grouping column(s); diagnostics are computed within group. None
z float Margin-of-error multiplier passed to margin_of_error(). Default 1.96 (95%). Z_95
digits int Decimal places for the numeric output columns. Default 2. 2

Returns

Name Type Description
pandas.DataFrame One row per column (per group), with variable, type, unit, n, estimate, se, rse, moe and precision. For type “mean”, unit is “points”; for proportions it is “ppt” (percentage points) and estimate is a percentage.

See Also

precision_summary, rse_rating, se_mean, se_prop

Examples

>>> diagnose(podracing_survey, "demo_gender", "nps_value")
>>> diagnose(podracing_survey, starts_with("ratings_"))