Palgrave Handbook of Econometrics: Applied Econometrics

(Grace) #1
David T. Jacho-Chávez and Pravin K. Trivedi 779

15.2.1.1 Characteristics
Researchers are often faced with the dilemma of what programming language to
use. Although the final decision is mostly a matter of taste and time constraints,
the following should serve as guidelines:


  • Portability. Source code written in 4GLs requires a local installation of the
    relevant compiler for their implementation. Since these languages are often
    proprietary, this could make sharing and replicability inconvenient.^1 On the
    other hand, after compilation, 3GL’s executable files do not require any kind of
    formal installation onto a computer’s permanent storage device to be executed
    and can be sent to others by e-mail, enabling it to be used on multiple computers.

  • Complexity. Compiled programming languages are general purpose languages.
    They often only include primitive mathematical functions and, with the excep-
    tion of Fortran, they solely provide uniform pseudo-random number generators.
    On the other hand, interpreted languages are conceived with a specific pur-
    pose in mind. They admit a richer set of data types than integer and double
    precision numbers. Multidimensional arrays are also native objects in some of
    these languages. Standard econometrics and mathematical techniques are sel-
    dom implemented in compiled languages, but they are plentiful in interpreted
    languages.

  • Expandability. Both 3GL and 4GL can readily be expanded by the inclusion
    oflibrariesandpackages. Libraries are collections of special purpose algorithms.
    Examples include the IMSL libraries of Visual Numerics Inc. for C and Fortran,
    and NAG Fortran Library subroutines of the Numerical Analysis Group. Packages
    are collections of programs linked together. Examples include packages in R, and
    modules in Stata.

  • Efficiency. A main disadvantage of interpreted languages is that applications
    run slower than if they had been compiled, especially iterative algorithms that
    require loops iterated many times, e.g., bootstrapping and cross-validation. This
    is because the interpreter must analyze each statement in the source code each
    time it is executed, and then perform the desired action, whereas the compiled
    code simply performs the action. Furthermore, 3GL such as C and Fortran per-
    mit better control of dynamic memory allocation that can potentially speed up
    many implementations.^2


However, it is no longer the case that researchers must choose between 3GL and
4GL when facing a programming task. Modern computing environments allow the
inclusion of C or Fortran subroutines, viaforeign language interface, into 4GL such as
GAUSS, MATLAB, R, Stata and vice versa, as well as the possibility ofparallelization.

15.2.2 Foreign language interface
Parts or chunks of source code written in an interpreted language can be rewrit-
ten in C or Fortran, and then compiled into a library (dynamic link libraryin MS
Windows®,orshare objectin *NIX^3 platforms). This compiled library can then be
Free download pdf