全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
50844 15
2013-02-22
各位同学老师好,我 根据VAR1分组,求VAR2的加权平均数,VAR3是权重。
我使用如下命令 bysort VAR1:egen waverage=mean(VAR2)[w=VAR3]
为什么stata反馈错误:weights not allowed
r(101);
关于r(101)的解释:
Keywords:  r(101)
          Search:  (1) Official help files, FAQs, Examples, SJs, and STBs


Search of official help files, FAQs, Examples, SJs, and STBs

[P]     error . . . . . . . . . . . . . . . . . . . . . . . .  Return code 101
        varlist not allowed;
        weights not allowed;
        in range not allowed;
        if not allowed;
        = exp not allowed;
        using not allowed;
        Certain commands do not allow an if exp or other elements of the
        language.  The message specifies which item in the command is not
        allowed.  See the command's syntax diagram.  For example, append
        does not allow a varlist; perhaps, you meant to type merge.

(end of search)
请指教,谢谢!
二维码

扫码加我 拉你入群

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

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

全部回复
2013-2-22 18:13:42
*设VAR3的各分组和均是1
bys VAR1:egen waverage=sum(VAR2*VAR3)
二维码

扫码加我 拉你入群

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

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

2013-2-22 19:16:07
sungmoo 发表于 2013-2-22 18:13
*设VAR3的各分组和均是1
bys VAR1:egen waverage=sum(VAR2*VAR3)
谢谢!
恩 ,这个方法可以的。但需要先处理VAR3,我查过mean函数的解释,是可以添加权重变量的,参考过一本讲义,里面的例子也是用的类似的语法,不知道为什么我这里行不通。
你知道怎么用mean函数来解决这个问题吗?
二维码

扫码加我 拉你入群

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

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

2013-2-23 13:47:00
在那里看到 mean后面可以加权重的?
二维码

扫码加我 拉你入群

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

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

2013-2-23 14:50:03
蓝色 发表于 2013-2-23 13:47
在那里看到 mean后面可以加权重的?
help mean

help mean                                         dialogs:  mean  svy: mean   
                                                 also see:  mean postestimation
-------------------------------------------------------------------------------

Title

    [R] mean -- Estimate means


Syntax

        mean varlist [if] [in] [weight] [, options]
这里不是说可以使用权重的吗?
二维码

扫码加我 拉你入群

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

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

2013-2-23 15:13:58
你仔细看这个mean 这不是求均值
这是进行估计
这也不是函数

函数你查egen的help,然后看帮助
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群