楼主: sdu薄荷红茶
43484 10

[面板数据求助] 在stata中怎么做面板数据的交叉项? [推广有奖]

  • 1关注
  • 0粉丝

高中生

87%

还不是VIP/贵宾

-

威望
0
论坛币
313 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1793 点
帖子
16
精华
0
在线时间
49 小时
注册时间
2011-12-24
最后登录
2014-6-13

楼主
sdu薄荷红茶 发表于 2013-7-18 14:49:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
最近在写论文,第一次接触面板数据,压力很大。
我在做检验的时候,需要设置两个变量的交叉项进行调节效应。想问一下,调节效应的另一个变量可以不是虚拟变量吗?还是必须是虚拟变量?可不可以是分类变量(1,2,3,4,5这样分类)?
此外,在stata中怎么做两个变量相乘啊~~谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Stata 面板数据 tata 交叉项 怎么做 论文

沙发
sunkai_bick 在职认证  学生认证  发表于 2013-7-18 21:27:32
https://bbs.pinggu.org/thread-1412312-1-1.html
https://bbs.pinggu.org/thread-2467410-1-1.html

伍德里奇 《计量经济学导论》关于交互项的内容好好阅读以下,应该就比较清楚啦。
(ps : 记得 @蓝色 版主在某一个帖子里把教材的相关页全贴出来了,楼主可以搜一下。。当然,最好直接看书)
good luck!

藤椅
lclray3 发表于 2013-7-18 21:49:45
不是可以直接利用gen命令生成么?

板凳
sdu薄荷红茶 发表于 2013-7-19 00:11:09
lclray3 发表于 2013-7-18 21:49
不是可以直接利用gen命令生成么?
我试了一下,stata是不是不支持*命令啊?
还有交叉项必须是虚拟变量吗?可不可以做类似1,2,3的分类变量啊?谢谢

报纸
sdu薄荷红茶 发表于 2013-7-19 00:11:47
sunkai_bick 发表于 2013-7-18 21:27
https://bbs.pinggu.org/thread-1412312-1-1.html
https://bbs.pinggu.org/thread-2467410-1-1.html
谢谢谢谢~~

地板
蓝色 发表于 2013-7-19 01:56:01
查看 factor variable的介绍

Title

    [U] 11.4.3 Factor variables


Description

    Factor variables are extensions of varlists of existing variables.  When a command allows factor variables,
    in 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

    Factor variables create indicator variables from categorical variables, interactions of indicators of
    categorical variables, interactions of categorical and continuous variables, and interactions of continuous
    variables (polynomials).  They are allowed with most estimation and postestimation commands, along with a
    few other commands.

    There are four factor-variable operators:

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

    The indicators and interactions created by factor-variable operators are referred to as virtual variables.
    They act like variables in varlists but do not exist in the dataset.

    Categorical variables to which factor-variable operators are applied must contain nonnegative integers with
    values in the range 0 to 32,740, inclusive.

    Factor variables may be combined with the L. and F. time-series operators.


Remarks

    Remarks are presented under the following headings:

        Basic examples
        Base levels
        Selecting levels
        Applying operators to a group of variables


Basic examples

    Here are some examples of use of the operators:

         Factor            
         specification     Result
         ------------------------------------------------------------------------------------------------------
         i.group           indicators for levels of group

         i.group#i.sex     indicators for each combination of levels of group and sex, a two-way interaction

         group#sex         same as i.group#i.sex

         group#sex#arm     indicators for each combination of levels of group, sex, and arm, a three-way
                             interaction

         group##sex        same as i.group i.sex group#sex

         group##sex##arm   same as i.group 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 type ib2.group or b2.group.
           (**) 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.sex ib3.group

    You can also permanently set the base levels of categorical variables by using the fvset command.


Selecting levels

    You can select a range of levels -- a range of virtual variables -- by using the i(numlist). operator.

         Examples          Description
         ------------------------------------------------------------------------------------------------------
         i2.cat            a single indicator for cat==2

         2.cat             same as i2.cat

         i(2 3 4).cat      three indicators, cat==2, cat==3, and cat==4;
                             same as i2.cat i3.cat i4.cat

         i(2/4).cat        same as i(2 3 4).cat

         2.cat#1.sex       a single indicator that is 1 when cat==2 and sex==1, and is 0 otherwise

         i2.cat#i1.sex     same as 2.cat#1.sex
         ------------------------------------------------------------------------------------------------------


Applying operators to a group of variables

    Factor-variable operators may be applied to groups of variables by using parentheses.

    In the examples that follow, variables group, sex, arm, and cat are categorical, and variables age, wt, and
    bp are continuous:

         Examples                  Expansion
         ------------------------------------------------------------------------------------------------------
         i.(group sex arm)         i.group i.sex i.arm

         group#(sex arm cat)       group#sex group#arm group#cat

         group##(sex arm cat)      i.group i.sex i.arm i.cat group#sex group#arm group#cat

         group#(c.age c.wt c.bp)   i.group group#c.age group#c.wt group#c.bp

         group#c.(age wt bp)       same as group#(c.age c.wt c.bp)
         ------------------------------------------------------------------------------------------------------
已有 3 人评分经验 学术水平 热心指数 信用等级 收起 理由
siyemelanie + 5 + 5 + 5 精彩帖子
seanj_cn + 1 + 1 + 1 精彩帖子
remlus + 100 + 5 + 5 + 5 热心帮助其他会员

总评分: 经验 + 100  学术水平 + 11  热心指数 + 11  信用等级 + 11   查看全部评分

7
sdu薄荷红茶 发表于 2013-7-19 20:02:25
蓝色 发表于 2013-7-19 01:56
查看 factor variable的介绍

Title
谢谢谢谢,受教了~~

8
ge1986505 发表于 2014-10-28 10:56:50
这个太有用了,谢谢!

把连老师教的方法也粘过来了,方便大家查找。
如下:
“产生交乘项:
gen xy = x*y
按此方法,可以模型中涉及的所有交乘项。
然后把交乘项放入模型进行估计即可。”
本文来自: 人大经济论坛 统计软件培训班VIP答疑区 版,详细出处参考: https://bbs.pinggu.org/forum.php?mod=viewthread&tid=2467410&page=1&from^^uid=2145031
已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
yybys + 1 + 1 + 1 + 1 热心帮助其他会员
诗清韵 + 1 + 1 热心帮助其他会员

总评分: 论坛币 + 1  学术水平 + 2  热心指数 + 2  信用等级 + 1   查看全部评分

9
ge1986505 发表于 2014-10-28 10:58:20
这个太有用了,谢谢!

把连老师教的方法也粘过来了,方便大家查找啊。
如下:
“产生交乘项:
gen xy = x*y
按此方法,可以模型中涉及的所有交乘项。
然后把交乘项放入模型进行估计即可。”
本文来自: 人大经济论坛 统计软件培训班VIP答疑区 版,详细出处参考: https://bbs.pinggu.org/forum.php?mod=viewthread&tid=2467410&page=1&from^^uid=2145031

10
余文涛 发表于 2015-9-5 16:00:59
支持一下!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-25 18:05