[R] Problem with simple random slope in gam and bam (mgcv package)

Martijn Wieling wieling at gmail.com
Wed Nov 9 13:41:46 CET 2011

Dear useRs,

This is the first time I post to this list and I would appreciate any
help available. I've used the excellent mgcv package for a while now
to investigate geographical patterns of language variation, and it has
has always worked without any problems for me. The problem below
occurs using R 2.14.0 (both 32 and 64 bit versions in Windows and the
64 bit version in Unix) and mgcv (both version 1.7-10 and 1.7-6).

In my (simplified) model predicting pronunciation distance I'd like to
include a random slope per Participant for a binary value (IsDem)
which stores a word-specific characteristic. I load the data
(available at http://www.martijnwieling.nl/dat.csv) and run the model
as follows:

> library(mgcv) # version 1.7-10, but problem also occurs with earlier versions (e.g., 1.7-6)
> dat = read.csv('dat.csv',header=T) # data available at: http://www.martijnwieling.nl/dat.csv
> dim(dat) # the original dataset is larger, but the problem also occurs in this subset
[1] 20000     4
> model = bam(PronDist ~ s(Participant,IsDem,bs="re"), data=dat)
> print(model) # works fine
> summary(model, freq=T) # works fine
> summary(model) # the Bayesian p-value estimation does not work:
Error in eigen(B, symmetric = TRUE) : infinite or missing values in 'x'

I obviously am interested in more complex models, but whenever I
include any binary value as a by-word or by-participant random slope I
get the same error. I've tried to locate the error and it appears to
occur in the function pinvXVX in the block which 'deals with the
fractional part of the pinv'.

Any help would be appreciated!

With kind regards,

Martijn Wieling
University of Groningen

More information about the R-help mailing list