楼主: spoonshen
5456 7

[求助] Monte Carlo Simulation of Regression Models in stata [推广有奖]

已卖:19份资源

学科带头人

40%

还不是VIP/贵宾

-

威望
1
论坛币
115 个
通用积分
134.5282
学术水平
272 点
热心指数
499 点
信用等级
387 点
经验
1168 点
帖子
775
精华
0
在线时间
2933 小时
注册时间
2007-5-30
最后登录
2025-5-28

楼主
spoonshen 发表于 2007-7-30 23:02:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
那位大侠有STATA里面怎么做回归模型的MONTE CARLO SIMULATION 的资料? 多谢了
二维码

扫码加我 拉你入群

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

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

关键词:Monte Carlo regression Simulation regressio ulation Monte Carlo models Simulation regression

沙发
xge2000 发表于 2011-7-22 07:33:48
gtoooooooooood

藤椅
dxystata 发表于 2011-7-22 10:01:35
In the first example, the two independent variables are from an existing dataset and the dependent variable is generated based on the two independent variables plus some random error. The dependent variable is then regressed on the two independent variables.

* Set up the steps you want to repeat for the simulation in a program
program define myprog1
        * drop all variables to create an empty dataset, do not use clear
        drop _all
        * get dataset
        use http://www.ats.ucla.edu/stat/stata/faq/hsb2
        * keep the independent variables (IVs)
        keep write math
        * gen dependent variable (DV) with set relationship to IVs + random error
        gen y = 7.541 + .3283*math + .5196*write + 7.281 * invnormal(uniform())
        * run the desired command
        reg y write math
end

* use the simulate command to rerun myprog1 1000 times
* collect the betas (_b) and standard errors (_se) from the regression each time
* You'll probably want to set reps(10) for testing, then set it higher for the simulation.
simulate _b _se, reps(1000): myprog1
The second example is similar to the first, except that the data are random draws from a normal distribution with a given correlational structure using the command drawnorm. Covariances can also be used by specifying the cov() option instead of corr(). If no correlation or covariance structure is specified, the variables generated will be orthogonal. The code below also specifies means and standard deviations for the variables, but this is not strictly necessary.

* Set up the steps you want to repeat for the simulation in a program
program define myprog2
        * drop all variables to create an empty dataset, do not use clear
        drop _all
        * create a vector that contains the equivalent of a lower triangular correlation matrix
        matrix c = (1, 0.5968, 1, 0.6623, 0.6174, 1)
        * create a vector that contains the means of the variables
        matrix m = (52.23,52.775,52.645)
        * create a vector that contains the standard deviations
        matrix sd = (10.25,9.47,9.36)
        * draw a sample of 1000 cases from a normal distribution with specified correlation structure
        * and specified means and standard deviations
        drawnorm x1 x2 y, n(1000) corr(c) cstorage(lower) means(m) sds(sd)
        * run the desired command
        reg y x1 x2
end
* use the simulate command to rerun myprog2 1000 times
* collect the betas (_b) and standard errors (_se) from the regression each time
* You'll probably want to set reps(10) for testing, then set it higher for the simulation.
simulate _b _se, reps(1000): myprog2
已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
crystal8832 + 10 + 1 热心帮助其他会员
Sunknownay + 100 + 8 + 1 + 1 + 1 热心帮助其他会员

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

板凳
spoonshen 发表于 2011-7-24 02:14:46
3# dxystata

多谢多谢。要好好学习。

报纸
isobear 发表于 2012-11-26 01:18:41
请问这可以用在 penal data 上吗?

地板
zhongzihong 发表于 2013-1-24 17:17:06
同问
曾经错过

7
afra3001 发表于 2013-1-30 11:13:49
thanks

8
zwa222 发表于 2013-3-7 15:29:00
记录,学习!

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-15 17:51