楼主: fuzixi1125
3859 15

[数据管理求助] 用xi 生成的虚拟变量时会出现覆盖问题吗? [推广有奖]

  • 2关注
  • 6粉丝

博士生

14%

还不是VIP/贵宾

-

威望
0
论坛币
4 个
通用积分
2.0381
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
4276 点
帖子
169
精华
0
在线时间
162 小时
注册时间
2015-3-28
最后登录
2019-11-14

楼主
fuzixi1125 发表于 2016-8-27 11:06:51 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
求助大家:请教个问题,已经用xi i.industry 生成了一个行业虚拟变量,想用xi i.city 再生成一个区域虚拟变量,但是一旦运行xi i.city,原来xi i.industry 生成的的那些虚拟变量没有了,请教是怎么回事?应该怎么修改?谢谢~
二维码

扫码加我 拉你入群

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

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

关键词:虚拟变量 Industry USTR City Dust 行业

回帖推荐

黃河泉 发表于4楼  查看完整内容

你不会是先 然后吧?的确,我试了一下,如楼上所说,后面会取代前面!要产生两组虚拟变量,可试试

沙发
guopeng8899@126 学生认证  发表于 2016-8-27 15:34:18 来自手机
fuzixi1125 发表于 2016-8-27 11:06
求助大家:请教个问题,已经用xi i.industry 生成了一个行业虚拟变量,想用xi i.city 再生成一个区域虚拟变 ...
因为生成的变量相同,后生成的数据会覆盖之前的内容

藤椅
fuzixi1125 发表于 2016-8-27 15:42:40
guopeng8899@126 发表于 2016-8-27 15:34
因为生成的变量相同,后生成的数据会覆盖之前的内容
不是很明白,前面生成的是city,另一个是industry,怎么会相同呢?能解释一下吗?本人刚入门不是很懂stata。。。谢谢。。。。

板凳
黃河泉 在职认证  发表于 2016-8-27 15:47:38
你不会是先
  1. xi i.industry
复制代码
然后
  1. xi i.city
复制代码
吧?的确,我试了一下,如楼上所说,后面会取代前面!要产生两组虚拟变量,可试试
  1. tab industry, gen(dindustry)
  2. tab city, gen(dcity)
复制代码

报纸
黃河泉 在职认证  发表于 2016-8-27 15:49:22
但若是要跑回归,请用:
  1. xi: reg y x1 x2 i.industry i.city, robust
复制代码

地板
蓝色 发表于 2016-8-27 18:13:48
用什么命令就看那个命令的帮助和解释。

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.


7
fuzixi1125 发表于 2016-8-27 19:56:38
黃河泉 发表于 2016-8-27 15:47
你不会是先
然后吧?的确,我试了一下,如楼上所说,后面会取代前面!要产生两组虚拟变量,可试试
是的,我确实是像您说的那样,结果就被覆盖了,我试试您的建议哈,谢谢呢^^

8
fuzixi1125 发表于 2016-8-27 19:57:37
黃河泉 发表于 2016-8-27 15:49
但若是要跑回归,请用:
是要跑回归的。。。弱弱的问一下,为什么后面要加一个rebust?稳健性??不懂。。。求教

9
黃河泉 在职认证  发表于 2016-8-28 10:31:49
fuzixi1125 发表于 2016-8-27 19:57
是要跑回归的。。。弱弱的问一下,为什么后面要加一个rebust?稳健性??不懂。。。求教
现在的趋势,在许多的顶尖财经期刊,极大部分的作者都会(至少)报告 robust standard errors  (robust to unknown form of heteroskedasticity),以确保 t 值(与检定结果)是对的!

10
fuzixi1125 发表于 2016-8-28 10:52:58
黃河泉 发表于 2016-8-28 10:31
现在的趋势,在许多的顶尖财经期刊,极大部分的作者都会(至少)报告 robust standard errors  (robust t ...
真的很感谢。。。从您这里学到很多。。。

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

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