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

Interaction expansion, enhancedThe

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. Its 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

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 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 using charvarname[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 use charvarname[omit]#or char _dta[omit] "prevalent" (see help xi for more information). Note that char _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 use charvarname[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 -.5 comparison 2: 1 0 -1

You indicate these comparisions like this

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

Simple Comparisons and Simple EffectsSay you wanted to specify

deviationcontrasts onvarname1at each level ofvarname2, along withsimplecontrasts onvarname2. You can use@like this to request that coding.d.varname1@s.varname2

For example to perform

forward differenceconrasts onsesat each level offemaleandsimplecoding on female, you could type. xi3 f.ses@s.female

The 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)_IsesWfem_1_1ses(1 vs. 2) @ female==0_IsesWfem_2_1ses(2 vs. 3) @ female==0_IsesWfem_1_2ses(1 vs. 2) @ female==1_IsesWfem_2_2ses(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_IsesWfem_1_1_IsesWfem_2_1 _IsesWfem_1_2and_IsesWfem_2_2reflect simple effects ofsesat the levels offemale. For example_IsesWfem_1_1is the effect of low ses vs. middle ses for males, and_IsesWfem_1_2is 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_IsesWfem_1_1and_IsesWfem_1_2, for example. test _IsesWfem_1_1 _IsesWfem_1_2

Note 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 f.ses@s.female

f.ses _Ises_1-3 (naturally coded; _Ises_3 omitted) s.female _Ifemale_0-1 (naturally coded; _Ifemale_0 omitted) f.ses@s.female _IsesWfem_#_# (simple effects of ses at female)

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 _IsesWfe~1_1 | -2.953191 2.659325 -1.11 0.268 -8.198093 2.29171 _IsesWfe~2_1 | -3.308877 2.117528 -1.56 0.120 -7.485208 .8674534 _IsesWfe~1_2 | -1.75 2.046537 -0.86 0.394 -5.786318 2.286318 _IsesWfe~2_2 | -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 _IsesWfem_1_1 _IsesWfem_2_1

( 1) _IsesWfem_1_1 = 0.0 ( 2) _IsesWfem_2_1 = 0.0

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

and the simple effects of

sesfor females like this.. test _IsesWfem_1_2 _IsesWfem_2_2

( 1) _IsesWfem_1_2 = 0.0 ( 2) _IsesWfem_2_2 = 0.0

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

Also seeManual:

[U] 23 Estimation and post-estimation commands,[R] xiOn-line: help for est, postest