help igenerate Alexander Schmidt-Catran

Applying different coding schemes to categorical variables (1.0.3 - beta version)

:

Syntax

igenerate varlist [if] [in] , coding(coding scheme) [generate(stubnames)] [omit(omitted categories)] [ia]

Description

ignerate allows generating indicator variables for different coding schemes. ignerate creates variable for the following coding schemes:

1. Dummy coding

2. Effect/deviation coding

3. Weighted effect/deviation coding

4. Forward adjacent coding

5. Backward adjacent coding

Additionally, ignerate allows generating orthogonal interaction terms of weighted effect coded indicator variables (see Te Grotenhuis et al., 2016b) .

ignerate allows a maximum of two variables in varlist. It should in principle be used with one variable at a time.
Speciyfing two variables in varlist should be done if interaction terms between these two variables are to be build.

Note that stata provides a build-in postestimation command (contrast) that provides regression results for a variety of different coding schemes.
For most situations in applied research contrast may be the better alternative. However, for didactical purposes and some special situations
igenerate might be a valuable alternative because it allows getting the estimates directly from the regression output without
the need to apply a postestimation command. Orthogonal interaction terms of weighted effect coded indicator variables are also not available in contrast.

Options

coding(coding scheme) specifies the coding scheme to be applied. coding scheme must be one of the following alternatives:

dummy: Standard dummy coding. Compares the levels of the variables in varlist to one reference category.
If the option omit is not specified, igenerate will generate as many indicators as the variables in varlist have levels.
If the option omit is specified, igenerate will not generate indicator variables for the chosen reference categories.
In this case, the labels of the remaining dummy variables will indicate the reference group.

effect: Effect/Deviation coding. Compares the levels of the variables in varlist to their grand mean; this is, the mean of the dependent variable
as if all categories of the variables in varlist had the same number of observations. If the option omit is not specified,
igenerate will select the first category of the variables in varlist as the omitted categories. If the option omit is specified,
igenerate will not generate an indicator variable for the chosen categories. The labels of the generated variables will indicate the contrast.

weightedeffect: Weighted effect/deviation coding. compares the levels of the variables in varlist to the observed mean. If the option omit is not specified,
igenerate will select the first category of the variables in varlist as the omitted categories. If the option omit is specified,
igenerate will not generate an indicator variable for the chosen categories. The labels of the generated variables will indicate the contrast.

we: Same as weightedeffect.

sweeney: Same as weightedeffect.

adjacent: Compares each level of the variables in varlist to the next (adjacent) level.
This option cannot be combined with omit because the omitted category is always the first.
The labels of each generated variable indicate the reference group.

reverseadjacent: Compares each level of the variables in varlist to the former (prior adjacent) level.
This option cannot be combined with omit because the omitted category is always the first.
The labels of each generated variable indicate the reference group.

ra: Same as reverseadjacent.

ia Generates orthogonal interaction terms of weighted effect coded indicator variables. ia is allowd only in combination with weighted effect
coding (sweeney coding). ia needs two variables in varlist. It builds interaction terms between the two sets of indicators from these two variables.

generate(stubnames) Defines the name(s) for the generated indicator variables.
If the option generate is specified, the constructed variables will begin with stubname followed by consecutive numbers.
If the option generate is not specified, stubname will be identical to the variables' names in varlist.

omit(omitted categories) Specifies the categories of the variables in varlist that ought to be omitted from the regression.
omit is not allowed in combination with (reversed) adjacent coding. If omit is not specified,
igenerate will select the first level as the omitted category for every coding scheme except dummy coding
(because dummy coding is independent of the reference category). If omit is specified, igenerate will omit the specified category.
If varlist contains two variables, omit allows two distinct numbers to be specified. If varlist contains two variables and omit contains only one argument,
the category specified in omit is used as the omitted category for both variables.
Note that the omitted category is the value of that category, not the position of that category.

Notes

Note that some coding schemes (in particular weighted effect coding) may require that igenerate knows the sample that is used in the
following regression. If your regression excludes cases for which the variables in varlist have valid observations (non-missing values), you should use if
to restrict igenerate to the corresponding sample, if you want the reference to be the observed mean in the sample of the regression.

References

Te Grotenhuis, M.; Pelzer, B.; Schmidt-Catran, A.W.; Nieuwenhuis, R.; König, R. and Eisinga, R. (2016a): When Size Matters. Advantages of Weighted Effect Coding in Observational Studies. International Journal of Public Health (online first).

Te Grotenhuis, M.; Pelzer, B.; Schmidt-Catran, A.W.; Nieuwenhuis, R.; König, R. and Eisinga, R. (2016b): Weighted effect coded interaction effects: a novel moderated regression model for observational studies. International Journal of Public Health (online first).

Authors

Alexander Schmidt-Catran, Institute of Sociology and Social Psychology, University of Cologne, alex@alexanderwschmidt.de,
www.schmidt-catran.de.