[Biomod-commits] error in projections

Wilfried Thuiller wilfried.thuiller at ujf-grenoble.fr
Fri Jul 8 08:36:56 CEST 2011


Hi Raquel,

I have no clue. It sound like the GLM experienced some problems of convergence at some point and does really manage to make a projection. I am just curious, are you sure this is an error message. Sounds more like a warning.

In any case, put GLM=F in projection should then work for that species. 

Note also that such loops over species are not really memory and CPU usage efficient. I understand what you are trying to do but.... Have a look at the snowfall package which allows you to use the different CPUs of your machine (if you have more than one of course) inside a kind of apply function. This is quite efficient and not very complicated to implement. 

Hope it helps,

Wilfried

 

Le 7 juil. 2011 à 11:29, Raquel A. Garcia a écrit :

> Hi,
> 
> I'm getting this error message when I run my projections on future climate data:
> 
> In predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type ==  ... :
>   prediction from a rank-deficient fit may be misleading
> 
> I wonder if anyone can help?  I paste my code below.
> 
> Many thanks,
> 
> Raquel 
> 
> 
> 
> ### CALIBRATION AND VALIDATION ##############################
> 
> path <- "C:/Raquel_Garcia/fourthRun"
> taxa <- c("frogs","snakes","mammals","birds")
> library(BIOMOD)
> source("C:/Raquel_Garcia/ModelsH.r")
> source("C:/Raquel_Garcia/thirdRun/Ensemble.Forecasting.r")
> clim <- c("clust1_4160a2",  "clust2_4160a2",  "clust3_4160a2",  "clust1_4160a1b",
> "clust2_4160a1b", "clust3_4160a1b", "clust1_4160b1",  "clust2_4160b1", 
> "clust3_4160b1",  "clust1_8100a2",  "clust2_8100a2",  "clust3_8100a2", 
> "clust1_8100a1b", "clust2_8100a1b", "clust3_8100a1b", "clust1_8100b1", 
> "clust2_8100b1",  "clust3_8100b1")
> for (tx in 1:4)
>   {
> #dir.create(paste(path, taxa[tx], sep="/"))
> taxapath <- paste(path, taxa[tx],sep="/")
> 
> ### CALIBRATION ################################################################
> setwd(paste(path,"Data",sep="/"))
> species<-read.table(paste(taxa[tx],"_1851cells_spp15.txt",sep=""),h=T,sep="\t")    
> sppnames <- names(species)
> clim6190<-get(load("var6190_1851cells_3var"))      # present climate table
> coor<-read.table(paste("coorXY_1851cells.txt",sep=""),h=T,sep="\t")               
> coorXY <- coor[,2:3]
> 
> for (f in 1:length(sppnames))
>   {
>   dir.create(paste(taxapath, "/", sppnames[f], sep=""))
>   setwd(paste(taxapath, "/", sppnames[f], sep=""))
> 
>   Initial.State(Response=species[,f], Explanatory=clim6190[,4:6], IndependentResponse=NULL, IndependentExplanatory=NULL,sp.name=sppnames[f])
>   ModelsH(GLM = T, TypeGLM = "poly", Test = "AIC", GBM = T, No.trees = 2000, GAM = T,
>   Spline = 3, CTA = F, CV.tree = 50, ANN = T, CV.ann = 5, SRE = F, q=0.0025, FDA = T,
>   MARS = T, RF = T, NbRunEval = 5, DataSplit = 75, Yweights=NULL, Roc = T, Optimized.Threshold.Roc = T,
>   Kappa = F, TSS=T, KeepPredIndependent = F, VarImport=5, NbRepPA=2, strategy="random",
>   coor=coorXY, nb.absences=1/3(dim(species)[1]))
> # saving Pseudo-Absence data
> save(Biomod.PA.data, file=paste(Biomod.material$species.names, "PAdata", sep="_"))
> save(Biomod.PA.sample, file=paste(Biomod.material$species.names, "PAsample", sep="_"))
> ### PREDICTIONS ################################################################
>   #Predictions on the original dataset 
> 
>   CurrentPred(GLM=T, GBM=T, GAM=T, CTA=F, ANN=T, SRE=F, FDA=T, MARS=F, RF=T,
>   BinRoc=T, BinKappa=F, BinTSS=T, FiltKappa=F)
>   PredictionBestModel(GLM=T,GBM=T, GAM=T, CTA=F, ANN=T, FDA=T, MARS=F, RF=T, SRE=F,
>   method='all', Bin.trans = T, Filt.trans = T)
> # saving evaluation results
>   save(Evaluation.results.TSS,file=paste("eval.TSS","_",Biomod.material$species.names,sep=""))
>   save(Evaluation.results.Roc,file=paste("eval.ROC","_",Biomod.material$species.names,sep=""))
> 
> # saving VarImportance
> 
>   save(VarImportance,file=paste("VarImportance","_",Biomod.material$species.names,sep=""))
> 
> ### CURRENT PROJECTIONS #########################################################
> 
>   Projection(Proj = clim6190[,4:6], Proj.name='CurrentF',
>   GLM = T, GBM = T, GAM = T, CTA = F, ANN = T, SRE = F, q=0.0025, FDA =T, MARS = T,
>   RF = T, BinRoc=T, BinKappa=F, BinTSS=T, FiltRoc=T, FiltKappa=F, FiltTSS=T, repetition.models=T)
>   Ensemble.Forecasting(Proj.name= "CurrentF", weight.method='TSS', PCA.median=T,
>   binary=T, bin.method='TSS', Test=T, decay=1.6, repetition.models=T, final.model.out=F)
> ### FUTURE PROJECTIONS #########################################################
>   for (d in 1:18)        
>       {
>       future <- read.table(paste(datapath, "/", clim[d], "_3var.txt", sep=""), header=T, sep="\t")
>       Projection(Proj = future, Proj.name=paste(clim[d],"F",sep=""), GLM = T, GBM = T, GAM = T,
>       CTA = F, ANN = T, SRE = F, q=0.0025, FDA =T, MARS = T, RF = T,
>       BinRoc = T, BinKappa = F, BinTSS = T, FiltRoc = T, FiltKappa = F, FiltTSS = T,
>       repetition.models=T)
>       ProjectionBestModel(Proj.name=paste(clim[d],"F",sep=""), Bin.trans=T, Filt.trans=T, method='all')
> ### ENSEMBLE FORECASTING (SDMs) ################################################
>       Ensemble.Forecasting(Proj.name= paste(clim[d],"F",sep=""), weight.method='TSS', PCA.median=T,
>       binary=T, bin.method='TSS', Test=T, decay=1.6, repetition.models=T, final.model.out=F)
>       }
> ### CLEANING UP ################################################################
> 
> # saving workspace
> save.image(file=paste(sppnames[f],"_workspace.RData",sep=""))
> 
> # remove objects not needed
>   t= c("path", "taxapath", "datapath", "sppnames", "varlist", "species", "clim6190", "coorXY", "ModelsH", "Ensemble.Forecasting")      
>   Rem = ls()
>   rm(list=(Rem[is.na(match(Rem, t))]))
> 
>   }
> } 
> 
> ................
> Raquel A. Garcia
> Integrative Biology and Global Change Group
> www.ibiochange.mncn.csic.es_______________________________________________
> 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
Personal website: http://www.will.chez-alice.fr
Team website: http://www-leca.ujf-grenoble.fr/equipes/emabio.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/20110708/9249ea7a/attachment.htm>


More information about the Biomod-commits mailing list