[R] [FORGED] Error from lme4: "Error: (p <- ncol(X)) == ncol(Y) is not TRUE"

Rolf Turner r.turner at auckland.ac.nz
Thu Sep 24 00:00:50 CEST 2015


On 24/09/15 01:57, Rory Wilson wrote:
> In reply to Rolf Turner and Jean Adams who have been helping me:
>
> This does appear to be an issue with NA values in the non-factor
> variables. In the (non-reproducible) example below, we can see that
> removing the NAs solves the problem. However, from what I can see to
> this point, there does not seem be be rhyme nor reason to why the issue
> is taking place. A slight modification to Rolf Turner's code
> (introducing some NAs) shows that, in general, NAs are not a problem for
> lmer (indeed, it just runs na.omit as default).
>
> Examining which factors are affected by the removal of the NAs shows no
> discernible pattern - no factors disappeared, none became "1" or
> anything of this nature.
> I will be able to proceed just by performing the na.omit beforehand, but
> it is curious.
>
> Thanks for your help everyone (especially Rolf Turner and Jean Adams)!
>
> mod1<-lmer(beta~expData+techVar$RIN+techVar$sample_storage_time+(1|techVar$p_amplification))
> #Error: (p <- ncol(X)) == ncol(Y) is not TRUE

First a pedantic quibble.  The foregoing call to lmer() would be better 
rendered as:

mod1 <- lmer(beta ~ expData + RIN + sample_storage_time
                             + (1|p_amplification), data=techVar)

I.e. Use the "data" argument (!!!) and put *spaces* in your code!

Second, can you not extract a relatively small subset of your data set 
which demonstrates the problem and make that cut-down data set available?

<SNIP>

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-help mailing list