Preview

Maximum Likelihood Programming in R

Satisfactory Essays
Open Document
Open Document
363 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Maximum Likelihood Programming in R
Maximum Likelihood Programming in R
Marco R. Steenbergen
Department of Political Science University of North Carolina, Chapel Hill

January 2006

Contents
1 Introduction 2 Syntactic Structure 2.1 Declaring the Log-Likelihood Function . . . . . . . . . . . . . . . . . . . . . . . 2.2 Optimizing the Log-Likelihood . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Output 4 Obtaining Standard Errors 5 Test Statistics and Output Control 2 2 2 4 5 5 7

1

1

Introduction

The programming language R is rapidly gaining ground among political methodologists. A major reason is that R is a flexible and versatile language, which makes it easy to program new routines. In addition, R algorithms are generally very precise. R is well-suited for programming your own maximum likelihood routines. Indeed, there are several procedures for optimizing likelihood functions. Here I shall focus on the optim command, which implements the BFGS and L-BFGS-B algorithms, among others.1 Optimization through optim is relatively straightforward, since it is usually not necessary to provide analytic first and second derivatives. The command is also flexible, as likelihood functions can be declared in general terms instead of being defined in terms of a specific data set.

2

Syntactic Structure

Estimating likelihood functions entails a two-step process. First, one declares the log-likelihood function, which is done in general terms. Then one optimizes the log-likelihood function, which is done in terms of a particular data set. The log-likelihood function and optimization command may be typed interactively into the R command window or they may be contained in a text file. I would recommend saving log-likelihood functions into a text file, especially if you plan on using them frequently.

2.1

Declaring the Log-Likelihood Function

The log-likelihood function is declared as an R function. In R, functions take at least two arguments. First, they require a vector of

You May Also Find These Documents Helpful

  • Better Essays

    QNT/351 Week two paper

    • 977 Words
    • 4 Pages

    References: Lind, D. A., Marchal, W. G., &Wathen, S. A. (2011). Basic statistics for business and…

    • 977 Words
    • 4 Pages
    Better Essays
  • Satisfactory Essays

    This discussion requires you to use the web-based statistical software that we will be using in this course: Stat-Crunch.…

    • 343 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Stat 231 Course Notes

    • 7029 Words
    • 29 Pages

    Estimates and Estimators 5.1 5.2 5.3 5.4 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Maximum Likelihood Estimation (MLE) Algorithm . . . . . . . . . . . . . . . . . . . . . Estimators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Biases in Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .…

    • 7029 Words
    • 29 Pages
    Satisfactory Essays
  • Better Essays

    Duncan Cramer, D. H. (2004). The SAGE Dictionary of Statistics. London, England: Sage Publications. doi:: http://dx.doi.org/10.4135/9780857020123…

    • 1038 Words
    • 3 Pages
    Better Essays
  • Satisfactory Essays

    Mat 540 Quiz 4

    • 1474 Words
    • 6 Pages

    A systematic approach to model formulation is to first construct the objective function before determining the decision variables.…

    • 1474 Words
    • 6 Pages
    Satisfactory Essays
  • Satisfactory Essays

    ADM3628 Fall 14

    • 840 Words
    • 5 Pages

    Statistical techniques have profound applications in almost all areas of modern science, including social and natural sciences. The objective of this course is to provide students with basic understanding of important statistical techniques and help them develop skills to work with statisticians towards appropriate application of these techniques to problems in business and management and interpretation of outputs of statistical software.…

    • 840 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Introduction to Probability and Statistics 14th Edition by Wm. Mendenhall & R. Beaver, Duxbury Press (required)…

    • 668 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Statistics Pga Tour Case

    • 2821 Words
    • 12 Pages

    I certify I, Paul Oliver, participated in the solution of this exam with the other members of my group and I was responsible for the Interpretation of Statistics, and formulation of analysis. Paul Oliver…

    • 2821 Words
    • 12 Pages
    Powerful Essays
  • Good Essays

    The Great Depression, a notorious period marked as the most severe economic downturn in the 1930s, affecting numerous countries, including the United States. Characterized by widespread business failures and a significant influx in unemployment rates, this time period saw countless individuals losing their jobs and property, with little hope for recovery. The Great Depression is estimated to have resulted in the deaths of 5-10 million people. Despite the grim reality, President Franklin D. Roosevelt introduced the New Deal: a series of programs and reforms aimed at alleviating the impact of the Great Depression and restoring the American economy. However, the New Deal has sparked ongoing debates regarding its effectiveness and scope.…

    • 784 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Sky Barragan, daughter of a good friend of mine is the child I observed for this written evaluation. Sky is four years old with a birthday quickly approaching this upcoming July. The observation took place at a local park in Pasadena that Sky frequents quite regularly for play time. We arrived at the park at approximately nine fifty in the morning and left the park at ten thirty. The park is about five acres and located in a quiet neighborhood of Pasadena, CA. It has a playground, basketball courts, handball courts, and plenty of open grass and trees which make for a calm and peaceful setting. The park was fairly empty with a few adults engaging in morning fitness activities, and the playground was empty. The temperature outside was about ninety…

    • 1467 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    Willy Tragic Hero

    • 291 Words
    • 2 Pages

    A tragic hero is a character who in spite of a basic goodness and authority, has a tragic flaw, and because of this fault is destined to fail. A true tragic hero or heroine recognizes his or her flaw/s, but typically not until it is too late to stop to downward spiral. A few examples of tragic heroes and heroines are from the many works of Shakespear. In Death of a Salesman by Arthur Miller, Willy Loman, the tragic hero, has so many flaws that end up in suicide before he has a chance to resolve them.…

    • 291 Words
    • 2 Pages
    Good Essays
  • Good Essays

    STAT 543 Homework

    • 1979 Words
    • 8 Pages

    Problem 2.2.10 Let X 1 ,..., X n denote a sample from a population with one of the following densities or frequency functions. Find the MLE of θ . (a) f ( x, θ ) = θ e −θ x , x ≥ 0;θ > 0. (Exponential density) (b) f ( x, θ ) = θ cθ x − (θ +1) , x ≥ c; c constant>0; θ > 0. (Pareto density) (c) Solution: (a).…

    • 1979 Words
    • 8 Pages
    Good Essays
  • Powerful Essays

    Econ2206- Assignment 1

    • 980 Words
    • 8 Pages

    (h) Suppose that the model in (g) is the true model that satisfies the Gauss-Markov assumptions MLR.1-5. Explain why the estimation results in (e) may not be desirable under this supposition. Comment on the differences in estimated coefficients on log () and log () in (e) and (g).…

    • 980 Words
    • 8 Pages
    Powerful Essays
  • Better Essays

    References: Grow, L., Carr, J., Kodak, T., Jostad, C., & Kisamore, A. (2011.). A Comparison of Methods for…

    • 2066 Words
    • 9 Pages
    Better Essays
  • Powerful Essays

    Hispanic Mental Health

    • 7700 Words
    • 31 Pages

    Kaufman, P., Kwon, J. Y., Klein, S., & Chapman, C. D. (1999). Statistical Analysis Report (NCES Report No. 2000–022).022)Retrieved July 25, 2001http://nces.ed.gov/pubs2000/2000022.pdf.…

    • 7700 Words
    • 31 Pages
    Powerful Essays