survey_mean
Compute survey-adjusted means and standard errors for clustered or stratified data using replicate weights or jackknife zones. Supports plausible values and group estimates to avoid inaccurate inference.
Instructions
Means for complex survey data, with design-correct standard errors. Use this instead of describe whenever the data comes from a clustered or stratified sample — the ordinary standard error assumes a simple random sample and can be less than half the true value.
For achievement scores use plausible values, never a single score: pv_prefix='BSMMAT' expands to BSMMAT01..05 (TIMSS style), or pv_pattern='PV{i}MATH' expands to PV1MATH.. (PISA style). The output reports how much of the standard error comes from sampling versus measurement.
Give the design one of two ways: replicate_weights (existing columns — either a list of names or a prefix such as 'W_FSTURWT' that matches W_FSTURWT1..80), or jkzone + jkrep so JK2 replicates are built for you (TIMSS/PIRLS ship JKZONE and JKREP). method defaults to JK2 for constructed replicates and Fay for 60+ supplied columns, which is what PISA needs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | Report the mean separately for each level of this column. | |
| fay | No | Fay factor when method='fay'; PISA uses 0.5. | |
| data | Yes | Dataset name in the session. | |
| jkrep | No | Jackknife replicate indicator column (TIMSS: JKREP). | |
| digits | No | Decimal places. | |
| jkzone | No | Jackknife zone column (TIMSS: JKZONE). | |
| method | No | Replication method: auto, jk2, jk1, brr or fay. | auto |
| weight | Yes | Final sampling weight column, e.g. TOTWGT (TIMSS) or W_FSTUWT (PISA). | |
| pv_count | No | How many plausible values (default 5 for prefix, 10 for pattern). | |
| pv_prefix | No | Plausible-value prefix, e.g. 'BSMMAT' for BSMMAT01..05. | |
| variables | No | Ordinary numeric columns to average. Omit when using plausible values. | |
| pv_pattern | No | Plausible-value pattern with {i}, e.g. 'PV{i}MATH'. | |
| replicate_weights | No | Replicate weight columns, or a prefix matching them. |