Virata manual

mean

The average, together with how precise that average is.

What we have

  • the mean with its standard error and confidence interval
  • over() and weights

Coming later

  • a survey design — weights alone give the right mean and the wrong standard error; use svy: mean

How you write it

mean varlist [if] [weight] [, over(var)]

Square brackets mean optional. A vertical bar means choose one.

What it does

summarize gives you the average. mean gives you the average plus its standard error and a 95% confidence interval — the range the true average plausibly lies in.

over(sector) reports it separately for each group. Weights are respected.

Watch out. This treats your rows as a simple random sample. If the data came from a survey with a design — stratified, clustered, weighted — use svy: mean instead, or the interval will be too narrow.

Try it

Every example below was run after sysuse vira.sample02, clear.

. mean mpce
Mean estimation

Number of obs   = 6,000
Design df       = 5,999
                 |          Mean     Std. err.    [95% conf.     interval]
-----------------+--------------------------------------------------------
            mpce |      3718.605      19.16605      3681.033      3756.178
The same thing in pandas and in R

pandas

# mean of ['mpce'] with linearised standard errors

R

# no R form for `mean` yet -- see docs/r-equivalents.md

Nearby

summarize tabulate tabstat correlate pwcorr ttest