Recently, I was contacted with an question about R code. A befriended researcher was working with nested data, which was unbalanced. He was working with data in a ‘long’ format: all observations nested within the same group had the same identification number. But, the number of observations in each of the groups differed (hence: unbalanced [...]
Posts Tagged ‘R-Sessions’
R-Sessions 31: Combining lmer output in a single table (UPDATED)
There are various ways of getting your output from R to your publication draft. Most of them are highly efficient, but unfortunately I couldn’t find a function that combines the output from several (lmer) models and presents it in a single table. lmer is the mixed effects model function from the lme4 package. So, I [...]
R-Sessions 30: Visualizing missing values
It always takes some time to get a grip on a new dataset, especially large ones. The code-books are often as indispensable as they are massive, and not always as clear as one would want. Routings, and resulting and strange patterns of missing values are at times difficult to find.
I found a nice way to plot missing values, using R. Basically, I thought it would be nice to calculate the percentage of missings on each variable, and do so for each year represented in the data. These numbers could be visualized using a levelplot(), which resulted in the graph below.
R-Sessions 29: Running R-Project twice on Apple Mac OS X
Working with statistics can be quite time consuming. As anyone working with relatively advanced models and large amounts of data knows, especially the waiting can be excruciating. Your statistical software is locked up while crunching those numbers, while you’d actually prefer to run some minor procedures, such as post-estimations, testing some loops, or simply displaying the output of a previously estimated model. With Apple’s Mac OS X you now can run R-Project twice, making the most of your dual core processor.
R-Sessions 28: Impressive R Speeds
Yesterday, I received my new Apple MacBook. It’s running a Core 2 Duo at 2.4 Ghz and it’s fast. Really fast! I tested it with using R-Project, doing some timings on matrix transformations.
Apparently, it’s very cool to show of the speed of R-Project on your system. Optimized .DLL files help to speed up your R on Windows systems (and possibly other systems as well) with respect to matrix transformations, which has led to enormous speed increases. So, let’s perform a speed-test of our own.
R Sessions 26: Text editors for R: Internal editor on OS X

Since R-Project is essentially syntax based, one needs a good text editor to write some code before it is executed in R. And, since we are all writing high quality code, we need a high quality text editor. This is the first in a series on text editors for using with R-Project on MacOSX.
The first editor to look at, is the internal one. The Mac OS X version of R-Project comes with quite a strong, although basic, text editor.
R-Sessions 25: Book – Mixed Effects Models in S and S-PLUS (Pinheiro & Bates, 2000)


Despite the reference to S and S-PLUS in the title of this book, it offers an excellent guide for the nlme-package in R-Project. Reason for this is the close resemblance between R and S. The nlme-package, available in R-Project for estimation of both linear and non-linear multilevel models, is written and maintained by the authors of this book.
R-Sessions 23: Book: Data Analysis Using Regression and Multilevel/Hierarchical Models — Gelman & Hill (2007)
Andrew Gelman is known for his expertise on Bayesian statistics. Based on that knowledge he wrote a book in multilevel regression using R and WINbugs. This book aims to be a thorough description of (multilevel) regression techniques, implementation of these techniques in R and bugs, and a guide on interpreting the results of your analyses. Shortly put, the books excels on all three subjects.
R-Sessions 22: Book: Introductory Statistics with R — Peter Dalgaard (2002)

Peter Dalgaard is associate professor at the Department of Biostatistics at the University of Copenhagen in Denmark, and a member of the R-Project Core Development team. Also, he is an active participating and respected member of the R-help mailing-list. Based on these experiences, he set to write an introductory book on statistics and R.
R-Sessions 21: Multilevel Model Specification (NLME)

Multilevel models, or mixed effect models, can easily be estimated in R. Several packages are available. Here, the lme() function from the nlme-package is described. The specification of several types of models will be shown, using a fictive example. A detailed description of the specification rules is given. Output of the specified models is given, but not described or interpreted.
Please note that this description is very closely related to the description of the specification of the lmer() function of the lme4-package. The results are similar and here exactly the same possibilities are offered.
In this example, the dependent variable is the standardized result of a student on a specific exam. This variable is called “normexam”. In estimating the score on the exam, two levels will be discerned: student and school. On each level, one explanatory variable is present. On individual level, we are taking into account the standardized score of the student on a LR-test (”standLRT”). On the school-level, we take into account the average intake-score (”schavg”).
Influence.ME: an R package providing tools for detecting influential data in mixed models.