------------------------------------------------------------------------------- help forxi3-------------------------------------------------------------------------------

Interaction expansion, enhancedNote:

xi3is not compatible with the following Stata commands:xtmixed,xtmelogitorxtmepoisson.

Caution:xi3should not be used with pweights, aweights or iweights.The

xi3command is the same as thexicommand, except that it allows 3 way interactions, any combination of continuous and categorical variables, and performs additional coding schemes beyond indicator coding, and can create codings that allow for testing simple contrasts and simple effects. It's syntax is much like thexicommand.

xi3[,prefix(string)]term(s)

xi3[,prefix(string)]:any_stata_commandvarlist_with_terms...where a term is a mixture of continuous (Con) and categorical (Cat) variables of the form:

Main Effects Con

varnameCatprefix.varnameTwo Way Interactions Cat by Cat

prefix.varname1*prefix.varname2Cat by Conprefix.varname1*varname2Con by Catvarname1*prefix.varname2Con by Convarname1*varname2Three Way Interactions Cat by Cat by Cat

prefix.varname1*prefix.varname2*prefix.varname3Cat by Cat by Conprefix.varname1*prefix.varname2*varname3... Con by Con by Convarname1*varname2*varname3and you can also request simple effects for two way interactions using the

@operatorCat by Cat

prefix.varname1@prefix.varname2Con by Catvarname1@prefix.varname2

Use of if and inIt is

notrecommended that you useiforinas part of your command. Instead, usekeepordropprior to usingxi3.

Additional Coding SchemesThe

xi3command allows additional prefixes beyondi.varname. These prefixes create a number of additional coding schemes, as described below.Please note: Starting with version 1.0 (April 7, 2003) the prefixes s, d, and f have been replaced with g, e, and a (respectively). This now permits the s., d. and f. prefixes to be used as time series operators reflecting seasonal differences, backward differencing, and forward differencing (respectively).

i.varname - Indicator (dummy) coding: compares each level to the omitted groupc.varname - Centered indicator (dummy) codingg.varname - reference Group coding: compares each level to a reference groupe.varname - Effect coding: deviations from the grand meanh.varname - Helmert coding: compares levels of a variable with the mean of subsequent levelsr.varname - Reverse Helmert coding: compares levels of a variable with the mean of previous levelsa.varname - Adjacent differences: each level vs. the next levelb.varname - Backward adjacent differences: each level vs. the previous levelo.varname - Orthogonal polynomial contrasts u.varname - User defined coding schemeu.varname - User defined coding scheme

Omitted Categories for Additional Coding SchemesThe

refgroupcommand is included withxi3to allow you to select the reference group (also called the omitted category). This is simply a shorthand for usingcharvarname[omit]#. The syntax ofrefgroupis

refgroupvarname#The following describes how omitted categories are handled using each coding scheme.

Indicator coding. The choice of the omitted category works just like the originalxiprogram, i.e. the first category is omitted unless you usecharvarname[omit]#orchar _dta[omit] "prevalent"(see help xi for more information). Note thatchar _dta[omit] "prevalent"is ignored for all of the other other coding schemes.

Simple and Deviation coding. By default, the first category is the omitted category and you can usecharvarname[omit]#to choose a different level to be omitted.

Helmert and Forward Difference coding. For these coding schemes the last category is always omitted (because the last category cannot be compared to subsequent categories.

Reverse Helmert and Backward Difference coding. For these coding schemes the first category is always omitted (because the first category cannot be compared to prior categories.

Orthogonal Polynomial coding. The kth level is omitted.

User Defined coding. The user definesk-1contrasts to be tested, as described in the section Creating User Defined Coding below.

Creating User Defined CodingIt may be easiest to describe user defined coding via an example. Say you have a variable

seswith 3 levels, and you wish to form 2 comparisons. The first will compare level 1 with levels 2 and 3, and the second will compare levels 1 and 3. The comparison coefficients for these two comparisons would be.comparison 1:

1 -.5 -.5comparison 2:1 0 -1You indicate these comparisions like this

. char ses[user] (1 -.5 -.5 1 0 -1)

Simple Comparisons and Simple EffectsSay you wanted to specify

adjacent differencecontrasts onvarname1at each level ofvarname2, along withgroupcontrasts onvarname2. You can use@like this to request that coding.

a.varname1@g.varname2For example to perform

adjacent differenceconrasts onsesat each level offemaleandgroupcoding on female, you could type

. xi3 a.ses@s.femaleThe terms that would be created are listed below along with their interpretation.

_Ises_1ses(1 vs. 2)_Ises_2ses(2 vs. 3)_Ifemale_1female(1 vs. 0)_Ise1Wfe0ses(1 vs. 2) female==0_Ise1Wfe1ses(1 vs. 2) female==1_Ise2Wfe0ses(2 vs. 3) female==0_Ise2Wfe1ses(2 vs. 3) female==1As you see, the lower order effects

_Ises_1 _Ises_1and_Ifemale_1are created as though you had used an interaction. But the terms_Ise1Wfe0 _Ise1Wfe1_Ise2Wfe0and_Ise2Wfe1reflect simple effects ofsesat the levels offemale. For example_Ise1Wfe0is the effect of low ses vs. middle ses for males, and_Ise2Wfe0is the effect of middle ses vs. high ses for males.If you wanted to form the simple effect of

sesfor males, you would use thetestcommand to test_Ise1Wfe0and_Ise2Wfe0, for example

. test _Ise1Wfe0 _Ise2Wfe0Note that when you use

xi3to create the coding scheme, it creates both the main effects forfemaleand forsesand for the simple contrasts ofsesat each level offemale. However, if you include all of these terms in an estimation model, it will be overparameterized. Instead, you wish to drop, in this example, the main effect ofsessince that effect is also contrained in the simple effects. When you usexi3with a command, it automatically drops thesesmain effects, although those variables are created, see example below.

. xi3 : regress write a.ses@g.female

a.ses _Ises_1-3 (naturally coded; _Ises_3 omitted) g.female _Ifemale_0-1 (naturally coded; _Ifemale_0 omitted)

Source | SS df MS Number of obs = 200 -------------+------------------------------ F( 5, 194) = 5.67 Model | 2278.24419 5 455.648837 Prob > F = 0.0001 Residual | 15600.6308 194 80.4156228 R-squared = 0.1274 -------------+------------------------------ Adj R-squared = 0.1049 Total | 17878.875 199 89.843593 Root MSE = 8.9675

------------------------------------------------------------------------------ write | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _Ifemale_1 | 5.566752 1.366513 4.07 0.000 2.871622 8.261882 _Ise1Wfe0 | -2.953191 2.659326 -1.11 0.268 -8.198093 2.29171 _Ise1Wfe1 | -1.75 2.046537 -0.86 0.394 -5.786318 2.286318 _Ise2Wfe0 | -3.308877 2.117528 -1.56 0.120 -7.485208 .8674534 _Ise2Wfe1 | -4.715517 2.109094 -2.24 0.027 -8.875215 -.5558195 _cons | 52.45513 .6832567 76.77 0.000 51.10756 53.80269 ------------------------------------------------------------------------------

Having done this test, we can test the simple effects of

sesfor males like this.

. test _Ise1Wfe0 _Ise2Wfe0( 1) _Ise1Wfe0 = 0 ( 2) _Ise2Wfe0 = 0

F( 2, 194) = 2.61Prob > F = 0.0765

and the simple effects of

sesfor females like this.

. test _Ise1Wfe1 _Ise2Wfe1( 1) _Ise1Wfe1 = 0.0 ( 2) _Ise2Wfe1 = 0.0

F( 2, 194) = 4.25Prob > F = 0.0157

Also seeManual:

[U] 23 Estimation and post-estimation commands,[R] xiOn-line: help for est, postestAuthor ------ Michael Mitchell & Phil Ender Academic Technology Services UCLA mnmatucla.edu enderatucla.edu