如何在stata输入面板数据,并区分因变量与自变量

苹果/安卓/wp
积分 81, 距离下一级还需 4 积分
道具: 彩虹炫, 涂鸦板, 雷达卡, 热点灯, 金钱卡, 显身卡下一级可获得
权限: 自定义头衔
购买后可立即获得
权限: 隐身
道具: 金钱卡, 彩虹炫, 雷达卡, 热点灯, 涂鸦板
悲催签到天数: 78 天连续签到: 1 天[LV.6]常住居民II
最近在写论文,第一次接触面板数据,压力很大。
我在做检验的时候,需要设置两个变量的交叉项进行调节效应。想问一下,调节效应的另一个变量可以不是虚拟变量吗?还是必须是虚拟变量?可不可以是分类变量(1,2,3,4,5这样分类)?
此外,在stata中怎么做两个变量相乘啊~~谢谢
载入中......
伍德里奇 《计量经济学导论》关于交互项的内容好好阅读以下,应该就比较清楚啦。
(ps : 记得 @蓝色 版主在某一个帖子里把教材的相关页全贴出来了,楼主可以搜一下。。当然,最好直接看书)
good luck!
不是可以直接利用gen命令生成么?
lclray3 发表于
不是可以直接利用gen命令生成么?我试了一下,stata是不是不支持*命令啊?
还有交叉项必须是虚拟变量吗?可不可以做类似1,2,3的分类变量啊?谢谢
sunkai_bick 发表于
http://bbs.pinggu.org/thread--1.html
http://bbs.pinggu.org/thread--1.html谢谢谢谢~~
查看 factor variable的介绍
& & [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 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
& && && && && && && && && &&&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)
& && && &------------------------------------------------------------------------------------------------------
热心帮助其他会员
总评分:&经验 + 100&
学术水平 + 6&
热心指数 + 6&
信用等级 + 6&
Stata版版规
蓝色 发表于
查看 factor variable的介绍
Title谢谢谢谢,受教了~~
这个太有用了,谢谢!
把连老师教的方法也粘过来了,方便大家查找。
“产生交乘项:
gen xy = x*y
按此方法,可以模型中涉及的所有交乘项。
然后把交乘项放入模型进行估计即可。”
本文来自: 人大经济论坛 统计软件培训班VIP答疑区 版,详细出处参考: http://bbs.pinggu.org/forum.php?mod=viewthread&tid=2467410&page=1&from^^uid=2145031
热心帮助其他会员
总评分:&学术水平 + 1&
热心指数 + 1&
这个太有用了,谢谢!
把连老师教的方法也粘过来了,方便大家查找啊。
“产生交乘项:
gen xy = x*y
按此方法,可以模型中涉及的所有交乘项。
然后把交乘项放入模型进行估计即可。”
本文来自: 人大经济论坛 统计软件培训班VIP答疑区 版,详细出处参考: http://bbs.pinggu.org/forum.php?mod=viewthread&tid=2467410&page=1&from^^uid=2145031
支持一下!
初级热心勋章
初级热心勋章
初级信用勋章
初级信用勋章
初级学术勋章
初级学术勋章
中级学术勋章
中级学术勋章
中级热心勋章
中级热心勋章
中级信用勋章
中级信用勋章
高级热心勋章
高级热心勋章
高级信用勋章
高级信用勋章
无限扩大经管职场人脉圈!每天抽选10位免费名额,现在就扫& 论坛VIP& 贵宾会员& 可免费加入
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
如有投资本站或合作意向,请联系(010-);
邮箱:service@pinggu.org
投诉或不良信息处理:(010-)
京ICP证090565号
论坛法律顾问:王进律师5分钟搞定Stata面板数据分析小教程_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
5分钟搞定Stata面板数据分析小教程
上传于|0|0|文档简介
&&简单易学,适合想用面板数据但不太会操作STATA的初学者使用
阅读已结束,如果下载本文需要使用2下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩8页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢苹果/安卓/wp
积分 57, 距离下一级还需 28 积分
道具: 彩虹炫, 涂鸦板, 雷达卡, 热点灯, 金钱卡, 显身卡下一级可获得
权限: 自定义头衔
购买后可立即获得
权限: 隐身
道具: 金钱卡, 彩虹炫, 雷达卡, 热点灯, 涂鸦板
开心签到天数: 100 天连续签到: 1 天[LV.6]常住居民II
请教各位大神,根据我的理解,该模型因变量是一个面板数据,自变量则是截面数据,那在stata回归分析中,该截面数据该怎么设定呢
支持楼主:、
购买后,论坛将把您花费的资金全部奖励给楼主,以表示您对TA发好贴的支持
载入中......
(86.33 KB)
18:26:42 上传
学习一下& && && && && && && && && && && && && && &&&& && && && && && && && & & &
& && && && && && && && && && && && && &
& && && && && && && && && &&&& && && && && && && && &
& && && && && && && && && && && && && && && && && &&&
& && && &&&& && && && && &&&& && &&&& && && &
& && && && && && && & & && && && && && && && && && & & && && && &
& && && && && && && && && && && && && && && && && && && && && && && && && && && &
论坛扫地人员
下一片蓝天 发表于
学习一下& && && && && && && && && && && && && && && && && && && && && && && && &
& && && && && && &...应该是写错了,是不同地区或者i地区在在第零期的数据,不然不可能做的出来。同样是M ,按照他写的,前后就不一致了,应该是笔误。
分析的有道理
总评分:&经验 + 100&
学术水平 + 1&
热心指数 + 1&
crystal8832 发表于
应该是写错了,是不同地区或者i地区在在第零期的数据,不然不可能做的出来。同样是M ,按照他写的,前后就 ...你好,那能否这样理解,因变量是从0期到t期的截面数据,自变量是0期的截面数据?
二级伯乐勋章
二级伯乐勋章
一级伯乐勋章
一级伯乐勋章
初级热心勋章
初级热心勋章
初级学术勋章
初级学术勋章
中级热心勋章
中级热心勋章
初级信用勋章
初级信用勋章
中级学术勋章
中级学术勋章
中级信用勋章
中级信用勋章
高级热心勋章
高级热心勋章
高级学术勋章
高级学术勋章
高级信用勋章
高级信用勋章
特级热心勋章
高级热心勋章
特级学术勋章
特级学术勋章
无限扩大经管职场人脉圈!每天抽选10位免费名额,现在就扫& 论坛VIP& 贵宾会员& 可免费加入
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
&nbsp&nbsp|
如有投资本站或合作意向,请联系(010-);
邮箱:service@pinggu.org
投诉或不良信息处理:(010-)
京ICP证090565号
论坛法律顾问:王进律师您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
STATA面板数据模型操作命令讲述.doc 14页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
需要金币:350 &&
你可能关注的文档:
··········
··········
STATA面板数据模型估计命令一览表一、静态面板数据的STATA处理命令固定效应模型随机效应模型(一)数据处理输入数据●tssetcodeyear该命令是将数据定义为“面板”形式●xtdes该命令是了解面板数据结构●summarizesqcpiunemgse5ln各变量的描述性统计(统计分析)●genlag_y=L.y///////产生一个滞后一期的新变量genF_y=F.y///////产生一个超前项的新变量genD_y=D.y///////产生一个一阶差分的新变量genD2_y=D2.y///////产生一个二阶差分的新变量(二)模型的筛选和检验●1、检验个体效应(混合效应还是固定效应)(原假设:使用OLS混合模型)●xtregsqcpiunemgse5ln,fe对于固定效应模型而言,回归结果中最后一行汇报的F统计量便在于检验所有的个体效应整体上显著。在我们这个例子中发现F统计量的概率为0.0000,检验结果表明固定效应模型优于混合OLS模型。●2、检验时间效应(混合效应还是随机效应)(检验方法:LM统计量)(原假设:使用OLS混合模型)●quixtregsqcpiunemgse5ln,re(加上“qui”之后第一幅图将不会呈现)xttest0可以看出,LM检验得到的P值为0.0000,表明随机效应非常显著。可见,随机效应模型也优于混合OLS模型。●3、检验固定效应模型or随机效应模型(检验方法:Hausman检验)原假设:使用随机效应模型(个体效应与解释变量无关)通过上面分析,可以发现当模型加入了个体效应的时候,将显著优于截距项为常数假设条件下的混合OLS模型。但是无法明确区分FEorRE的优劣,这需要进行接下来的检验,如下:Step1:估计固定效应模型,存储估计结果Step2:估计随机效应模型,存储估计结果Step3:进行Hausman检验●quixtregsqcpiunemgse5ln,feeststorefequixtregsqcpiunemgse5ln,reeststorerehausmanfe(或者更优的是hausmanfe,sigmamore/sigmaless)可以看出,hausman检验的P值为0.0000,拒绝了原假设,认为随机效应模型的基本假设得不到满足。此时,需要采用工具变量法和是使用固定效应模型。(三)静态面板数据模型估计●1、固定效应模型估计●xtregsqcpiunemgse5ln,fe(如下图所示)其中选项fe表明我们采用的是固定效应模型,表头部分的前两行呈现了模型的估计方法、界面变量的名称(id)、以及估计中使用的样本数目和个体的数目。第3行到第5行列示了模型的拟合优度、分为组内、组间和样本总体三个层面,通常情况下,关注的是组内(within),第6行和第7行分别列示了针对模型中所有非常数变量执行联合检验得到的F统计量和相应的P值,可以看出,参数整体上相当显著。需要注意的是,表中最后一行列示了检验固定效应是否显著的F统计量和相应的P值。显然,本例中固定效应非常显著。●2、随机效应模型估计若假设本例的样本是从一个很大的母体中随机抽取的,且与解释变量均不相关则我们可以将视为随机干扰项的一部分此时设定随机效应模型更为合适●3、时间固定效应(以上分析主要针对的是个体效应)如果希望进一步在上述模型中加入时间效应,可以采用时间虚拟变量来实现。首先,我们需要定义一下T-1个时间虚拟变量。●tabyear,gen(dumt)(tab命令用于列示变量year的组类别,选项gen(dumt)用于生产一个以dumt开头的年度虚拟变量)dropdumt1(作用在于去掉第一个虚拟变量以避免完全共线性)若在固定效应模型中加入时间虚拟变量,则估计模型的命令为:●xtregsqcpiunemgse5lndumt*,fe(四)异方差和自相关检验●1、异方差检验(组间异方差)本节主要针对的是固定效应模型进行处理(1)检验原假设:同方差需要检验模型中是否存在组间异方差,需要使用xttest3命令。●quixtregsqcpiunemgse5ln,fexttest3显然,原假设被拒绝。此时,需要进一步以获得参数的GLS估计量,命令为xtgls:●xtglssqcpiunemgse5ln,panels(heteroskedastic)其中组间异方差通过panels往往无法完全反映时序相关性此时便可能存在序列相关在多数情况下被设定为可以发现,这里的P=0.0000,我们可以在1%的显著性水平下爱拒绝不存在序列相关的原假设。考虑到样本,该检验的最后一步是用对进行。检验该值是否显著异于,可见本例中不相等拒绝原假设说明存在序列相关RE模型的序列相关检验对于RE模型,可以采用xttest1命令来执行检验:●quixtregsqcpiunem
正在加载中,请稍后...}

我要回帖

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信