stata如何建立交互项
stata如何建⽴交互项
1. 建⽴新变量
gen z=x*y电子锁原理
2. addition to typing variable names from your data, you can type factor variables, which might look like
i.varname
i.varname#i.varname
i.varname#i.varname#i.varname
i.varname##i.varname
i.varname##i.varname##i.varname
Operator  Description
i. unary operator to specify indicators
c. unary operator to treat as continuous
# binary operator to specify interactions
## binary operator to specify factorial interactions
3. Here are some examples of use of the operators:
Factor
specification    Result
电脑c盘满了怎么办
-------------------------------------------------------------------------------------------------------------
初中英语教学方法
group#sex        same up#i.sex
group#sex#arm    indicators for each combination of levels of group, sex, and arm, a three-way interaction          group##sex        same up i.sex group#sex
group##sex##arm  same up i.sex i.arm group#sex group#arm sex#arm group#sex#arm
sex#c.age        two variables -- age for males and 0 elsewhere, and age for females and 0 elsewhere; if age                              is also in the model, one of the two virtual variables will be treated as a base
sex##c.age        same as i.sex age sex#c.age
c.age            same as age
c.age#c.age      age squared
c.age#c.age#c.age age cubed
-------------------------------------------------------------------------------------------------------------
Base levels
You can specify the base level of a factor variable by using the ib. operator.  The syntax is
Base
operator(*)    Description
-----------------------------------------------------------------------------------------------------------
ib#.          use # as base, #=value of variable
ib(##).        use the #th ordered value as base (**)
ib(first).    use smallest value as base (the default)
员工制度ib(last).      use largest value as base
ib(freq).      use most frequent value as base乒乓球双打
ibn.          no base level
-----------------------------------------------------------------------------------------------------------
有啥好玩的网游
(*) The i may be omitted.  For instance, you may up up.
(**) For example, ib(#2). means to use the second value as the base.
If you want to use group==3 as the base in a regression, you can type,
. regress y  i.up
You can also permanently set the base levels of categorical variables by using the fvset command.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。