由买买提看人间百态

topics

全部话题 - 话题: rnormal
(共0页)
K*****2
发帖数: 9308
1
来自主题: Statistics版 - 菜鸟求助STATA循环
两个错误:x的变量名重复,要区分;rnormal里面的i没加引号
set obs 1
local i = 1
while `i' <= 100 {
gen var_`i' = rnormal(0,`i')
local i = `i' + 1
}
包子就不用了
Z*****e
发帖数: 617
2
来自主题: Statistics版 - 菜鸟求助STATA循环
题目是这样的
Use the loop command to generate 100 variables var_1 to var_100, which are
normally distributed with mean 0 and standard deviations which increase from
1 to 100;
我写的
local i=1
. while 'i'<=100 {
gen x=rnormal(0,i)
local i='i'+1
}
'i' invalid name
r(198);
初学见笑了。
(共0页)