Skip to content

dismo predict and glm binomial error

2 messages · Ben Weinstein, Robert J. Hijmans

#
Hello all,

I'm developing ecological niche models and i'd like to use a
simple glm framework, following the vignette published for the package
"dismo".

Everything works fine, except the predict function creates cell values
that vary from -5 to 1, which is impossible for a binomial variable.
Should the predict function not be used for binomial glm?
#Create the presence absence matrix.
?pb bio1 bio10 bio11 bio12 bio13 bio14 bio15 bio16 bio17 bio18 bio19 bio2
1 ?1 ?237 ? 240 ? 232 ?1774 ? 250 ? ?80 ? ?34 ? 603 ? 270 ? 418 ? 529 ? 89
2 ?1 ?237 ? 240 ? 232 ?1774 ? 250 ? ?80 ? ?34 ? 603 ? 270 ? 418 ? 529 ? 89
3 ?1 ?229 ? 231 ? 227 ?1433 ? 288 ? ? 7 ? ?90 ? 806 ? ?34 ? ?96 ? 137 ?114
4 ?1 ?195 ? 196 ? 193 ?1351 ? 301 ? ? 3 ? ?98 ? 817 ? ?16 ? ?40 ? 799 ?122
5 ?1 ?222 ? 226 ? 217 ?1325 ? 311 ? ? 3 ? 103 ? 838 ? ?17 ? 838 ? ?43 ?123
6 ?1 ?213 ? 213 ? 210 ?1286 ? 237 ? ? 7 ? ?86 ? 704 ? ?37 ? ?37 ? 704 ?110
#Check fitted values - they should be from 0-1
[1] 0.009706557 0.553194264

#Use the predict function to fit the bbox of the predictor variables.
#Error! bizarre range of data.
? ? ? ? ? [,1]
[1,] -5.0485812
[2,] ?0.5138158


I suspect the error has to do with that although the presence/absence
datamatrix contains all bioclimatic variables, i only choose ?4
predictors to use.

I tried to follow this idea by fitting just one bioclimatic variable,
and using only that rasterlayer in the predict function as shown
below.

m1 = glm(pb ~ bio1 , data=sdmdata,family=binomial(link="logit"))
range(m1$fitted)
p <- predict(predictors[[1]],m1)
cellStats(p,range)

however i recieve the error
Error in eval(expr, envir, enclos) : object 'bio1' not found

I appreciate all help,

Best,

Ben Weinstein




Thanks for your help

Ben Weinstein

--
Ben Weinstein
Graduate Student
Ecology and Evolution
Stony Brook University

http://life.bio.sunysb.edu/~bweinste/index.html