plm: nouvelles fonctionnalités

2007-04-06 by librecono

Il y a quelque temps, j’ai parlé du package plm, qui propose des otuils pour l’estimation de modèles de panel sous R. Récemment, lors d’une mise à jour de R, je viens de constater que le package plm a fait certains progrès. Il est dorénavant possible d’estimer des matrices de covariance robustes, à la White. Une autre nouveauté est l’introduction d’estimateurs pour modèles dynamiques à la ArellanoBond. Ces estimateurs sont disponibles via la fonction pgmm (General method of moments estimator for panel data). Affaire à suivre … ;-)

Econométrie des panels avec R: un exemple

2007-01-29 by librecono

Ici nous allons reproduire le tableau 10.2 page 326 du livre de Marno Verbeek, A Guide to Modern Econometrics, à l’aide du logiciel R. Hormis, ce logiciel , les prérequis pour bien suivre tout ceci sont les suivants:

  • Disposer du fichier de données males.csv
  • Disposer du package plm

La suite est expliquée dans ce petit script. Lisez bien les commentaires avant de poursuivre.

15 manières pour utiliser R

2006-12-27 by librecono

Dirk Eddelbuettel nous propose un aperçu intéressant de 15 manières différentes pour utiliser R:

Use R! in fifteen different ways: A survey of R front-ends in Quantian (pdf, 1.5MB)

Comme le titre l’indique, ces 15 interfaces sont disponibles via Quantian, un Live-DVD Linux. Attention quand même, cette présentation ne s’intéresse pas uniquement aux “clickodrômes” (GUI). On y retrouve aussi des interfaces avec d’autres langages de programmation, des interfaces web et le célèbre ESS. Il ne s’agit pas non plus d’une sélection d’interfaces réservées aux utilisateurs de Linux. En effet, la plupart des outils présentés sont disponibles pour d’autres systèmes comme Windows et Mac.

Les personnes intéressées par un clickodrôme sont invitées à consulter la page suivante sur le wiki de R:

I would like to use R with a GUI, where do I find one?

Sinon une liste plus complète peut être consultée ici:

R GUI Projects

Using Spreadsheets to Create LaTeX Tables

2006-12-27 by librecono

Creating tables in LaTeX may become quite difficult and cumbersome, especially for big tables and tables that have a more complicated structure. A spreadsheet can come in handy at this point. Indeed, there are tools that can translate spreadsheet tables into LaTeX code. Thus you can create the table in a nearly WYSIWIG way and collect the LaTeX code at the end of the day. Here are three ways to create LaTeX tables by using a spreadsheet.

Gnumeric

In Gnumeric, a table can directly be saved in LaTeX format (.tex). This option is availabe under the “File -> Save As” Menu. There are two possibilities. First, you can save it as a standalone LaTeX document. With this option, the table’s formatting is preserved (bold text, merged cells, …). Second you can save the file as a “table fragment”. This gives only minimal LaTeX code to be insetrted into a “tabular” environment. If you decide to go this way, you will loose all the formatting you may have applied in Gnumeric.

OpenOffice.org Calc

As opposed to Gnumeric, there is no “Save As LaTeX” option in OpenOffice.org Calc. However, there is a macro, Calc2LaTeX, that allows to convert a table into LaTeX code. The code can be copied to the clipboard or can be written into anew file. Calc2LaTeX preserves the formatting and makes available a dialogue box to customize the outputted LaTeX code. Installation and usage instructions can be found on the Calc2LaTeX homepage.

Microsoft Excel

If you are using MS Excel, you may be interested in the Excel2LaTeX macro. It is quite similar to Calc2LaTeX, but less universal, as it is a “Microsoft only” solution …

KSpread

I am not aware if a similar tool exists in KSpread, the spreadsheet appplication of KOffice. If you know more, just drop me a line.

plm: modèles de panel avec le logiciel R

2006-12-07 by librecono

Le package plm, écrit par Yves Croissant, offre une boîte à outils intéressante pour l’estimation de modèles de panel sous R. Bien sûr, il y a des packages comme nlme ou lmer qui permettent à priori d’estimer ce genre de modèles et bien plus. Et ces packages existent depuis un moment. Or, plm s’adresse plutôt à un public d’économètres ou de personnes familières avec le jargon économétrique.

Le noyau du package plm est une fonction homonyme. Elle permet d’estimer toute une panoplie de modèles sur des panels cylindrés et non-cylindrés. On retrouve aussi des routines pour effectuer des tests de spécification dont notamment le test de Hausman. Finalement, plm offre aussi des fonctions utiles et pratiques pour la manipulation des données de panel.

Le package est bien documenté. Il contient notamment un document d’une vigntaine de page qui explique de manière tout à fait claire comment utiliser plm. Ce document est disponible en anglais et en fraçais. Une fois que le package est installé, le document peut-être consulté en utilisant la commande suivante:

vignette(“plmFR”)

pour la version française, ou

vignette(“plmEN”)

pour la version anglaise.

Bien entendu, ces “vignettes” ne remplacent en aucun cas un bon livre, repspectivement un bon cours sur l’économétrie des panels.

plm est disponible sur CRAN et peut donc être installé directement à partir de R. Sinon, on retrouve tout ce qu’il faut sur la page CRAN dédiée à plm.

Alternativement, plm est diponible via les CRAN Task Views, et plus précisément via le paquet Econometrics.

06/04/2007: Quelques nouveautés!

Télécharger et convertir des fichiers de données avec R

2006-08-06 by librecono

Voici une petite recette de cuisine pour télécharger et convertir des fichiers de données sous R. Nous allons télécharger un jeu de données utilisé dans le livre de Marno Verbeek, A Guide to Modern Econometrics. Il s’agit des données utilisées dans le chapitre 10, “Models Based on Panel Data”. Evidemment, on pourrait télécharger les fichiers en question à l’aide d’un fureteur et l’enregistrer quelque part sur son ordinateur. Ici nous allons demander à R de s’occuper de cette manip. Voyons un peu …

Le fichier en question s’apelle “males.dta”. Par ailleurs, Marno Verbeek nous fournit une petit description de ce jeu de données dans un fichier appelé “males.txt”. Plus précisément, nous allons passer par les étapes suivantes:

  1. Télécharger le jeu de données
  2. Télécharger la documentation qui va avec
  3. Importer les données sous R
  4. Afficher la documentation
  5. Regarder la structure du jeu de données
  6. Faire une manip sur les noms des variables
  7. Exporter les données en format csv

Toutes les comamndes requises sont disponibles sous forme d’un petit script. Le fichier contient aussi toute une série de commentaires sur les différentes opérations. Ce fichier peut être affiché dans un éditeur de texte. Vous pouvez aussi lancer R, et lui demander d’exécuter les commandes en tapant:

source(url(“http://librecono.googlepages.com/dlco1.r”))

Using Perl for Statistics

2006-08-04 by librecono

I have recently read an interesting paper by Giovanni Baiocchi on how to use Perl in Data Processing and Statistical Computing. It contains quite a few examples and code snippets, making it a nice ressource to learn the Perl language.

Abstract:

In this paper we show how Perl, an expressive and extensible high-level programming language, with network and object-oriented programming support, can be used in processing data for statistics and statistical computing. The paper is organized in two parts. In Part I, we introduce the Perl programming language, with particular emphasis on the features that distinguish it from conventional languages. Then, using practical examples, we demonstrate how Perl’s distinguishing features make it particularly well suited to perform labor intensive and sophisticated tasks ranging from the preparation of data to the writing of statistical reports. In Part II we show how Perl can be extended to perform statistical computations using modules and by “embedding” specialized statistical applications. We provide example on how Perl can be used to do simple statistical analyses, perform complex statistical computations involving matrix algebra and numerical optimization, and make statistical computations more easily reproducible. We also investigate the numerical and statistical reliability of various Perl statistical modules. Important computing issues such as ease of use, speed of calculation, and efficient memory usage, are also considered.

Reference:

Baiocchi, G. (2004), Using Perl for Statistics: Data Processing and Statistical Computing, Journal of Statistical Software, 11(1).

Download the Paper (pdf, 1.1MB)

DiNardo-Fortin-Lemieux Decomposition in Stata

2006-07-23 by librecono

Thanks to João Pedro Azevedo, there is a routine called -dfl- to do a DiNardo-Fortin-Lemieux decomposition in Stata. Unfortunately, this routine is only available for Stata 8 or higher. Yes, I know, Stata has meanwhile released version 9, but there are still quite a few among us that are using Stata 7 (or less), for any reason whatsoever. Here I provide some “rough” code to do the DFL decomposition in Stata 7 (I don’t know if it will work under a lower version …).

Here is the reference for the DFL paper:

J. DiNardo, N. Fortin and T. Lemieux, 1996, “Labor Market Institutions and the Distribution of Wages, 1973-1992 : A Semiparametric Analysis”, Econometrica, Vol. 64, September, pp.1001-1044

 

The script can be downloaded here: dfl7.do. Some comments are included.

There are also routines for other related techniques that may be relevant if you are interested in decompositions of outcome differentials (such as e.g. wages):

  • oaxaca Blinder-Oaxaca decompositions
  • decomp an alternative for Blinder-Oaxaca decompositions
  • decompose Blinder-Oaxaca decompositions for Stata 7
  • jmpierce Juhn-Murphy-Pierce decompositions
  • jmpierce2 Juhn-Murphy-Pierce trend decompositions
  • smithwelch Smith and Welch (1989) trend decompositions
  • fairlie Nonlinear decomposition of binary outcome differentials

Note that these routines require Stata 8.2 or higher. If your computer is connected to the Internet, the easiest and safest way to install the routines mentionned here is to use Stata’s -ssc- command. For example, if you want to install the -oaxaca- package, you have to type the following command in Stata:

ssc install oaxaca

and likewise for the other packages.