help for funnelcompar                                 (Silvia Forni, Rosa Gini)


funnelcompar Funnel plot for institutional comparison


funnelcompar value pop unit [sdvalue] [if] [in] , continuous/binomial/poisson [smr] [ options]

options Description ------------------------------------------------------------------------- Distribution (mandatory) continuous normal distribution binomial binomial distribution poisson Poisson distribution smr values are indirectly standardised rates

Distribution parameters noweight specify that target value and/or standard deviation of the target distribution must be computed from the data, but without using pop as weights ext_stand(num) specify target value as an external standard, instead of weighted mean of value ext_sd(num) specify standard deviation as an external value, instead of weighted mean of sdvalue

Contours contours(numlist) specify significance levels (in percentage) of the contours to be plotted; default is 5% and 0.2%, that is c(5 .2) exact specify that contours are computed using an exact formula instead of the normal approximation (only valid for discrete distributions; implies Stata version 10.0) contcolor(color) specify colour of the contour lines if shadedcontours is not specified shadedcontours specify shaded, instead of black, contour lines solidcontours specify solid, instead of dashed, contour lines

Constant constant(num) contains the multiplicative constant by which the indicators contained in value are multiplied, e.g. 100 if they are percentages

Legend legendcontour specify that contours should be labeled with labels of the form "Sign. 5%" legendmore(options) specify any additional graph to be labeled; the options string must be contained in compound double quotes, e.g. `"3 "lower bound""' legendoptions(options) specify any legend_options

Marking options: principal scatter scattercolor(color) colour of scatter points scatteropts(options) other marker_options unitlabel(string) string to be used in the legend of the scatter points, instead of the variable label of unit or the string "Units" markall specify that all scatter points should be labeled with the value label or, if there is no value label, with the actual value of the unit they represent

Marking options: contours markup specify that points upper the countour at significance markcontour should be coloured in markupcolor and labeled with the label or value of the unit they represent markupcolor(color) option of markup marklow specify that points lower the countour at significance markcontour should be coloured in marklowcolor marklowcolor(color) option of marklow markcontour(num) option of markup and/or marklow, the default is the first contour of the numlist in contours(numlist) - if contours is not specified, the default is significance 5%

Marking options: conditions markcond(condition) must contain a condition valid on the active dataset; specifies that points satisfying that condition should be coloured in colormarkcond with marker_options contained in optionsmarkcond and that the legend of this scatter should be legendmarkcond colormarkcond(color) option of markcond legendmarkcond(string) option of markcond optionsmarkcond(options) option of markcond markcond1(condition)... up to 5 conditions might be specified of the form markcondi(condition); specifies that points satisfying markcondi(string) should be coloured in colormarkcondi(color) with marker_options contained in optionsmarkcondi(options) and that the legend of this scatter should be legendmarkcondi(string)

Marking options: markunit markunits(# "text" [# ["text"] ...]) list a set of values of unit whose scatter point must labeled; if a string is specified after a value, then that string is used to label the unit corresponding to that value, otherwise value label or value itself is used markcolor(color) specify the colour of the units marktextoptions(options) specify any added_text_options; default is placement(ne)

Other graph options vertical plot a vertical funnel plot instead of a horizontal one linecolor(color) specify the colour of the target line extraplot(plot) specify additional plots to overlay the funnel plot title(string) specify title_options {y|x}title(string) specify axis title, see axis_options aspectratio(options) specify aspectratio, see aspect_option twowayopts(options) specify additional twoway_options possibly overriding other default or specified options (e.g. legending options)

Programming options displaycommand show the command that generates the graph saving(filename) save a dta file ready for funnel generation with the command displayed by displaycommand, with target value and other information saved as dataset characteristics nodraw avoid plotting the graph

------------------------------------------------------------------------- value contains the values of the indicator; pop contains the denominators of the indicator or, if smr is specified, the expected number of events; unit contains an identifier of the units (e.g. institutions) whose indicator values are to be compared with a target value; sdvalue is optionally specified in case the continuous option is also specified, and contains the standard deviations of the indicator values.


funnelcompar computes data and plots a funnel plot as defined by Spiegelhalter 2005. A scatter plot of an indicator values value is plotted against a measure of their precision pop, tipically the sample size, together with a target line and control limits (contours), that narrow as the sample size gets bigger. The plot graphically tests whether each value of the indicator is extracted from a target distribution specified by the options.

Target distribution and algorithm for parameter definition

The user must specify a distribution among normal, binomial or Poisson, respectively with the options continuous, binomial or poisson. The parameters of the target distribution (target value and standard deviation) are then defined. The target value is computed as a default as a weighted mean of value with weights pop. If the noweight option is specified it is computed as a simple mean. Finally, it might be specified by the user as an external value via the ext_stand option. If the distribution is binomial or Poisson with target value t then the standard deviation is obtained as the squared root of, respectively, t(1-t) and t. Only if the distribution is normal the standard deviation must be further estimated. As a default it is computed as a weighted mean of sdvalue with weights pop. If the noweight option is specified it is computed as a simple mean of sdvalue. Finally, it might be specified by the user as an external value via the ext_sd option. If the smr option is specified then poisson must be specified as well, and the target is assumed to be 1 (or the value specified in the constant option).


Plotting the default contours of the funnel plot corresponds to testing if the value of the indicator differ 2 or 3 standard deviations from the target value, as recommended by standard Statistical Process Control principles. Other significance values can be chosen with the contours() option. If the distribution is discrete (i.e. binomial or Poisson) the exact option specifies that the contours are plotted with an exact formula, that produces slightly different contours for small values of the indicator. As a default the normal approximation is used.


Plot funnel of percentages, specify an external target and specify the legend of the units . funnelcompar measure pop unit, binom const(100) ext_stand(23) unitlabel("LHAs")

Plot funnel of percentages and mark in blue a group of units and in green another group of units . funnelcompar measure pop unit, binomial const(100) markcond(group==3) legendmarkcond(Group 3) colormarkcond(blue) markcond1(group==5) legendmarkcond1(Group 5) colormarkcond1(green)

Plot funnel of indirectly standardised rates, mark in green a single point labelled "Your hospital", display the command and save a dataset containing instructions for plotting the graph again . funnelcompar smr expected hospital, poisson smr markunit(37 "Your hospital") display saving(for_funnel)

Plot funnel of means and label units that fail the test at 0.02% significance . funnelcompar mean pop unit sd, continuous markup marklow markcontour(.2)


Silvia Forni, Rosa Gini, Agenzia regionale di sanità della Toscana, Italy. Email: rosa.gini@arsanita.toscana.it


Spiegelhalter, DJ. Funnel plots for institutional comparison. Qual. Saf. Health Care 2002; 11:390-391.

Spiegelhalter, DJ. Funnel plots for comparing institutional performance. Statist. Med. 2005; 24:1185–1202.

Also see

Silvia Forni, Rosa Gini. Funnel plots for institutional comparisons. 2009 UK Stata Users Group meeting. abstract presentation

Online: confunnel (if installed)