楼主: hshly
2275 8

[其他] 求助成功,谢谢 [推广有奖]

  • 1关注
  • 25粉丝

高级会员

已卖:11份资源

学术权威

2%

还不是VIP/贵宾

-

威望
0
论坛币
1764290 个
通用积分
493.3863
学术水平
13 点
热心指数
17 点
信用等级
8 点
经验
37289 点
帖子
877
精华
0
在线时间
8662 小时
注册时间
2004-12-13
最后登录
2025-12-23

楼主
hshly 发表于 2012-3-4 21:46:22 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
var1 var2 var3 var4
1       1        .       4
2      .         2        5

列求均值(或和)比较好求,现在我想行求均值(或和),但是注意考虑缺失值,即第一行的值为(1+1+4)/3等
即最后生成一列var5,它是前面按照上述要求的均值。
请问如何编程,谢谢了
二维码

扫码加我 拉你入群

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

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

关键词:求助成功 VaR 缺失值 如何

沙发
蓝色 发表于 2012-3-4 22:09:19
egen kk=rmean(var1 var2 var3 var4)
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
h3327156 + 1 + 1 + 1 哈 有这function喔 呵 学习了
hshly + 1 + 1 + 1 谢谢

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

藤椅
hshly 发表于 2012-3-5 06:55:36
蓝色 发表于 2012-3-4 22:09
egen kk=rmean(var1 var2 var3 var4)
谢谢蓝色,就是这个,前面这个r真好

板凳
h3327156 发表于 2012-3-5 11:41:58
hshly 发表于 2012-3-5 06:55
谢谢蓝色,就是这个,前面这个r真好
呵呵呵诃呵…  那个r真好…   那个r应该是row的意思…  很好… 很强大!!!!!

报纸
蓝色 发表于 2012-3-5 12:52:17
h3327156 发表于 2012-3-5 11:41
呵呵呵诃呵…  那个r真好…   那个r应该是row的意思…  很好… 很强大!!!!!
是的
原来是写r
现在写全了row,不过原来的命令还是可以用的。

关键是egen的命令比较强大

地板
蓝色 发表于 2012-3-5 12:52:48
rowfirst(varlist)
            may not be combined with by.  It gives the first nonmissing value in varlist for each
            observation (row).  If all values in varlist are missing for an observation, newvar
            is set to missing.

        rowlast(varlist)
            may not be combined with by.  It gives the last nonmissing value in varlist for each
            observation (row).  If all values in varlist are missing for an observation, newvar
            is set to missing.

        rowmax(varlist)
            may not be combined with by.  It gives the maximum value (ignoring missing values) in
            varlist for each observation (row).  If all values in varlist are missing for an
            observation, newvar is set to missing.

        rowmean(varlist)
            may not be combined with by.  It creates the (row) means of the variables in varlist,
            ignoring missing values; for example, if three variables are specified and, in some
            observations, one of the variables is missing, in those observations newvar will
            contain the mean of the two variables that do exist.  Other observations will contain
            the mean of all three variables.  Where none of the variables exist, newvar is set to
            missing.

        rowmedian(varlist)
            may not be combined with by.  It gives the (row) median of the variables in varlist,
            ignoring missing values.  If all variables in varlist are missing for an observation,
            newvar is set to missing in that observation.  Also see rowpctile().

        rowmin(varlist)
            may not be combined with by.  It gives the minimum value in varlist for each
            observation (row).  If all values in varlist are missing for an observation, newvar
            is set to missing.

        rowmiss(varlist)
            may not be combined with by.  It gives the number of missing values in varlist for
            each observation (row).

        rownonmiss(varlist) [, strok]
            may not be combined with by.  It gives the number of nonmissing values in varlist for
            each observation (row) -- this is the value used by rowmean() for the denominator in
            the mean calculation.

            String variables may not be specified unless the strok option is also specified.  If
            strok is specified, string variables will be counted as containing missing values
            when they contain "".  Numeric variables will be counted as containing missing when
            their value is ">.".

        rowpctile(varlist) [, p(#)]
            may not be combined with by.  It gives the #th percentile of the variables in
            varlist, ignoring missing values.  If all variables in varlist are missing for an
            observation, newvar is set to missing in that observation.  If p() is not specified,
            p(50) is assumed, meaning medians.  Also see rowmedian().

        rowsd(varlist)
            may not be combined with by.  It creates the (row) standard deviations of the
            variables in varlist, ignoring missing values.

        rowtotal(varlist) [, missing]
            may not be combined with by.  It creates the (row) sum of the variables in varlist,
            treating missing as 0.  If missing is specified and all values in varlist are missing
            for an observation, newvar is set to missing.
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 100 + 8 + 1 + 1 + 1 热心帮助其他会员

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

7
fudanly 发表于 2012-3-5 13:38:02
蓝色 发表于 2012-3-4 22:09
egen kk=rmean(var1 var2 var3 var4)
您好,请问如果要求移动平均,该怎么设置呢?比如,一个时间序列数据,我要计算每个前八期的median。

8
h3327156 发表于 2012-3-5 14:31:06
fudanly 发表于 2012-3-5 13:38
您好,请问如果要求移动平均,该怎么设置呢?比如,一个时间序列数据,我要计算每个前八期的median。
如果您不想编程,
我个人觉得
help tssmooth
参考一下,特别是那个 tssmooth nl
已有 1 人评分学术水平 热心指数 收起 理由
fudanly + 1 + 1 热心帮助其他会员

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

9
h3327156 发表于 2012-3-5 14:31:52
蓝色 发表于 2012-3-5 12:52
是的
原来是写r
现在写全了row,不过原来的命令还是可以用的。
嗯嗯 感谢蓝色版主的教导阿!!!!!!!!!!!!!!!!

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

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