*! version 1.2.1 07mar2013
help swindex (SJ20-4: st0622)

Title

swindex -- A command to create a standardized weighted
index of multiple indicator variables

Syntax

swindex
varlist
[if] [in], generate(varname)
[options]

* generate(varname) specify the new variable that takes the value of the constructed composite index

replace specify that if the variable in generate() already exists, it should instead be replaced

flip(varlist) reverse the sign of specified variables in varlist when calculating the index

normby(varname) specify that only observations for which varname is equal to one shall be used to normalize the variables in varlist for generalized least-squares (GLS) weighting procedure

nostd do not normalize the variables in varlist for GLS weighting procedure; cannot be combined with normby()

fullrescale rescale the final index based on the full sample mean and standard deviation; cannot be combined with norescale; default when normby() and nostd are not specified

norescale specify no rescaling of the final index; cannot be combined with fullrescale

numvars(newvar) store in newvar the number of nonmissing variables of varlist for each observation

displayw display the index weights for each indicator in varlist

* generate(varname) is required.

Description

swindex calculates a standardized weighted index from the variables in
varlist. The procedure follows a GLS weighting procedure as described in
Anderson (2008).

Several options are provided to allow the user to customize the calculation.
Variables included in the index should work in the same direction (for
example, increases in the variables all indicate better outcomes).
swindex allows users to include variables that move in the opposite
direction (for example, where increases indicate worse outcomes) by specifying
them in varlist provided in the option flip(). The signs of
variables included in flip() will change for the purposes of the
calculation, but no changes are made to the dataset in memory.

The recommended method standardizes the indicator variables in varlist
prior to constructing the inverted covariance matrix used in the GLS weighting
procedure. This standardization can employ a subsample (for example, the
control group) as a reference group, or otherwise use the full sample as a
reference group, for calculating the mean and standard deviation used for
normalization. By default, the program normalizes against the full sample
mean and standard deviation, which is equivalent to obtaining the weights by
inverting the correlation matrix. If the user wishes to use the mean and
standard deviation from a subsample, the user may specify the subsample
varname using the normby() option. For example, in a randomized
trial, the normby() option can be used to standardize based on the
control group subsample. The user can also opt not to standardize by invoking
nostd, though this is not recommended for most applications.

By default, the program rescales the calculated index to the mean and standard
deviation of the sample used for the standardization in the GLS weighting
procedure. This rescaling results in an "effect size" interpretation where
the index is distributed mean zero with standard deviation one within the
sample used. The fullrescale option allows the user to rescale the
calculated index using the full sample, even if normby() has been
invoked for the GLS weighting procedure. Further, the user can opt not to
rescale at all by specifying norescale.

The procedure accommodates construction of the index even when data on
indicators are missing. It does so by setting missing indicator values to
zero, which is the mean of the reference group following normalization. The
numvars() option saves the number of variables in varlist missing
for each observation.

Options

generate(varname) creates a new variable that takes the value of the
constructed composite index. varname in generate() does not have
to be a new varible name. Use the option replace if varname exists
and is to be replaced. generate() is required.

replace changes the contents of an existing variable. Because
replace alters data, the command cannot be abbreviated.

flip(varlist) alters the sign of variables in varlist to calculate
the index. This command should be used when the variables in varlist
move in the opposite direction as the summary index (for example, where
increases indicate "worse" outcomes). The variables in varlist provided
in flip() must be a subset of the variables in varlist. Invoking
this option will not result in changes to the variables in varlist in the
permanent dataset.

normby(varname) specifies the reference group over which to standardize
the variables in varlist during the GLS weighting procedure. When one
estimates impacts from a randomized intervention, normby() will
typically be an indicator for being in the control group. The specified
varname must be a binary variable. With normby(), the specified
varname is also used to rescale the calculated index unless the
fullrescale or norescale option is specified. This option cannot
be combined with nostd.

nostd specifies that no standardization should take place during the GLS
weighting procedure. When nostd is specified, the calculated index is
also not rescaled unless fullrescale is specified. This option cannot
be combined with normby().

fullrescale specifies the full sample be used to rescale the calculated
index. This is the default option when normby() and nostd are not
specified.

norescale specifies that the calculated index not be rescaled. This is
the default option when nostd is specified.

numvars(newvar) stores the number of nonmissing variables in
varlist for each observation.

displayw interactively displays the proportional weights used in the
index calculation. The displayed weight matrix is also stored in the return
list as r(pw), while the raw weights are stored as r(wt).

Examples

Setup

. sysuse auto

Create a new index called sizeindex from the variables trunk,
weight, and length. By default, size index will be standardized
using the full sample standard deviation and rescaled to be a standard normal
variable over the full sample.

. swindex trunk weight length, generate(sizeindex)

Replace sizeindex with an index that standardizes over the standard
deviation of foreign cars only.

. swindex trunk weight length, generate(sizeindex) normby(foreign) replace

Replace sizeindex with an index that standardizes over the standard
deviation of foreign cars but includes the negative value of mpg.

. swindex trunk weight length mpg, generate(sizeindex) replace flip(mpg) normby(foreign)

Stored results

swindex stores the following in r():

r(pw) matrix of proportional weights used to construct index variable

r(wt) matrix of raw weights used to construct index variable

Reference

Anderson, M. L. 2008. Multiple inference and gender differences in the effects
of early intervention: A reevaluation of the Abecedarian, Perry Preschool, and
Early Training Projects.
Journal of the American Statistical Association 103: 1481-1495.
https://doi.org/10.1198/016214508000000841.

Authors

Benjamin Schwab

Kansas State University

Department of Agricultural Economics

Manhattan, KS

benschwab@ksu.edu

Sarah Janzen

University of Illinois at Urbana Champaign

Department of Agricultural and Consumer Economics

Urbana, IL

sjanzen@illinois.edu

Nicholas P. Magnan

University of Georgia

Department of Agricultural and Applied Economics

Athens, GA

nmagnan@uga.edu

William M. Thompson

IDInsight

New Delhi, India

will.thompson@idinsight.org

Also see

Article: Stata Journal, volume 20, number 4: st0622