ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:112.58KB ,
资源ID:1411392      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/1411392.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(eviews中的蒙特卡洛模拟程序.docx)为本站会员(b****4)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

eviews中的蒙特卡洛模拟程序.docx

1、eviews中的蒙特卡洛模拟程序模拟程序案例例 1,在做抛掷一枚质地均匀的硬币的试验中发“正面朝上”的事件(用 1 表示)和“正面朝下”的事件 A(用 0 表示)的情况。历史上一些学者得到的具体试验结果如下:现在需要利用 eviews 来模拟上述三位学者的实验。算法分析:上述三学者的实验均为二项分布的实验,可以直接利用 eviews 产生二项分布随机数的函数rbinom(n,p).编程如下:work u 1 2048series resultfor !i=0 to 1smpl 1 2048series xx(1)=0for !cou=1 to 2048x(!cou)=rbinom(!i,0.5

2、)nextnextx.hist例 2(投掷骰子)(1)投掷一颗质地均匀的骰子,令 X 表示其出现的点数,分析各点数出现的频率的稳定性及变化规律;(2)利用统计的方法,根据“频率的稳定性”规律求投掷一枚质地不均匀的骰子出现某点数的概率;(3)演示随机变量 X 的数学期望的统计意义。算法分析:根据逆变换法产生来自分布函数F(x)的随机数,就要求出 F-1(y),其中 F-1(y)infx:F(x)y.0y1.质地均匀的骰子各点数出现的频率的分布函数是F(x)=p(xx)=(i=1)/6,i-1xi,i=1,2,7可求得F-1(y)=infx:F(x)y.0y1=i-1,(i-1)/6yi/6,i=

3、1,6因而,可先由产生均匀分布随机数的函数 runif(0,1)抽取 y 值,再来计算 F-1(y)值即可。程序实现:work u 1 1000smpl 1 1000series x series yseries a1series a2series a3series a4series a5series a6for !i=1 to 1000a1(!i)=1/6a2(!i)=2/6a3(!i)=3/6a4(!i)=4/6a5(!i)=5/6a6(!i)=1x(!i)=runif(0,1)if x(!i)=a1(!i) and x(!i)=a2(!i) and x(!i)=a3(!i) and x(

4、!i)=a4(!i) and x(!i)=a5(!i) and x(!i)a6(!i) then y(!i)=6else y(!i)=7endifendifendifendifendifendifnexty.hist1.通过已知总体模型得到多组样本数据,进行多次回归,验证回归结果的特征、性质最小二乘法的无偏性work u 1 10vector(10) v1v1.fill 80, 100,120,140,160,180,200,220,240,260mtos(v1,x)!b1=25!b2=0.5matrix(100,2) ffor !k=1 to 100series u=3*nrndseries

5、 y=!b1+!b2*x+uequation eq.ls y=c(1)+c(2)* xf(!k,1)=c(1)f(!k,2)=c(2)nextshow fexpand 1 100smpl 1 100mtos(f,gr)freeze ser01.qqplotfreeze ser01.histfreeze ser02.qqplotfreeze ser02.histmatrix(1,2) mm(1,1)=mean(ser01)m(1,2)=mean(ser02)show m蒙特卡洛模拟程序:(最终调试成功)store monte carle results in a serieschecked 4/

6、1/2004set work to number of monte carle replicationswfcreate mcarle u 1 100create data series for xnote: x is fixed in repeated samplesonly first 10 observations are used (remaining 90 obs missing)series x x.fill 80,100,120,140,160,180,200,220,240,260set true parameter values!beta1=2.5!beta2=0.5set

7、seed for random number generatorrndseed 123456assign number of replications to a control variable!reps=100begin loopfor !I=1 to !reps set sample to estimation sample smpl 1 10 simulate y data (only for 10 obs) series y=!beta1+!beta2*x+3*nrnd regress y on a constant and x Equation eq1.ls y c xset sam

8、ple to one observationsmpl !I !iand store each coefficient estimate in a series series b1=eq1.coefs(1)series b2=eq1.coefs(2)nextend of loopset sample to full samplesmpl 1 100show kernel density eatimate for each coeffreeze(gra1) b1.distplot kerneldrow vertical dashline at true parameter valuegra1.dr

9、aw(dashline,bottom,rgb(156,156,156) !beta1show gra1freeze(gra2) b2.distplot kerneldraw vertical dashline at true parameter valuegra2.draw(dashline,bottom,rgb(156,156,156) !beta2show gra2一元回归参数的分布:Subroutine moni (scalar n, scalar sum, scalar param1, scalar param2, scalar type)For !m=1 to nX(!m)=rnd*

10、100NextFor !n=1 to sumIf type=0 thenFor !m=1 to nU(!m)=nrndNextEndifIf type=1 thenFor !m=1 to nIf rnd0.5 thenU(!m)=rndElseU(!m)=rnd*(-1)EndifNextEndifIf type=2 thenU(1)=nrndFor !m=2 to nU(!m)=u(!m-1)+nrndNextEndifIf type=3 thenFor !m=1 to nIf rnd=2freeze(statby_%1) %1.statby(nomean,nostd)cao_%1nextfor %1 r0 b0 t0 dw0 r20 f0 r1 b1 t1 dw1 r21 f1 r2 b2 t2 dw2 r22 f2freeze(hist_%1) %1.h

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1