简单eviews命令

更新时间:2023-08-20 17:03:01 阅读量: 高等教育 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

全英文

ProgramminginEViews

NikolausHautschOctober16,2003

1Generalinstructions

selectfromthemenubar:file→new→program savingtheprogram(.prg)→program le executingtheprogramwithrun EViewsreferences(underhelp):

–generalprogrammingreferences:

helphelphelphelp

→→→→EViewsEViewsEViewsEViews

helphelphelphelp

topicstopicstopicstopics

→→→→

programbasicsprogramvariables

controllingaprogramsubroutines

–thecommandreferenceprovidesacompletealphabeticallistingofthecommands,views,andproceduresinEViews–thefunctionreferencecontainsacompletelistingofthefunctionsandmathematicaloperatorsusedinformingseriesexpressions,andinperformingmatrixelementoperations–thematrixandstringreferencelistsallofthematrix,vector,andscalarfunctionsandcommands–thestringreferencecontainsalistofstringfunctions

2Loadingdataandconstructingwork les

loadyourdataintoExcelsheets

createanewwork leinEViews:file→new→workfile

choosethework lefrequencyandwork lerange(accordingtothenumberofobservationsinyourExcelsheet)

UsetheExcelimportfunctionofEViews:file→import→ReadText-Lotus-Excel

Chooseyourspeci cExcel le

SpecifytheimportedrangeontheExcelsheetandthenamesoftheseries.ClickonOK. Saveyourwork le.

1

全英文

3Writingtheprogram

openanexistingwork le:openc:\mypath\mywork

or

creatinganewwork lenamedmywork:workfilemyworku110000 Allvariablesusedhavetobedeclared rst Don’tforgettosaveitfromtimetotime!

Usecommentsextensivelytounderstandyourprogramlateron,commentlinesbeginwitha’,forexample:

’thisprogramcomputesVaRonsimulateddata

4Programvariables

(seealsounderhelp→EViewssearch)

Control(program)variables:namesbeginwitha!!anfang=1

!ende=!anfang+100 Generalvariablescoefaseriesxvector(10)vmatrix(10,3)mgroupg

Stringvariables(textenclosedindoublequotes):namesbeginwitha%

%str="Thisisastring"

youcanusestringstohelpyoubuildupcommandsandvariablenamesorasheadingsintables

Manipulatingstringvariables

–convertingastringvariablecontaininganumberintoanumberbyusingthe@valfunction%str=".05"

!nmbr=@val(%strng)

–convertinganumberintoastringvariable%strng=@str(!nmbr)–concatenatingstrings

%sampleperiod=""+@str(!anfang)+""+@str(!ende) Replacementvariables:EViewsallowsyoutoconstructcommandlinesusingthecontentsofstringandcontrolvariables.!i=1

seriesx!i%strng="new"seriesx%strng}

declaresaseriesnamedx1declaresaseriesnamedx

全英文

programarguments:programargumentsarespecialstringvariablesthatarepassedtoyourprogramwhenyouruntheprogram.Argumentsallowyoutochangethevalueofstringvariableseverytimeyouruntheprogram.eq1.ls%0c%1

runregproglgdpm1performsaregressionofthevariableLGDP,onC,andM1

5Convertingseriestovectorsandviceversa

conversionfromaseriesintoavector:vector(10)vctr1=@convert(ser1) conversionofseriesintoamatrix:stom(lwage,vec1)

stom llsthevectorvec1withdatafromlwageAttention:missingvaluesareexcluded.Alternative:stomna(lwage,vec1)

conversionofamatrixtoaseriesorgroup:seriescol1seriescol2

groupgrp1col1col2mtos(mtrx1,grp1)

mtos llsthegroupgrp1withdatafrommtrx1

6Ifstatements

(seealso:help,controllingaprogram)if!a=10or%strng="yes"x=yelse

x=y+zendif

7Loops

forloops

vctr(1,1)=1

for!i=2to!ende

vctr(!i,1)=vctr(!i-1,1)*!inext

for!run=1to10

!anfang=(!runcounter-1)*100+1!ende=(!runcounter)*100

%sample=""+@str(!anfang)+""+@str(!ende)smpl%sample

全英文

sigmavector(!run=@stdev(x)next whileloops!i=1

while!i<=100!i=!i+1wend

8Subroutines

asubroutinestartswiththeword’subroutine’followedbythenameoftheroutineandanyarguments,andendswith’endsub’subroutinequot(seriesv,seriesy,scalarp)v=y/pendsub

9Workingwithtables

(seealsohelp→EViewshelptopics→workingwithtables) declaringatabletable(n,k)tab1 llingcellsofatable

setcell(tab1,x,y,u):placesscalaruinthexthrowandythcolumnoftab1

10Objectcommands

(seealso:help,objectreference)

10.1Generalcommands

showsobjectplotsseriesxfreezesoutputrestrictssample

showxplotx

freezegraph1smpl1100

全英文

10.2Regressioncommands

OLSregressionofyonx1,x2,x3ARCH(p,q)regression

Twostageleastsquareswithinstrumentsz1,z2,z3displaysgraphsoftheresidualscoe cientvector

vectorofstandarderrorsforcoe cients

sumofsquaredresidualsbasedonOLSregression

runningaVAR(1)(namevar1)fory1andy2inaprogramresidualcovariancematrixofthe(VAR)systemvar1

ls(options)yx1x2x3

arch(p,q,options)yx1x2x3

tsls(options)yx1x2@z1z2z3resids@coefs@stderrs@ssr

varvar1.ls11y1y2cvar1.@residcov

10.3Graphiccommands

bargraphsxygraph

barser1ser2ser3xy

11

11.1

Functions

Timeseriesfunctions

1 n 1

n-periodbackwardmovingaverage: j=0Xt j

n 1

n-periodbackwardmovingsum:j=0Xt j1storderdi erenceofseriesX:Xt Xt 1

1storderdi erenceoflogarithmofseriesX:ln(Xt) ln(Xt 1)

@movav(X,n)@movsum(X,n)d(X)dlog(X)

11.2Statisticaldistributionfunctions

cumulativedensityfunctionofnormaldistributiondensityfunctionofnormaldistributionquantileofnormaldistribution

generatesnormallydistributedrandomvariablesquantileoftvdistribution

generatestvdistributedrandomvariablesquantileofχ2vdistribution

generatestvdistributedrandomvariables

@cnorm(x)@dnorm(x)@qnorm(p)@rnorm

@qtdist(p,v)@rtdist(v)@qchisq(p,v)@rtdist(v)

全英文

11.3Descriptivestatisticfunctions

numberofelementsofgroup’grp1’nameofithelementofgroup’grp1’absolutevalueexponential

naturallogarithm(ln)squareroot nsumofallX:=1Xt tn

2sum-of-squares:t=1Xt

numberofelementsinx

maximumoftheseriesXminimumoftheseriesXmedianoftheseriesXmeanoftheseriesX

standarddeviationoftheseriesXq-thquantileoftheseriesX

correlationbetweentheSeriesXandY1storderautocorrelationcovariance

computestheCholeskydecompositionofm1

largestintegernotgreaterthanx,e.g.@ oor(1.23)=1

grp1.@count

%str=grp1.@seriesname(i)@abs(x)@exp(x)@log(x)@sqr(x)@sum(X)@sumsq(X)@obs(x)@max(X)@min(X)@median(X)@mean(X)@stdev(X)

@quantile(X,q)@cor(X,Y)

@cor(X,X(-1))@cov(X,Y)

@cholesky(m1)@floor(x)

11.4Matrixfunctions

placesthecolumnvectorvintothematrixmatcolumnnplacestherowvectorrintothematrixmatrown

placesthematrixm2intom1atrown1andcolumnn2Choleskyfactorizationofs

extractsavectorfromcolumnnofthematrixobjectmextractsarowvectorfromrownofthematrixobjectmnumberofcolumnsinthematrixobjectoquantileoftvdistribution

generatestvdistributedrandomvariablesquantileofχ2vdistribution

generatestvdistributedrandomvariables

colplace(m,v,n)rowplace(m,v,n)

matplace(m1,m2,n1,n2)@cholesky(s)

@columnextract(m,n)@rowextract(m,n)@columns(o)@qtdist(p,v)@rtdist(v)@qchisq(p,v)@rtdist(v)

12Operators

+,-,*,/,^>,<,=,<><=,>=and,or

add,subtract,multiply,divide,raisetopowergreater,less,equal,notequal

lessthanorequal,greaterthanorequallogicaland,logicalor

(seealso:help,functionreference)

本文来源:https://www.bwwdw.com/article/pyuj.html

Top