**[R] ratio** -- Estimate ratios

__Syntax__

Basic syntax

**ratio** [*name***:**] *varname* [**/**] *varname*

Full syntax

**ratio** **(**[*name***:**] *varname* [**/**] *varname***)**
[**(**[*name***:**] *varname* [**/**] *varname***)** ...] [*if*] [*in*] [*weight*] [**,**
*options*]

*options* Description
-------------------------------------------------------------------------
Model
__std__**ize(***varname***)** variable identifying strata for
standardization
__stdw__**eight(***varname***)** weight variable for standardization
__nostdr__**escale** do not rescale the standard weight variable

if/in/over
**over(***varlist*[**,** __nolab__**el**]**)** group over subpopulations defined by *varlist*;
optionally, suppress group labels

SE/Cluster
**vce(***vcetype***)** *vcetype* may be __linear__**ized**, __cl__**uster** *clustvar*,
__boot__**strap**, or __jack__**knife**

Reporting
__l__**evel(***#***)** set confidence level; default is **level(95)**
__noh__**eader** suppress table header
__nol__**egend** suppress table legend
*display_options* control column formats and line width

__coefl__**egend** display legend instead of statistics
-------------------------------------------------------------------------
**bootstrap**, **jackknife**, **mi estimate**, **rolling**, **statsby**, and **svy** are allowed;
see prefix.
**vce(bootstrap)** and **vce(jackknife)** are not allowed with the **mi estimate**
prefix.
Weights are not allowed with the **bootstrap** prefix.
**vce()** and weights are not allowed with the **svy** prefix.
**fweight**s, **iweight**s, and **pweight**s are allowed; see weight.
**coeflegend** does not appear in the dialog box.
See **[R] ratio postestimation** for features available after estimation.

__Menu__

**Statistics > Summaries, tables, and tests >** **Summary and descriptive**
**statistics > Ratios**

__Description__

**ratio** produces estimates of ratios, along with standard errors.

__Options__

+-------+
----+ Model +------------------------------------------------------------

**stdize(***varname***)** specifies that the point estimates be adjusted by direct
standardization across the strata identified by *varname*. This option
requires the **stdweight()** option.

**stdweight(***varname***)** specifies the weight variable associated with the
standard strata identified in the **stdize()** option. The
standardization weights must be constant within the standard strata.

**nostdrescale** prevents the standardization weights from being rescaled
within the **over()** groups. This option requires **stdize()** but is
ignored if the **over()** option is not specified.

+------------+
----+ if/in/over +-------------------------------------------------------

**over(***varlist* [**,** **nolabel**]**)** specifies that estimates be computed for
multiple subpopulations, which are identified by the different values
of the variables in *varlist*.

When this option is supplied with one variable name, such as **over(**
*varname***)**, the value labels of *varname* are used to identify the
subpopulations. If *varname* does not have labeled values (or there
are unlabeled values), the values themselves are used, provided that
they are nonnegative integers. Noninteger values, negative values,
and labels that are not valid Stata names are substituted with a
default identifier.

When **over()** is supplied with multiple variable names, each
subpopulation is assigned a unique default identifier.

**nolabel** specifies that value labels attached to the variables
identifying the subpopulations be ignored.

+------------+
----+ SE/Cluster +-------------------------------------------------------

**vce(***vcetype***)** specifies the type of standard error reported, which
includes types that are derived from asymptotic theory (**linearized**),
that allow for intragroup correlation (**cluster** *clustvar*), and that
use bootstrap or jackknife methods (**bootstrap**, **jackknife**); see **[R]**
*vce_option*.

**vce(linearized)**, the default, uses the linearized or sandwich
estimator of variance.

+-----------+
----+ Reporting +--------------------------------------------------------

**level(***#***)**; see **[R] estimation options**.

**noheader** prevents the table header from being displayed. This option
implies **nolegend**.

**nolegend** prevents the table legend identifying the subpopulations from
being displayed.

*display_options*: **cformat(***%fmt***)** and **nolstretch**; see **[R] estimation**
**options**.

The following option is available with **ratio** but is not shown in the
dialog box:

**coeflegend**; see **[R] estimation options**.

__Examples__

---------------------------------------------------------------------------
Setup
**. webuse fuel**

Estimate ratio of **mpg1** to **mpg2** and call it **myratio**
**. ratio myratio: mpg1/mpg2**

---------------------------------------------------------------------------
Setup
**. webuse census2**

Estimate ratio of **death** to **pop** and ratio of **marriage** to **pop** and call the
ratios **deathrate** and **marrate**, respectively
**. ratio (deathrate: death/pop) (marrate: marriage/pop)**

---------------------------------------------------------------------------
Setup
**. webuse highschool**
**. svyset**

Estimate height-weight ratio
**. svy: ratio height/weight**

Estimate race- and gender-specific height-weight ratios
**. svy: ratio height/weight, over(race sex)**
---------------------------------------------------------------------------

__Stored results__

**ratio** stores the following in **e()**:

Scalars
**e(N)** number of observations
**e(N_over)** number of subpopulations
**e(N_stdize)** number of standard strata
**e(N_clust)** number of clusters
**e(k_eq)** number of equations in **e(b)**
**e(df_r)** sample degrees of freedom
**e(rank)** rank of **e(V)**

Macros
**e(cmd)** **ratio**
**e(cmdline)** command as typed
**e(varlist)** *varlist*
**e(stdize)** *varname* from **stdize()**
**e(stdweight)** *varname* from **stdweight()**
**e(wtype)** weight type
**e(wexp)** weight expression
**e(title)** title in estimation output
**e(clustvar)** name of cluster variable
**e(over)** *varlist* from **over()**
**e(over_labels)** labels from **over()** variables
**e(over_namelist)** names from **e(over_labels)**
**e(namelist)** ratio identifiers
**e(vce)** *vcetype* specified in **vce()**
**e(vcetype)** title used to label Std. Err.
**e(properties)** **b V**
**e(estat_cmd)** program used to implement **estat**
**e(marginsnotok)** predictions disallowed by **margins**

Matrices
**e(b)** vector of ratio estimates
**e(V)** (co)variance estimates
**e(_N)** vector of numbers of nonmissing observations
**e(_N_stdsum)** number of nonmissing observations within the
standard strata
**e(_p_stdize)** standardizing proportions
**e(error)** error code corresponding to **e(b)**

Functions
**e(sample)** marks estimation sample