[R-sig-ME] Factor conversion

Jarrod Hadfield j.hadfield at ed.ac.uk
Wed Jun 8 06:31:28 CEST 2011


Hi, 

The argument to as.is has a spelling mistake perhaps: "bithrcoef" should
read "brithrcoef"?

You could also try as.numeric(as.character(x))

Jarrod




On Tue, 2011-06-07 at 23:14 +0100, Iker Vaquero Alba wrote:
> 
>    Dear R list:
> 
>    I am fitting a model where I have several covariates which are coefficients 
> of variation. For some reason, the software interprets them as factors. I was 
> converting them with the function "as.numeric", but when doing so, the variable 
> is converted into an ordinal categorical one.
>    I have tried the “as.is” function but I get this message:
>  
> In read.table("Coefvar insects 2009+2010.txt", header = T, as.is = "bithrcoef") 
> :
>   not all columns named in 'as.is' exist
>  
>    Could you tell me wich is the most suitable converting function I should use? 
> I’ve tried “as.vector” and “as.character”, but I get this error messages when 
> fitting the model with lme or lmer:
>    With lmer:
>    
> “insectmodel2<-lmer(inslarge~tlengthcoef+brivencoef+brithrcoef+condcoef+sex+tlengthcoef:sex+brivencoef:sex+brithrcoef:sex+condcoef:sex+tlengthcoef:brivencoef+tlengthcoef:brithrcoef+tlengthcoef:condcoef+brivencoef:brithrcoef+brivencoef:condcoef+brithrcoef:condcoef+(1|year))”
> 
>    Error in mer_finalize(ans) : Downdated X'X is not positive definite, 35.
> Also: lost warning messages
> 1: In model.matrix.default(mt, mf, contrasts) :
>   variable 'tlengthcoef' converted to a factor
> 2: In model.matrix.default(mt, mf, contrasts) :
>   variable 'brivencoef' converted to a factor
> 3: In model.matrix.default(mt, mf, contrasts) :
>   variable 'brithrcoef' converted to a factor
> 4: In model.matrix.default(mt, mf, contrasts) :
>   variable 'condcoef' converted to a factor
>  
>    With lme:  
>    
> “insectmodel2<-lme(inslarge~tlengthcoef+brivencoef+brithrcoef+condcoef+sex+tlengthcoef:sex+brivencoef:sex+brithrcoef:sex+condcoef:sex+tlengthcoef:brivencoef+tlengthcoef:brithrcoef+tlengthcoef:condcoef+brivencoef:brithrcoef+brivencoef:condcoef+brithrcoef:condcoef,random=~1|year)”
> 
> Error in MEEM(object, conLin, control$niterEM) : 
>   Singularity in backsolve at level 0, block 1
> Also: Lost warning messages
> 1: In model.matrix.default(fixed, data = X) :
>   variable 'tlengthcoef' converted to a factor
> 2: In model.matrix.default(fixed, data = X) :
>   variable 'brivencoef' converted to a factor
> 3: In model.matrix.default(fixed, data = X) :
>   variable 'brithrcoef' converted to a factor
> 4: In model.matrix.default(fixed, data = X) :
>   variable 'condcoef' converted to a factor
>  
> 
>    Any help will be greatly appreciated.
>  
>    Thank you very much. Iker
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.




More information about the R-sig-mixed-models mailing list