|
用什么命令就看那个命令的帮助和解释。
Title
[R] xi -- Interaction expansion
Syntax
xi [, prefix(string) noomit] term(s)
xi [, prefix(string) noomit] : any_stata_command varlist_with_terms ...
where a term has the form
i.varname or I.varname
i.varname1*i.varname2 I.varname1*I.varname2
i.varname1*varname3 I.varname1*varname3
i.varname1|varname3 I.varname1|varname3
varname, varname1, and varname2 denote numeric or string categorical variables. varname3
denotes a continuous, numeric variable.
Menu
Data > Create or change data > Other variable-creation commands > Interaction expansion
+-----------------------------------------------------------------+
| Most commands in Stata now allow factor variables; see |
| fvvarlist. To determine if a command allows factor variables, |
| see the information printed below the options table for the |
| command. If the command allows factor variables, it will say |
| something like "indepvars may contain factor variables." |
| |
| We recommend that you use factor variables instead of xi if a |
| command allows factor variables. |
| |
| We include [R] xi in our documentation so that readers can |
| consult it when using a Stata command that does not allow |
| factor variables. |
+-----------------------------------------------------------------+
Description
xi expands terms containing categorical variables into indicator (also called dummy)
variable sets by creating new variables and, in the second syntax (xi: any_stata_command),
executes the specified command with the expanded terms. The dummy variables created are
i.varname creates dummies for categorical variable varname
i.varname1*i.varname2 creates dummies for categorical variables varname1 and varname2:
all interactions and main effects
i.varname1*varname3 creates dummies for categorical variable varname1 and continuous
variable varname3: all interactions and main effects
i.varname1|varname3 creates dummies for categorical variable varname1 and continuous
variable varname3: all interactions and main effect of varname3,
but no main effect of varname1
Options
prefix(string) allows you to choose a prefix other than _I for the newly created interaction variables. The prefix cannot be longer than four characters. By default, xi will create interaction variables starting with _I. When you use xi, it drops all previously created interaction variables starting with the prefix specified in the prefix(string) option or with _I by default. Therefore, if you want to keep the variables with a certain prefix, specify a different prefix in the prefix(string) option.
noomit prevents xi from omitting groups. This option provides a way to generate an
indicator variable for every category having one or more variables, which is useful when
combined with the noconstant option of an estimation command.
|