GAUSS Programming for Econometricians and Financial Analysts

Total Page:16

File Type:pdf, Size:1020Kb

GAUSS Programming for Econometricians and Financial Analysts GAUSS Programming for Econometricians and Financial Analysts Kuan-Pin Lin ETEXT Los Angeles www.etext.net COMPUTATIONAL ECONOMETRICS GAUSS Programming for Econometricians and Financial Analysts Copyright 2001-2003 by K.–P. Lin ISBN 0-9705314-3-5 Published by ETEXT Textbook Publisher, www.etext.net. All rights reserved. No part of this book and the accompanying software may be reproduced, stored in a retrieval system, translated or transcribed, in any form or by any means— electronic, mechanical, photocopying, recording, or otherwise—without the prior written permission of the copyright owner. For permission requests or further information, see www.etext.net or email [email protected]. Printed in the United States of America. Limit of Liability and Disclaimer of Warranty Although every precaution has been taken in the preparation this book and the accompanying software, the publisher and author make no representation or warranties with respect to the accuracy or completeness of the contents, and specifically disclaim any implied warranties of merchantability or fitness for any particular purpose, and shall in no event be liable for any loss of profit or any damages arising out of the use of this book and the accompanying software. Trademarks GAUSS is a trademark of Aptech Systems, Inc. GPE2 is a product name of Applied Data Associates. All other brand names and product names used in this book are trademarks, registered trademarks, or trade names of their respective holders. ii Preface Computational Econometrics is an emerging field of applied economics which focuses on the computational aspects of econometric methodology. To explore an effective and efficient approach for econometric computation, GAUSS Programming for Econometricians and Financial Analysts (GPE) was originally developed as the outcome of a faculty-student joint project. The author developed the econometric program and used it in the classroom. The students learned the subject materials and wrote about their experiences in using the program and GAUSS. We know that one of the obstacles in learning econometrics is the need to do computer programming. Who really wants to learn a new programming language while at the same time struggling with new econometric concepts? This is probably the reason that “easy-to-use” packages such as RATS, SHAZAM, EVIEWS, and TSP are often used in teaching and research. However, these canned packages are inflexible and do not allow the user sufficient freedom in advanced modeling. GPE is an econometrics package running in the GAUSS programming environment. You write simple codes in GAUSS to interact with GPE econometric procedures. In the process of learning GPE and econometrics, you learn GAUSS programming at your own pace and for your future development. Still, it takes some time to become familiar with GPE, not to mention the GAUSS language. The purpose of this GPE project is to provide hands-on lessons with illustrations on using the package and GAUSS. GPE was first developed in 1991 and has since undergone several updates and revisions. The first version of the project, code-named LSQ, started in the summer of 1995 with limited functions of least squares estimation and prediction. This book and CDROM represent a major revision of this work in progress, including linear and nonlinear regression models, simultaneous linear equation systems, and time series analysis. Here, in your hands, is the product of GPE. The best way to learn GPE is to read the book, type in and run each lesson, and explore the sample programs and output. For your convenience, all the lessons and data files are available on the distribution disk. During several years of teaching econometrics using the GPE package, many students contributed to the ideas and codes in GPE. Valuable feedback and suggestions were incorporated into developing this book. In particular, the first LSQ version was a joint project with Lani Pennington, who gave this project its shape. Special thanks are due to Geri Manzano, Jennifer Showcross, Diane Malowney, Trish Atkinson, and Seth Blumsack for their efforts in editing and proofreading many draft versions of the manuscript and program lessons. As always, I am grateful to my family for their continuing support and understanding. iii Table of Contents PREFACE................................................................................................................................iii TABLE OF CONTENTS ............................................................................................................. v I INTRODUCTION ...................................................................................................................1 Why GAUSS?..................................................................................................................... 1 What is GPE? .................................................................................................................... 1 Using GPE......................................................................................................................... 2 II GAUSS BASICS ..............................................................................................................5 Getting Started................................................................................................................... 5 An Introduction to GAUSS Language................................................................................ 7 Creating and Editing a GAUSS Program........................................................................ 17 Lesson 2.1 Let’s Begin ...............................................................................................................18 File I/O and Data Transformation................................................................................... 21 Lesson 2.2: File I/O ....................................................................................................................23 Lesson 2.3: Data Transformation................................................................................................25 GAUSS Built-In Functions............................................................................................... 26 Lesson 2.4: Data Analysis ..........................................................................................................32 Controlling Execution Flow ............................................................................................ 33 Writing Your Own Functions........................................................................................... 36 User Library .................................................................................................................... 40 GPE Package................................................................................................................... 41 III LINEAR REGRESSION MODELS .....................................................................................43 Least Squares Estimation ................................................................................................ 43 Lesson 3.1: Simple Regression...................................................................................................44 Lesson 3.2: Residual Analysis....................................................................................................46 Lesson 3.3: Multiple Regression ................................................................................................48 Estimating Production Function...................................................................................... 50 Lesson 3.4: Cobb-Douglas Production Function ........................................................................51 Lesson 3.5: Testing for Structural Change..................................................................................55 Lesson 3.6: Residual Diagnostics ...............................................................................................58 IV DUMMY VARIABLES ....................................................................................................63 Seasonality....................................................................................................................... 63 Lesson 4.1: Seasonal Dummy Variables.....................................................................................64 Lesson 4.2: Dummy Variable Trap.............................................................................................67 Structural Change............................................................................................................ 68 Lesson 4.3: Testing for Structural Change: Dummy Variable Approach ...................................68 V MULTICOLLINEARITY.....................................................................................................73 Detecting Multicollinearity.............................................................................................. 73 Lesson 5.1: Condition Number and Correlation Matrix..............................................................73 Lesson 5.2: Theil’s Measure of Multicollinearity.......................................................................75 Lesson 5.3: Variance Inflation Factors (VIF) .............................................................................77 Correction for Multicollinearity ...................................................................................... 78 Lesson 5.4: Ridge Regression and Principal Components..........................................................78
Recommended publications
  • Stan: a Probabilistic Programming Language
    JSS Journal of Statistical Software MMMMMM YYYY, Volume VV, Issue II. http://www.jstatsoft.org/ Stan: A Probabilistic Programming Language Bob Carpenter Andrew Gelman Matt Hoffman Columbia University Columbia University Adobe Research Daniel Lee Ben Goodrich Michael Betancourt Columbia University Columbia University University of Warwick Marcus A. Brubaker Jiqiang Guo Peter Li University of Toronto, NPD Group Columbia University Scarborough Allen Riddell Dartmouth College Abstract Stan is a probabilistic programming language for specifying statistical models. A Stan program imperatively defines a log probability function over parameters conditioned on specified data and constants. As of version 2.2.0, Stan provides full Bayesian inference for continuous-variable models through Markov chain Monte Carlo methods such as the No-U-Turn sampler, an adaptive form of Hamiltonian Monte Carlo sampling. Penalized maximum likelihood estimates are calculated using optimization methods such as the Broyden-Fletcher-Goldfarb-Shanno algorithm. Stan is also a platform for computing log densities and their gradients and Hessians, which can be used in alternative algorithms such as variational Bayes, expectation propa- gation, and marginal inference using approximate integration. To this end, Stan is set up so that the densities, gradients, and Hessians, along with intermediate quantities of the algorithm such as acceptance probabilities, are easily accessible. Stan can be called from the command line, through R using the RStan package, or through Python using the PyStan package. All three interfaces support sampling and optimization-based inference. RStan and PyStan also provide access to log probabilities, gradients, Hessians, and data I/O. Keywords: probabilistic program, Bayesian inference, algorithmic differentiation, Stan.
    [Show full text]
  • Introduction Rats Version 9.0
    RATS VERSION 9.0 INTRODUCTION RATS VERSION 9.0 INTRODUCTION Estima 1560 Sherman Ave., Suite 510 Evanston, IL 60201 Orders, Sales Inquiries 800–822–8038 Web: www.estima.com General Information 847–864–8772 Sales: [email protected] Technical Support 847–864–1910 Technical Support: [email protected] Fax: 847–864–6221 © 2014 by Estima. All Rights Reserved. No part of this book may be reproduced or transmitted in any form or by any means with- out the prior written permission of the copyright holder. Estima 1560 Sherman Ave., Suite 510 Evanston, IL 60201 Published in the United States of America Preface Welcome to Version 9 of rats. We went to a three-book manual set with Version 8 (this Introduction, the User’s Guide and the Reference Manual; and we’ve continued that into Version 9. However, we’ve made some changes in emphasis to reflect the fact that most of our users now use electronic versions of the manuals. And, with well over a thousand example programs, the most common way for people to use rats is to pick an existing program and modify it. With each new major version, we need to decide what’s new and needs to be ex- plained, what’s important and needs greater emphasis, and what’s no longer topical and can be moved out of the main documentation. For Version 9, the chapters in the User’s Guide that received the most attention were “arch/garch and related mod- els” (Chapter 9), “Threshold, Breaks and Switching” (Chapter 11), and “Cross Section and Panel Data” (Chapter 12).
    [Show full text]
  • Econometrics Oxford University, 2017 1 / 34 Introduction
    Do attractive people get paid more? Felix Pretis (Oxford) Econometrics Oxford University, 2017 1 / 34 Introduction Econometrics: Computer Modelling Felix Pretis Programme for Economic Modelling Oxford Martin School, University of Oxford Lecture 1: Introduction to Econometric Software & Cross-Section Analysis Felix Pretis (Oxford) Econometrics Oxford University, 2017 2 / 34 Aim of this Course Aim: Introduce econometric modelling in practice Introduce OxMetrics/PcGive Software By the end of the course: Able to build econometric models Evaluate output and test theories Use OxMetrics/PcGive to load, graph, model, data Felix Pretis (Oxford) Econometrics Oxford University, 2017 3 / 34 Administration Textbooks: no single text book. Useful: Doornik, J.A. and Hendry, D.F. (2013). Empirical Econometric Modelling Using PcGive 14: Volume I, London: Timberlake Consultants Press. Included in OxMetrics installation – “Help” Hendry, D. F. (2015) Introductory Macro-econometrics: A New Approach. Freely available online: http: //www.timberlake.co.uk/macroeconometrics.html Lecture Notes & Lab Material online: http://www.felixpretis.org Problem Set: to be covered in tutorial Exam: Questions possible (Q4 and Q8 from past papers 2016 and 2017) Felix Pretis (Oxford) Econometrics Oxford University, 2017 4 / 34 Structure 1: Intro to Econometric Software & Cross-Section Regression 2: Micro-Econometrics: Limited Indep. Variable 3: Macro-Econometrics: Time Series Felix Pretis (Oxford) Econometrics Oxford University, 2017 5 / 34 Motivation Economies high dimensional, interdependent, heterogeneous, and evolving: comprehensive specification of all events is impossible. Economic Theory likely wrong and incomplete meaningless without empirical support Econometrics to discover new relationships from data Econometrics can provide empirical support. or refutation. Require econometric software unless you really like doing matrix manipulation by hand.
    [Show full text]
  • Econometric Theory
    Econometric Theory John Stachurski January 10, 2014 Contents Preface v I Background Material1 1 Probability2 1.1 Probability Models.............................2 1.2 Distributions................................. 16 1.3 Dependence................................. 25 1.4 Asymptotics................................. 30 1.5 Exercises................................... 39 2 Linear Algebra 49 2.1 Vectors and Matrices............................ 49 2.2 Span, Dimension and Independence................... 59 2.3 Matrices and Equations........................... 66 2.4 Random Vectors and Matrices....................... 71 2.5 Convergence of Random Matrices.................... 74 2.6 Exercises................................... 79 i CONTENTS ii 3 Projections 84 3.1 Orthogonality and Projection....................... 84 3.2 Overdetermined Systems of Equations.................. 90 3.3 Conditioning................................. 93 3.4 Exercises................................... 103 II Foundations of Statistics 107 4 Statistical Learning 108 4.1 Inductive Learning............................. 108 4.2 Statistics................................... 112 4.3 Maximum Likelihood............................ 120 4.4 Parametric vs Nonparametric Estimation................ 125 4.5 Empirical Distributions........................... 134 4.6 Empirical Risk Minimization....................... 137 4.7 Exercises................................... 149 5 Methods of Inference 153 5.1 Making Inference about Theory...................... 153 5.2 Confidence Sets..............................
    [Show full text]
  • The Evolution of Econometric Software Design: a Developer's View
    Journal of Economic and Social Measurement 29 (2004) 205–259 205 IOS Press The evolution of econometric software design: A developer’s view Houston H. Stokes Department of Economics, College of Business Administration, University of Illinois at Chicago, 601 South Morgan Street, Room 2103, Chicago, IL 60607-7121, USA E-mail: [email protected] In the last 30 years, changes in operating systems, computer hardware, compiler technology and the needs of research in applied econometrics have all influenced econometric software development and the environment of statistical computing. The evolution of various representative software systems, including B34S developed by the author, are used to illustrate differences in software design and the interrelation of a number of factors that influenced these choices. A list of desired econometric software features, software design goals and econometric programming language characteristics are suggested. It is stressed that there is no one “ideal” software system that will work effectively in all situations. System integration of statistical software provides a means by which capability can be leveraged. 1. Introduction 1.1. Overview The development of modern econometric software has been influenced by the changing needs of applied econometric research, the expanding capability of com- puter hardware (CPU speed, disk storage and memory), changes in the design and capability of compilers, and the availability of high-quality subroutine libraries. Soft- ware design in turn has itself impacted applied econometric research, which has seen its horizons expand rapidly in the last 30 years as new techniques of analysis became computationally possible. How some of these interrelationships have evolved over time is illustrated by a discussion of the evolution of the design and capability of the B34S Software system [55] which is contrasted to a selection of other software systems.
    [Show full text]
  • International Journal of Forecasting Guidelines for IJF Software Reviewers
    International Journal of Forecasting Guidelines for IJF Software Reviewers It is desirable that there be some small degree of uniformity amongst the software reviews in this journal, so that regular readers of the journal can have some idea of what to expect when they read a software review. In particular, I wish to standardize the second section (after the introduction) of the review, and the penultimate section (before the conclusions). As stand-alone sections, they will not materially affect the reviewers abillity to craft the review as he/she sees fit, while still providing consistency between reviews. This applies mostly to single-product reviews, but some of the ideas presented herein can be successfully adapted to a multi-product review. The second section, Overview, is an overview of the package, and should include several things. · Contact information for the developer, including website address. · Platforms on which the package runs, and corresponding prices, if available. · Ancillary programs included with the package, if any. · The final part of this section should address Berk's (1987) list of criteria for evaluating statistical software. Relevant items from this list should be mentioned, as in my review of RATS (McCullough, 1997, pp.182- 183). · My use of Berk was extremely terse, and should be considered a lower bound. Feel free to amplify considerably, if the review warrants it. In fact, Berk's criteria, if considered in sufficient detail, could be the outline for a review itself. The penultimate section, Numerical Details, directly addresses numerical accuracy and reliality, if these topics are not addressed elsewhere in the review.
    [Show full text]
  • Hands-On & Exercise: Stata Hands-On: Eviews & Stata
    @ COMP. LAB. 3, SCHOOL OF MATHEMATICAL SCIENCES, USM PENANG 13 (Sat) & 14 (Sun) MARCH 2021 The OBJECTIVE of this course is to introduce participants with VAR model and panel data structures and also to equip them with core skills in analyzing techniques for various types of panel data HANDS-ON & EXERCISE: STATA COURSE CONTENTS SHORT PANEL DATA ANALYSIS FACILITATORS: ✓ Fixed & Random Effects ✓ Pooled OLS, Hausman Test Dr Zainudin Arsad (USM) & ✓ Arellano-Bond Difference GMM ✓ Blundell-Bond System GMM Ass. Prof. Dr LAW S. HOOK (UPM) ECONOMETRIC ANALYSIS WITH STRUCTURAL BREAK: ✓ Long-run Models: FMOLS/DOLS/CCR ✓ Quandt-Andrews, Bai-Perron Tests ✓ Gregory & Hansen (1996) Test ✓ Johansen, Mosconi and Nieldsen (2000) Cointegration Test WHO SHOULD ATTEND Academics and Graduate Students as well as Researchers, Analysts and Consultants in various business disciplines that may include Private & Public Sector Organizations, Banks & Financial Institutions and Regulatory Authorities. HANDS-ON: EVIEWS & STATA FACILITATOR: Professor Dr. Eng Yoke Kee (UTAR) 3 (Sat) & 4 (Sun) APRIL 2021 SHORT PANEL DATA ANALYSIS DAY 1 : SATURDAY, 13 MARCH 2021 8:15 AM REGISTRATION 8:45 AM SESSION 1 – THE NATURE OF PANEL DATA ▪ Nature and Benefits od Panel Data; Examining & Arranging Your Dataset 10:30 AM TEA BREAK 10:45 AM SESSION 2 – STATIC LINEAR PANEL MODELS ▪ Panel Data Basics: Pooled OLS, Fixed and Random Effects 12:45 PM LUNCH 2:00 PM SESSION 3 – SELECTING PANEL DATA MODELS ▪ Poolability F-test, Breusch-Pagan LM Test, Hausman Test 3.45 PM TEA BREAK 4.00 PM SESSION 4 – ISSUES ON PANEL DATA MODELS: ROBUST ESTIMATES ▪ Diagnostic Tests and Robust Standard Errors 5:45 PM Q & A (SESSIONS 1 - 4) DAY 2 : SUNDAY, 14 MARCH 2021 8:30 AM SESSION 5 – DYNAMIC PANEL DATA APPROACH ▪ Why Dynamic Panel? 10:15 AM TEA BREAK 10:30 AM SESSION 6 – MULTIVARIATE DYNAMIC MODELS WITH PERSISTENT SERIES ▪ Arellano-Bond Difference Estimator, 1-step vs.
    [Show full text]
  • Rtadf: Testing for Bubbles with Eviews
    JSS Journal of Statistical Software November 2017, Volume 81, Code Snippet 1. doi: 10.18637/jss.v081.c01 Rtadf: Testing for Bubbles with EViews Itamar Caspi Bank of Israel Abstract This paper presents Rtadf (right-tail augmented Dickey-Fuller), an EViews add-in that facilitates the performance of time series based tests that help detect and date-stamp asset price bubbles. The detection strategy is based on a right-tail variation of the standard augmented Dickey-Fuller (ADF) test where the alternative hypothesis is of a mildly explo- sive process. Rejection of the null in each of these tests may serve as empirical evidence for an asset price bubble. The add-in implements four types of tests: standard ADF, rolling window ADF, supremum ADF (SADF; Phillips, Wu, and Yu 2011) and general- ized SADF (GSADF; Phillips, Shi, and Yu 2015). It calculates the test statistics for each of the above four tests, simulates the corresponding exact finite sample critical values and p values via Monte Carlo methods, under the assumption of Gaussian innovations, and produces a graphical display of the date stamping procedure. Keywords: rational bubble, ADF test, sup ADF test, generalized sup ADF test, mildly explo- sive process, EViews. 1. Introduction Empirical identification of asset price bubbles in real time, and even in retrospect, is surely not an easy task, and it has been the source of academic and professional debate for several decades.1 One strand of the empirical literature suggests using time series estimation tech- niques while exploiting predictions made by finance theory in order to test for the existence of bubbles in the data.
    [Show full text]
  • Introduction to Eviews 2.0
    Introduction to EViews 2.0 Overview of product EViews provides regression and forecasting tools on Windows computers. With EViews you can develop a statistical relation from your data and then use the relation to forecast future values of the data. Areas where EViews can be useful include: · Sales forecasting · Cost analysis and forecasting · Financial analysis · Macroeconomic forecasting · Simulation · Scientific data analysis and evaluation EViews is a new version of a set of tools for manipulating time series data originally developed in the Time Series Processor software for large computers. The immediate predecessor of EViews was MicroTSP, first released in 1981. Though EViews was developed by economists and most of its uses are in economics, there is nothing in its design that limits its usefulness to economic time series. Even quite large cross-section projects can be handled in EViews. The basic data object within EViews is the time series. Each series has a name, and you can request operations on all the observations just by mentioning the name of the series. EViews provides convenient visual ways to enter time series from the keyboard or from disk files, to create new series from existing ones, to display and print series, and to carry out statistical analysis of the relations among series. EViews uses the visual features of modern Windows software. You can use your mouse to guide the operation with standard Windows menus and dialogs. Results appear in windows and can be manipulated with standard Windows techniques. Alternatively, you may use EViews' powerful command language. You can enter and edit commands in the command window.
    [Show full text]
  • Gretl User's Guide
    Gretl User’s Guide Gnu Regression, Econometrics and Time-series Allin Cottrell Department of Economics Wake Forest university Riccardo “Jack” Lucchetti Dipartimento di Economia Università Politecnica delle Marche December, 2008 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation (see http://www.gnu.org/licenses/fdl.html). Contents 1 Introduction 1 1.1 Features at a glance ......................................... 1 1.2 Acknowledgements ......................................... 1 1.3 Installing the programs ....................................... 2 I Running the program 4 2 Getting started 5 2.1 Let’s run a regression ........................................ 5 2.2 Estimation output .......................................... 7 2.3 The main window menus ...................................... 8 2.4 Keyboard shortcuts ......................................... 11 2.5 The gretl toolbar ........................................... 11 3 Modes of working 13 3.1 Command scripts ........................................... 13 3.2 Saving script objects ......................................... 15 3.3 The gretl console ........................................... 15 3.4 The Session concept ......................................... 16 4 Data files 19 4.1 Native format ............................................. 19 4.2 Other data file formats ....................................... 19 4.3 Binary databases ..........................................
    [Show full text]
  • Eviews 10 Getting Started Eviews 10 Getting Started Copyright © 1994–2017 IHS Global Inc
    EViews 10 Getting Started EViews 10 Getting Started Copyright © 1994–2017 IHS Global Inc. All Rights Reserved ISBN: 978-1-880411-36-0 This software product, including program code and manual, is copyrighted, and all rights are reserved by IHS Global Inc. The distribution and sale of this product are intended for the use of the original purchaser only. Except as permitted under the United States Copyright Act of 1976, no part of this product may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of IHS Global Inc. Disclaimer The authors and IHS Global Inc.assume no responsibility for any errors that may appear in this manual or the EViews program. The user assumes all responsibility for the selection of the pro- gram to achieve intended results, and for the installation, use, and results obtained from the pro- gram. Trademarks EViews® is a registered trademark of IHS Global Inc. Windows, Excel, PowerPoint, and Access are registered trademarks of Microsoft Corporation. PostScript is a trademark of Adobe Corpora- tion. X11.2 and X12-ARIMA Version 0.2.7, and X-13ARIMA-SEATS are seasonal adjustment pro- grams developed by the U. S. Census Bureau. Tramo/Seats is copyright by Agustin Maravall and Victor Gomez. Info-ZIP is provided by the persons listed in the infozip_license.txt file. Please refer to this file in the EViews directory for more information on Info-ZIP. Zlib was written by Jean-loup Gailly and Mark Adler. More information on zlib can be found in the zlib_license.txt file in the EViews directory.
    [Show full text]
  • Applied Econometrics Using MATLAB
    Applied Econometrics using MATLAB James P. LeSage Department of Economics University of Toledo CIRCULATED FOR REVIEW October, 1998 2 Preface This text describes a set of MATLAB functions that implement a host of econometric estimation methods. Toolboxes are the name given by the MathWorks to related sets of MATLAB functions aimed at solving a par- ticular class of problems. Toolboxes of functions useful in signal processing, optimization, statistics, nance and a host of other areas are available from the MathWorks as add-ons to the standard MATLAB software distribution. I use the termEconometrics Toolbox to refer to the collection of function libraries described in this book. The intended audience is faculty and students using statistical methods, whether they are engaged in econometric analysis or more general regression modeling. The MATLAB functions described in this book have been used in my own research as well as teaching both undergraduate and graduate econometrics courses. Researchers currently using Gauss, RATS, TSP, or SAS/IML for econometric programming might nd switching to MATLAB advantageous. MATLAB software has always had excellent numerical algo- rithms, and has recently been extended to include: sparse matrix algorithms, very good graphical capabilities, and a complete set of object oriented and graphical user-interface programming tools. MATLAB software is available on a wide variety of computing platforms including mainframe, Intel, Apple, and Linux or Unix workstations. When contemplating a change in software, there is always the initial investment in developing a set of basic routines and functions to support econometric analysis. It is my hope that the routines in the Econometrics Toolbox provide a relatively complete set of basic econometric analysis tools.
    [Show full text]