eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx

上传人:b****2 文档编号:5070610 上传时间:2023-05-04 格式:DOCX 页数:17 大小:112.49KB
下载 相关 举报
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第1页
第1页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第2页
第2页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第3页
第3页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第4页
第4页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第5页
第5页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第6页
第6页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第7页
第7页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第8页
第8页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第9页
第9页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第10页
第10页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第11页
第11页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第12页
第12页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第13页
第13页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第14页
第14页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第15页
第15页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第16页
第16页 / 共17页
eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx

《eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx(17页珍藏版)》请在冰点文库上搜索。

eviews中的蒙特卡洛模拟程序Word文档下载推荐.docx

seriesa3

seriesa4

seriesa5

seriesa6

i=1to1000

a1(!

i)=1/6

a2(!

i)=2/6

a3(!

i)=3/6

a4(!

i)=4/6

a5(!

i)=5/6

a6(!

i)=1

i)=@runif(0,1)

ifx(!

i)<

i)theny(!

elseifx(!

i)>

=a1(!

i)andx(!

i)=2

=a2(!

i)=3

=a3(!

i)=4

=a4(!

i)=5

=a5(!

i)=6

elsey(!

i)=7

endif

y.hist

1.通过已知总体模型得到多组样本数据,进行多次回归,验证回归结果的特征、性质

最小二乘法的无偏性

workfilemcu110

vector(10)v1

v1.fill80,100,120,140,160,180,200,220,240,260

mtos(v1,x)

!

b1=25

b2=0.5

matrix(100,2)f

k=1to100

seriesu=3*nrnd

seriesy=!

b1+!

b2*x+u

equationeq.lsy=c

(1)+c

(2)*x

f(!

k,1)=c

(1)

k,2)=c

(2)

showf

expand1100

smpl1100

mtos(f,gr)

freezeser01.qqplot

freezeser01.hist

freezeser02.qqplot

freezeser02.hist

matrix(1,2)m

m(1,1)=@mean(ser01)

m(1,2)=@mean(ser02)

showm

蒙特卡洛模拟程序:

(最终调试成功)

'

storemontecarleresultsinaseries

checked4/1/2004

setworkfilerangetonumberofmontecarlereplications

wfcreatemcarleu1100

createdataseriesforx

note:

xisfixedinrepeatedsamples

onlyfirst10observationsareused(remaining90obsmissing)

x.fill80,100,120,140,160,180,200,220,240,260

settrueparametervalues

beta1=2.5

beta2=0.5

setseedforrandomnumbergenerator

rndseed123456

assignnumberofreplicationstoacontrolvariable

reps=100

beginloop

I=1to!

reps

'

setsampletoestimationsample

smpl110

simulateydata(onlyfor10obs)

seriesy=!

beta1+!

beta2*x+3*nrnd

regressyonaconstantandx

Equationeq1.lsycx

setsampletooneobservation

smpl!

I!

i

andstoreeachcoefficientestimateinaseries

seriesb1=eq1.@coefs

(1)

seriesb2=eq1.@coefs

(2)

endofloop

setsampletofullsample

showkerneldensityeatimateforeachcoef

freeze(gra1)b1.distplotkernel

drowverticaldashlineattrueparametervalue

gra1.draw(dashline,bottom,rgb(156,156,156))!

beta1

showgra1

freeze(gra2)b2.distplotkernel

drawverticaldashlineattrueparametervalue

gra2.draw(dashline,bottom,rgb(156,156,156))!

beta2

showgra2

一元回归参数的分布:

Subroutinemoni(scalarn,scalarsum,scalarparam1,scalarparam2,scalartype)

For!

m=1ton

X(!

m)=@rnd*100

Next

n=1tosum

Iftype=0then

U(!

m)=@nrnd

Endif

Iftype=1then

If@rnd<

0.5then

m)=@rnd

Else

m)=@rnd*(-1)

Iftype=2then

U

(1)=@nrnd

m=2ton

m)=u(!

m-1)+@nrnd

Iftype=3then

0.5then

m)=@nrnd*2

Y(!

m)=param1+param2*x(!

m)+u(!

m)

Equationeq.lsycx

B1(!

n)=eq.@coefs

(1)

B2(!

n)=eq.@coefs

(2)

Endsub

Workfilemoniu110000

Seriesb1

Seriesb2

Seriesx

Seriesy

Seriesu

Callmoni(100,10000,20,0.8,3)

B1.hist

B2.hist

生成季度虚拟变量的程序:

wfcreatedumtestq19701990

%start="

1972:

1"

%end="

1979:

4"

i=@dtoo(%start)to@dtoo(%end)

%obsstr=@otod(!

i)

if(@mid(%obsstr,5,1)="

:

"

)then

%name="

d_"

+@left(%obsstr,4)+"

_"

+@mid(%obsstr,6)

else

+%obsstr

endif

smpl@all

series{%name}=0

smpl{%obsstr}{%obsstr}

series{%name}=1

下面这个执行不了:

n=10000

wfcreatecaou1!

n

matrix(!

n,18)m

groupg

for%1r0b0t0dw0r20f0r1b1t1dw1r21f1r2b2t2dw2r22f2

series{%1}=0

g.add{%1}

k=1to!

smpl1122

for%1y0x0y1x1y2x2

series{%1}=@rnorm

smpl2122

x1=x1(-1)+@rnorm

y1=y1(-1)+@rnorm

x2=2*x2(-1)-x2(-2)+@rnorm

y2=2*y2(-1)-y2(-2)+@rnorm

for%1%2%31y0x07y1x113y2x2

m(!

k,{%1})=@cor({%2},{%3})

equationeq.ls{%2}c{%3}

k,{%1}+1)=eq.c

(2)

k,{%1}+2)=eq.@tstats

(2)

k,{%1}+3)=eq.@dw

k,{%1}+4)=eq.@r2

k,{%1}+5)=eq.@f

smpl1!

T

mtos(m,g)

for%1t0t1t2

seriescao_{%1}=@abs({%1})>

=2

freeze(statby_{%1}){%1}.statby(nomean,nostd)cao_{%1}

freeze(hist_{%1}){%1}.hist

伪回归相关系数模拟(不行)

workfilecorru1500

i=1to500

seriesx=nrnd

seriesy=nrnd

seriesxx

seriesyy

scalarsum1=0

scalarsum2=0

counter=1to100

sum1=sum1+x(!

counter)

sum2=sum2+y(!

xx(!

counter)=sum1

yy(!

counter)=sum2

scalarr=@cor(xx,yy)

result(!

i)=r

时变贝塔系数的模拟(执行不了):

BETA.PRG(3/7/2007)

Timevaryingbeta

demonstratesseveralways

toobtainbetabetweenassets

1)constantbeta

2)rollingbetabyregression/movingcov/var

3)usingstatespace

4)usingmultivariateARCH

Checked3/20/2007

changepathtoprogrampath

%path=@runpath

cd%path

loadworkfile

loadfx.wf1

dependentvariablesofseriesmustbecontinuous

seriesy1=@pch(index)

seriesy2=@pch(jy)

------------------------------------------------------------------------

calculatetheconstantbetausingOLS

smpl1990@last

equationconstant_beta.lsy2cy1

seriesbeta_const=c

(2)

calculatingtimevaryingbetawithrollingregression

forabi-variatecasecanusemovingcov/varinstead

ofOLSregression

ssize=200

seriesbeta_roll=@movcov(y1,y2,!

ssize)/@movvar(y1,!

ssize)

codeforrunningarollingregression:

commentedoutrightnow

length=@obs(y1)

equationroll_beta.lsy2cy1

showroll_beta

i=1to!

length-!

ssize+1

smpl@first+!

i-1@first+!

i+!

ssize-2

equationroll_beta.lsy2cy1

ssize-2@first+!

beta_roll=roll_beta.@coefs

(2)

calculatebetawithStateSpace

viaatime-varyingcoefficientforY1

sspacessbeta

ssbeta.appendy2=c

(1)+sv1*y1+[var=exp(c

(2))]

ssbeta.append@statesv1=sv1(-1)

ssbeta.ml

ssbeta.makestatesbeta_*

renamebeta_sv1beta_ss

calculatebetawithsystemARCH

byestimatingthecovarianceandvarianceof

thetwoseriesusingMultivariateARCH

systemarbeta

arbeta.appendy1=c

(1)

arbeta.appendy2=c

(2)

arbeta.arch@Diagvechc(indef)arch(1,indef)garch(1,indef)

arbeta.makegarch(name=arch)

seriesbeta_arch=arch01_02/arch01

displaythedifferentbetas

groupbetas_ls_rollbeta_constbeta_roll

groupbetas_roll_ss_archbeta_rollbeta_ssbeta_arch

showbetas_ls_roll.line

showbetas_roll_ss_arch.line

在生成服从某种分布(标准正态分布白噪声序列)的随机序列的基础上生成各种ARIMA序列:

AR

(1)、MA

(1)、ARMA(1,1)、ARIMA(1,1,1)

⏹Workfilerandom2u11000

⏹Seriesu=@nrnd

⏹U

(1)=0

⏹Seriesx1

⏹X1

(1)=0

⏹Seriesx2

⏹X2

(1)=0

⏹Seriesx3

⏹X3

(1)=0

⏹Seriesx4

⏹X4

(1)=0

⏹Smpl21000

⏹x1=0.8*x1(-1)+u

⏹X2=u+0.8*u(-1)

⏹X3=0.8*x3(-1)+u+0.8*u(-1)

⏹X4=x4(-1)+x3

⏹Smpl@all

⏹groupmyx1x2x3

⏹showmy.line

⏹workfilesimuu11000

⏹seriesx1=@runif(0,1)

⏹seriesx2=@runif(0,1)

⏹seriesx3=@runif(0,1)

⏹groupgx1x2x3

⏹g.line

⏹g.bar

⏹scatx1x2

⏹sortx1

⏹genry=10+2*x1

⏹y.line

⏹freezey

⏹y.hist

⏹scalaryy=@mean(y)

⏹scalaryy1=@skew(y)

⏹scalaryy3=@kurt(y)

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2