GAUSS Programming for Econometricians and Financial Analysts
Total Page:16
File Type:pdf, Size:1020Kb
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