Home » R-Project » Recent Articles:

Index of the R-Sessions

thumbnail-1209

The R-Sessions are a series of blog entries on using R. A large part consists of an R-manual I once wrote. Other posts include some tricks I found out, as well as entries detailing functions and packages I wrote for R. The series already entails over forty posts, so I decided to create an index. It is found below. On a fixed page on this website (www.rensenieuwenhuis.nl/r-project/r-sessions-index/) I will continue to update this index with new editions of the R-Sessions.

… Continue Reading

R Sessions 33: Select (nested) observations with equal number of occurences

September 23, 2009 R-Project, R-Sessions No Comments
thumbnail-1107

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 data).

He asked me for a piece of code that creates a subset of the data that is balanced, i.e. all observations that are nested within equally sized groups. Or, as an alternative, all observations nested within groups with at least a minimum number of observations.

I solved it the quick and dirty way, and the solution involves creating additional variables, a new data.frame, and merging. It sure can be done much prettier, but it works.

So, I share it below:
… Continue Reading

Influence.ME: Simple Analysis

July 16, 2009 Influence.ME No Comments
thumbnail-1015

With the introduction of our new package for influential data influence.ME, I’m currently writing a manual for the package. This manual will address topics for both the experienced, and the inexperienced users.

I will also present much of the content of this manual on my blog. Of course, feel free to comment on it, and readers are encouraged to discuss the content of the manual here. All information will be accessible from the influence.ME website as well. Note that updates to the manual will be made available on that website”, instead of updating this blog post. So, please refer to the influence.ME website for the most up-to-date information.

This is the first section on influence.ME, which deals with a very simply analysis of students nested within 23 schools. Only the effect of a single variable measured at the school level is estimated.

… Continue Reading

Presenting influence.ME at useR!

July 10, 2009 Influence.ME 2 Comments

Logo influence.ME

Today I presented influence.ME at the useR! conference in Rennes. Influence.ME is an R package for detecting influential data in mixed models. I developed this package together with Ben Pelzer and Manfred te Grotenhuis.

More information about influence.ME can be found on another section of my website.

Below, please find the slides of the presentation.
Presentation Influence.ME at Rennes, useR! 2009

Influence.ME: don’t specify the intercept

June 18, 2009 Influence.ME No Comments

Just recently, I was contacted by a researcher who wanted to use influence.ME to obtain model estimates from which iteratively some data was deleted. In his case, observations were nested within an area, but there were very unequal numbers of observations in each area.

Unfortunately, he wasn’t able to use the influence.ME package on his models. He kindly sent me his data, so I could figure out what went wrong, and it showed to be a little problem with influence.ME.

The problem was with how the model was specified: the intercept was explicated, next to several (fixed) variables. It turned out, that such a model specification is not compatible with the internal changes made to the mixed model. Therefore, I advise users of influence.ME not to explicitly specify the intercept in their lme4 regression models.

I reproduced the problem with the school23 data, which is available in influence.ME. Compare the two model specifications below: in the first the intercept is specified, in the second it isn’t. The outcomes of both lmer models are identical. However, the first returns a convergence error when used with the estex() function, while the second doesn’t.

The input:

mod <- lmer(math ~ 1 + structure + (1 | school.ID), data=school23)
estex.mod <- estex(mod, "school.ID")

mod <- lmer(math ~ structure + (1 | school.ID), data=school23)
estex.mod <- estex(mod, "school.ID")

The output:

> mod <- lmer(math ~ 1 + structure + (1 | school.ID), data=school23)
> estex.mod <- estex(mod, "school.ID")
Error in mer_finalize(ans) : Downdated X'X is not positive definite, 3.
>
> mod <- lmer(math ~ structure + (1 | school.ID), data=school23)
> estex.mod <- estex(mod, "school.ID")

I will surely investigate whether this can be resolved in a future update, but for now, simply leave the intercept out of your model specification: lmer will add it for you.


Influence.ME is an R package and provides tools for detecting influential data in mixed effects models. More information can be found here.

One outlier and you’re out: Influential data and racial prejudice

June 16, 2009 Influence.ME 4 Comments

ResearchBlogging.org
Currently preparing a presentation on analyzing influential data in mixed effects models myself, my eye fell on an article in which important claims on racial prejudice were refuted. An important aspect of the criticism on existing work, is that in one article the main correlation was completely due to a single observation. Solely based on this single observation, the study’s outcomes showed the Implicit Association Test (IAT) to predict overall interaction quality between White or Black people. Removing that single observation (out of 41) from the data removed the complete effect.

With survey research showing declines in “American’s endorsement of prejudice sentiments” (p.568), the question rose whether such declines actually took place, or that they are an artifact of social desirability determining respondents’ responses to survey questions. Naturally, tests like the Implicit Association Test (IAT) gained considerable attention, for the attractive claim of such tests is to be able to show levels of prejudice that people themselves are unaware of and which do not show when asked about explicitly (e.g. in a survey).
… Continue Reading

Introducing Influence.ME: Tools for detecting influential data in mixed models

April 29, 2009 Influence.ME No Comments
thumbnail-914

I’m highly excited to announce that influence.ME is now available. Influence.ME is a new software package for R, providing statistical tools for detecting influential data in mixed models. It has been developed by Rense Nieuwenhuis, Ben Pelzer, and Manfred te Grotenhuis. The basic rationale behind identifying influential data is that when iteratively single units are omitted from the data, models based on these data should not produce substantially different estimates. To standardize the assessment of how influential data is, several measures of influence are commonly used, such as DFBETAS and Cook’s Distance.

… Continue Reading

useR! 2009 acceptance: presenting influence.ME

Logo influence.ME

The organizing committee of the useR! 2009 conference just informed me, that my submission for presenting my extension package influence.ME, has been accepted! Influence.ME is a new R package that I’m currently developing, with the indispensable help of Ben Pelzer and Manfred te Grotenhuis. Although I did not yet introduce influence.ME on this blog, rest assured that I will do so within just a few weeks. Now is time for celebration!
… Continue Reading

R-Sessions 32: Forward.lmer: Basic stepwise function for mixed effects in R

February 13, 2009 R-Project, R-Sessions 6 Comments

Intended to be a customized solution, it may have grown to be a little more. forward.lmer is an early installment of a full stepwise function for mixed effects regression models in R-Project. I may put in some work to extend it, or I may not. Nevertheless, in a ‘forward sense of stepwise’, I think it can be pretty useful as it is. Also, it has an interesting take on the stepwise concept, I think.

… Continue Reading

R-Sessions 31: Combining lmer output in a single table (UPDATED)

February 5, 2009 R-Project, R-Sessions 1 Comment


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 wrote a simple function that does exactly that.
… Continue Reading

Welcome to Curving Normality

Curving Normality is an academic blog maintained by Rense Nieuwenhuis. He uses this blog to write about the social sciences in general, fascinating journal papers, useful data, interesting books, statistics using R. In addition, his personal academic activities are shared here, as well.