[Biomod-commits] Factors as predictive variables

Wilfried Thuiller wilfried.thuiller at ujf-grenoble.fr
Tue Jun 22 07:47:14 CEST 2010


Dear Peter,
I have checked and I am not sure what's happening with your data. BIOMOD does work with factor variables. 

library(BIOMOD)
data(Sp.Env)
Cat <- c(rep(0, nrow(Sp.Env)/2), rep(1, nrow(Sp.Env)/2))
Cat <- as.factor(Cat[sample(nrow(Sp.Env))])
Sp.Env$Cat <- Cat

Initial.State(Response=Sp.Env[,11:12], Explanatory=Sp.Env[,c(4:6,19)])	

Models(GLM = TRUE, TypeGLM = "quad", Test = "AIC", GBM = TRUE, No.trees = 3000, GAM = TRUE, CTA = TRUE, CV.tree = 50, ANN = TRUE, CV.ann = 2, SRE = TRUE, quant=0.05, FDA = TRUE, MARS = TRUE, RF = TRUE, NbRunEval = 2, DataSplit = 80,Yweights=NULL, Roc=TRUE, Optimized.Threshold.Roc=TRUE, Kappa=TRUE, TSS=TRUE, KeepPredIndependent = FALSE, VarImport=5,NbRepPA=0, strategy="circles", coor=CoorXY, distance=2, nb.absences=1000)

It works perfectly fine, excepted MARS and SRE which are turned off because they do not handle factor variables. 


Do you have the latest version of R and BIOMOD? 

Wilfried





Le 7 juin 2010 à 18:01, Wilfried Thuiller a écrit :

> Dear Peter,
> This is supposed to work indeed. I need to have a look. It seems the GAM function does not work with the categorical variables whereas I thought I had previously removed that problem. 
> 
> A sexy alternative is to transform your categorical variable in n-1 binary variables. This is actually what the models do but hidden. 
> In your case, you just need one variable GRASS coded in 0 when there is forest and 1 when there is grassland. 
> Use this binary variable as continuous into the models. 
> 
> HIH
> Wilfried
> 
> 
> Le 31 mai 2010 à 13:08, <Horchler at bafg.de> <Horchler at bafg.de> a écrit :
> 
>> Hello,
>> 
>> I am wondering if I can use factorial vairables in BIOMOD?
>> I want to include type of land-use codes as "grassland" or "forest" in
>> my analysis but get an error message:
>> 
>> ----------------------------------- 
>> Modelling summary 
>> ----------------------------------- 
>> Number of species modelled :            6
>> Alopprat, Urtidioi, Glycmaxi, Rubucaes, Crxacuta, Rorisylv
>> 
>> numerical variables :                   UFD.n, vmhq, Hum, S
>> factorial variables :                   Nutzung
>> 
>> number of evaluation repetitions :      0
>> number of pseudo-absences runs :        0
>> models selected :                       GAM, GBM, GLM, RF
>> total number of model runs :            24
>> ----------------------------------- 
>> 
>> 
>> #####                    Alopprat                       #####
>> Model=GAM spline 
>>         3  Degrees of smoothing 
>> Fehler in Summary.factor(c(1L, 1L, 1L, 1L, 1L, 3L, 3L, 1L, 1L, 1L, 3L,
>> : 
>>  sum not meaningful for factors
>> 
>> 
>> 
>> What can I do about this?
>> 
>> Thnaks in advance!
>> Peter
>> _______________________________________________
>> Biomod-commits mailing list
>> Biomod-commits at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits
> 
> --------------------------
> Dr. Wilfried Thuiller
> Laboratoire d'Ecologie Alpine, UMR CNRS 5553
> Université Joseph Fourier
> BP53, 38041 Grenoble cedex 9, France
> tel: +33 (0)4 76 51 44 97
> fax: +33 (0)4 76 51 42 79
> 
> Email: wilfried.thuiller at ujf-grenoble.fr
> Home page: http://www.will.chez-alice.fr
> Website: http://www-leca.ujf-grenoble.fr/equipes/tde.htm
> 
> FP6 European MACIS project: http://www.macis-project.net
> FP6 European EcoChange project: http://www.ecochange-project.eu
> 
> 
> 
> 
> 
> _______________________________________________
> Biomod-commits mailing list
> Biomod-commits at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits

--------------------------
Dr. Wilfried Thuiller
Laboratoire d'Ecologie Alpine, UMR CNRS 5553
Université Joseph Fourier
BP53, 38041 Grenoble cedex 9, France
tel: +33 (0)4 76 51 44 97
fax: +33 (0)4 76 51 42 79

Email: wilfried.thuiller at ujf-grenoble.fr
Home page: http://www.will.chez-alice.fr
Website: http://www-leca.ujf-grenoble.fr/equipes/tde.htm

FP6 European MACIS project: http://www.macis-project.net
FP6 European EcoChange project: http://www.ecochange-project.eu





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/biomod-commits/attachments/20100622/1a3601be/attachment.htm>


More information about the Biomod-commits mailing list