[R] Error: length(f1) == length(f2) is not TRUE (fwd)

A Singh Aditi.Singh at bristol.ac.uk
Fri Sep 18 20:25:38 CEST 2009



---------- Forwarded Message ----------
Date: 18 September 2009 19:24 +0100
From: A Singh <bzwas at bristol.ac.uk>
To: William Dunlap <wdunlap at tibco.com>
Subject: RE: [R] Error: length(f1) == length(f2) is not TRUE

Yup, they are all factors- and its still doesn't work.
Getting to the stage where I can use 'summary()' is the problem- the error
stalls the process before a summary can be output.

I tried the same code, but using 'family' and P1L55 as independent random
factors, and that works.

(I actually tried this with a new marker P1L74)

> try(fit<-lmer(peg.no~1 + (1|family) + (1|P1L74), na.action=na.exclude))
> summary(fit)

Linear mixed model fit by REML
Formula: peg.no ~ 1 + (1 | family) + (1 | P1L74)
  AIC  BIC logLik deviance REMLdev
 2981 2997  -1487     2976    2973
Random effects:
 Groups   Name        Variance Std.Dev.
 family   (Intercept) 87.86380 9.37357
 P1L74    (Intercept)  0.48815 0.69868
 Residual             92.11681 9.59775
Number of obs: 390, groups: family, 57; P1L74, 2

Fixed effects:
            Estimate Std. Error t value
(Intercept)    96.40       1.49   64.71

..but the nested random effect ..(1|family/P1L74).. is where the error
occurs. And its the same error.

Error : length(f1) == length(f2) is not TRUE
In addition: Warning messages:
1: In P1L55:family :
  numerical expression has 390 elements: only the first used
2: In P1L55:family :
  numerical expression has 390 elements: only the first used

My design is a very unbalanced one. Do you think that can be the problem?




--On 18 September 2009 09:11 -0700 William Dunlap <wdunlap at tibco.com> wrote:

> Look at the output of summary(vcdf) and make sure
> that 'family' and 'P1L55' columns are factors.  Perhaps
> columns 4:13 did not include them.
>
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
>
>> -----Original Message-----
>> From: A Singh [mailto:Aditi.Singh at bristol.ac.uk]
>> Sent: Friday, September 18, 2009 9:03 AM
>> To: William Dunlap; r-help at r-project.org
>> Subject: RE: [R] Error: length(f1) == length(f2) is not TRUE
>>
>> Hi Bill,
>>
>> Thanks, I did try out what you suggested but it doesn't seem to work.
>> I get the same error again.
>>
>> There's obviously something here that I don't get. Need to
>> figure it out.
>>
>> Aditi
>>
>> --On 18 September 2009 08:34 -0700 William Dunlap
>> <wdunlap at tibco.com> wrote:
>>
>> >> From: r-help-bounces at r-project.org
>> >> [mailto:r-help-bounces at r-project.org] On Behalf Of A Singh
>> >> Sent: Friday, September 18, 2009 4:42 AM
>> >> To: r-help at r-project.org
>> >> Subject: [R] Error: length(f1) == length(f2) is not TRUE
>> >>
>> >>
>> >> Dear R users,
>> >>
>> >> I am trying to fit an lmer model with only random effects
>> >> which is giving
>> >> me the following error:
>> >>
>> >> Error : length(f1) == length(f2) is not TRUE
>> >> In addition: Warning messages:
>> >> 1: In P1L55:family :
>> >>   numerical expression has 390 elements: only the first used
>> >> 2: In P1L55:family :
>> >>   numerical expression has 390 elements: only the first used
>> >>
>> >>
>> >> I am trying to extract variance components for a phenotype
>> >> 'peg.no', using
>> >> the variable 'family' and a marker column 'P1L55' (which is
>> >> categorical and
>> >> has 2 levels- 0 and 1), as random effects. There are no
>> fixed effects.
>> >>
>> >> The code I used is as follows:
>> >>
>> >> vc<-read.table(...)
>> >>
>> >> vcdf<-data.frame(vc)
>> >> colms<-(vc)[4:13] ##these are the markers
>> >> lapply(colms,factor)
>> >
>> > Note that you did not change columns 4:13 of vcdf to factors:
>> > you changed copies of them to factors.  Do
>> >    vcdf[4:13] <- lapply(vcdf[4:13], factor)
>> > and lmer should be happier.
>> >
>> > Bill Dunlap
>> > TIBCO Software Inc - Spotfire Division
>> > wdunlap tibco.com
>> >
>> >>
>> >> try(fit<-lmer(peg.no~1 + (1|family/P1L55),
>> >> na.action=na.include, data=vcdf))
>> >>
>> >>
>> >> I thought that putting the data into a dataframe would help,
>> >> along with the
>> >> na.exclude command, because there is a lot of missing data in
>> >> patches which
>> >> I have replaced with NA's, but I  don't know how to fix this
>> >> error at all.
>> >>
>> >> Its a bit urgent, and any help is hugely appreciated.
>> >>
>> >> The data files are at:
>> >>
>> >>
>> >> <http://www.4shared.com/file/131980362/460bdafe/Testvcomp10.ht
>> >> ml> (excel)
>> >> http://www.4shared.com/file/131980512/dc7308b/Testvcomp10.html
>> >> (txt)
>> >>
>> >>
>> >> Cheers,
>> >> Aditi
>> >>
>> >> ----------------------
>> >> A Singh
>> >> Aditi.Singh at bristol.ac.uk
>> >> School of Biological Sciences
>> >> University of Bristol
>> >>
>> >> ______________________________________________
>> >> R-help at r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide
>> >> http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >>
>>
>>
>>
>> ----------------------
>> A Singh
>> Aditi.Singh at bristol.ac.uk
>> School of Biological Sciences
>> University of Bristol
>>
>>
>>
>>
>>



----------------------
A Singh
Aditi.Singh at bristol.ac.uk
School of Biological Sciences
University of Bristol




---------- End Forwarded Message ----------



----------------------
A Singh
Aditi.Singh at bristol.ac.uk
School of Biological Sciences
University of Bristol




More information about the R-help mailing list