1 / 14

GAUSS Programming for Econometricians

GAUSS Programming for Econometricians. Introduction to GAUSS Using GPE2/ GAUSS. GAUSS Mathematical and Statistical System. Windows Interface Windows Command, Error, Log, … Menu File, Edit, Run, …, Help Operation Interactive Mode Command (Input / Output) Batch Mode Writing Program.

ion
Download Presentation

GAUSS Programming for Econometricians

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GAUSS Programming for Econometricians Introduction to GAUSS Using GPE2/GAUSS

  2. GAUSSMathematical and Statistical System • Windows Interface • Windows • Command, Error, Log, … • Menu • File, Edit, Run, …, Help • Operation • Interactive Mode • Command (Input / Output) • Batch Mode • Writing Program

  3. GAUSS Basic • Basic Operations on Matrices + -  ^   .*   ./   %   !   *   / .<   .<=   .==   .>=   .>   ./=     <   <=   ==   >=   >   /= .not  .and   .or   .xor   not  and or   xor ~   |   .*.   *~ • Special Operators []   {}   :   .   '(transpose) • Useful Algrbra and Matrix Operations exp ln log  abs  sqrt  pi sin cos inv invpd(inverse) det(determinant)

  4. Useful GAUSS Functions • System Functions: use, load, output • Data Generating Functions:ones, zeros, eye, seqa, seqm, rndu, rndn • Data Conversion Functions:reshape, selif, delif, vec, vech, xpnd, submat, diag, diagrv • Basic Matrix Functions: • Matrix Description:rows, cols, maxc, minc, meanc, median, stdc • Matrix Operations:sumc,cumsumc,prodc,cumprodc,sortc,sorthc,sortind • Matrix Computation:det,inv,invpd,solpd,vcx,corrx,cond,rank,eig,eigh • Probability and Statistical Functions:pdfn, cdfn, cdftc, cdffc, cdfchic, dstat, ols • Calculus Functions:gradp, hessp, intsimp, linsolve, eqsolve, sqpsolve

  5. GPE2 for GAUSS • GPE2 is a package of econometric procedures written in GAUSS. There are four main functions, driven by a set of global control variables: • ResetSet up global control (input and output) variables. • EstimateEstimation of a linear or generalized linear model. • ForecastForecasting based on a linear or generalized linear model. • OptimizeEstimation of a nonlinear model.

  6. GPE2 for GAUSS • Selected Global Control Variables • Input Control Variables_names, _begin, _end, _rstat, _rtest, _rplot, _rlist,_const, _restr, _vcov, _hacv, _weight, _ivar, _dlags, _pdl, _eq, _id, _ar, _ma, _arma, _garch, _acf, _acf2, _nlopt, _method, _iter, _tol, _step, _conv, _fbrgin, _fend, _fstat, _fplot • Output Control Variables__y, __x, __e, __b, __vb, __v, __rss, __r2, __f, __vf, __t, __a, __va

  7. A Typical Program Using GPE2 /* ** Comments on program title, purposes, and the usage of the program */ use gpe2; @ using GPE package (version 2) @ // this must be the first executable statement /* ** Writing output to file or sending it to printer: ** specify file name for output */ // Loading data: read data series from data files. /* ** Generating or transforming data series: ** create and generate variables with data scaling or transformation ** (e.g. y and x are generated here and will be used below) */ call reset; @ initialize global variables @ /* ** Set input control variables for model estimation ** (e.g. _names for variable names, see Appendix A) */ call estimate(y,x); @ do model estimation @ // variables y, x are generated earlier /* ** Retrieve output control variables for model evaluation and analysis */ /* ** Set more input control variables if needed, for model prediction ** (e.g. _b for estimated parameters) */ call forecast(y,x); @ do model prediction @ end; @ important: don’t forget this @

  8. Where is the Data? • GAUSS Dataset • Datasets (or matrices) • Text Data • Type your own data • Import from Notebook, … • Spreadsheet • Excel

  9. Stata Dataset sp500.dta • Interactive mode • Use GPE2; • Load dataset • Data Analysis • Generate variables • Regression and Graph • Call GPE functions: Reset, Estimate,… • Help for GAUSS and GPE2 • Gpehelp

  10. /* ** Load GAUSS dataset ** Data management and analysis using GPE2 */ use gpe2; datfile="c:\\course09\\ec570\\data\\sp500.dat"; // "\" is a special character in GAUSS alldata=loadd(datfile); names=getname(datfile); high=alldata[.,4]; low=alldata[.,5]; closed=alldata[.,6]; // can not use "close" volumed=alldata[.,7]; // can not use "volume" change=alldata[.,8]; volatility=high-low; call reset; _names={"returns","risk","volume"}; _rplot=2; _begin=2; call estimate(change,volatility); call estimate(change,volatility~ln(volumed)); end;

  11. Text Data gasoline.txt • Batch Mode: write your program • Use GPE2; • Load text (or spreadsheet) data • Generate variables • Call GPE functions: Reset, Estimate,…

  12. /* ** Example 1.1: U.S. Gasoline Market ** Regression without using GPE2 */ load txtdata[52,11]=c:\course09\ec570\data\gasoline.txt; year=txtdata[.,1]; // year, 1953-2004 gasexp=txtdata[.,2]; // total U.S. gasoline expenditure popu=txtdata[.,3]; // U.S. population gasp=txtdata[.,4]; // price index for gasoline income=txtdata[.,5]; // per capita disposable income pnc=txtdata[.,6]; // price index for new cars puc=txtdata[.,7]; // price index for used cars ppt=txtdata[.,8]; // price index for public transportation pd=txtdata[.,9]; // price index for consumer duraqbles pn=txtdata[.,10]; // price index for consumer nondurables ps=txtdata[.,11]; // price index for consumer services call dstat(0,txtdata); g=ln(gasexp./(popu.*gasp)); pg=ln(gasp); y=ln(income); n=rows(g); one=ones(n,1); xvar=pg~y~one; yvar=g; b=invpd(xvar'*xvar)*xvar'*yvar; // b=yvar/xvar; e=yvar-xvar*b; print b; M=eye(n)-xvar*invpd(xvar'*xvar)*xvar'; print e~(M*e)~(M*xvar); end;

  13. /* ** Example 1.2: U.S. Gasoline Market ** Checking Frisch-Waugh Theorem using GPE2 */ use gpe2; load txtdata[52,11]=c:\course09\ec570\data\gasoline.txt; /* ** … skip data definition, same as Example 1.1 … ** */ g=ln(gasexp./(popu.*gasp)); // log-per-capita gas consumption y=ln(income); // log-per-capita income pg=ln(gasp); // log price of gas call reset; call estimate(g,year); gstar=__e; call estimate(y,year); // partial regression ystar=__e; call estimate(pg,year); pgstar=__e; _names={"G","Y","PG","year"}; call estimate(gstar,ystar~pgstar); call estimate(g,ystar~pgstar~year); call estimate(g,y~pg~year); // full regression end;

  14. /* ** Example 1.3: U. S. Gasoline Market ** Checking R-square and effects of adding variables */ use gpe2; load txtdata[52,11]=c:\course09\ec570\data\gasoline.txt; /* ** … skip data definition, same as Example 1.1 … ** */ g=ln(gasexp./(popu.*gasp)); // log-per-capita gas consumption y=ln(income); // log-per-capita income pg=ln(gasp); // log price of gas pnew=ln(pnc); // log price of new cars pused=ln(puc); // log price of used cars call reset; _names={"g","y","pg"}; call estimate(g,y~pg); call estimate(g,y~pg~year); call estimate(g,y~pg~pnew); call estimate(g,y~pg~pused); _names={"g","y","pg","year","pnew","pused"}; call estimate(g,y~pg~year~pnew~pused); end;

More Related