0

I am modelling the potential distribution of a species using COZIGAM package. I have the response variable ("pb", which tells where the species is present) and the predictor variables (e.g. altitude, temperature, precipitation, etc). When I run this formula:

# devtools::install_github('AndrewLJackson/COZIGAM')
coz.model <- cozigam(formula=pb ~ s(altitude) + s(combustible) + s(distribution) + s(e1) + s(e2) + s(e3) + s(euc.human) + s(euc.river) + s(fccarb) + s(fccmat) + s(forarb) + s(aspect) + s(slope) + s(precipitation) + s(radiation) + s(tipestr_class) + s(tipestr_forest) + s(tmean), data=sdmdata2, family=poisson)

it appears an error warning, which is:

Error in as.matrix(x) : object 'altitude' not found

However, when I run as.matrix(sdmdata2), 'altitude' variable exits in my matrix. The output of dput(head(sdmdata2)) is:

structure(list(X = 1:6, pb = c(2L, 2L, 2L, 2L, 2L, 2L), altitude = c(879L,
1094L, 1035L, 410L, 342L, 665L), combustible = c(6L, 6L, 3L, 
0L, 3L, 3L), distribution = c(6L, 6L, 6L, 0L, 6L, 0L), e1 = c(4L, 
4L, 2L, 0L, 4L, 0L), e2 = c(0L, 0L, 2L, 0L, 2L, 0L), e3 = c(0L, 
0L, 4L, 0L, 2L, 0L), euc.human = c(790.569397, 3201.562012, 1750, 
250, 250, 1952.562012), euc.river = c(0, 4069.705078, 353.5534058, 
1030.776001, 559.0170288, 0), fccarb = c(90L, 70L, 40L, 0L, 30L, 
0L), fccmat = c(5L, 10L, 35L, 0L, 60L, 80L), forarb = c(1L, 1L, 
2L, 0L, 5L, 0L), aspect = c(6L, 8L, 6L, 4L, 3L, 3L), slope = c(5L, 
3L, 5L, 2L, 6L, 5L), precipitation = c(87.01500702, 79.57628632, 
81.86239624, 75.10630798, 49.58106995, 69.55927277), radiation = c(160.1408997, 
163.4971008, 161.8542938, 157.9179993, 159.2113953, 160.6203003
), tipestr_class = c(1L, 1L, 1L, 7L, 1L, 2L), tipestr_forest = c(6L, 
6L, 6L, 0L, 6L, 0L), tmean = c(141.7760925, 134.9530029, 141.9192047, 
171.9972992, 186.2566986, 157.0391998)), .Names = c("X", "pb", 
"altitude", "combustible", "distribution", "e1", "e2", "e3", "euc.human", 
"euc.river", "fccarb", "fccmat", "forarb", "aspect", "slope", 
"precipitation", "radiation", "tipestr_class", "tipestr_forest", 
"tmean"), row.names = c(NA, 6L), class = "data.frame")

Do someone know what is the problem?

  • It appears COZIGAM was taken off of cran. – Dason Apr 21 '15 at 17:56
  • Your example isn't reproducible. I don't know how we could possibly help with what you've given us. – Dason Apr 21 '15 at 17:58
  • Could you provide the result of `head(dput(sdmdata2))`? – David Robinson Apr 21 '15 at 18:01
  • I downloaded the package from [here](http://cran.r-project.org/src/contrib/Archive/COZIGAM/). The output of that function is (shortened because it's too long): >.Names = c("X", "pb", "altitude", "combustible", "distribution", "e1", "e2", "e3", "euc.human", "euc.river", "fccarb", "fccmat", "forarb", "aspect", "slope", "precipitation", "radiation", "tipestr_class", "tipestr_forest", "tmean"), class = "data.frame", row.names = c(NA, -10124L)). I am unable to give more info since 'sdmdata2' is a pretty long csv file. – Karla Enher Apr 21 '15 at 19:10
  • @KarlaEnher you need to install the version from [here](https://github.com/AndrewLJackson/COZIGAM) to start with, your version won't be compatible with r v3.0 I expect. you can use `devtools::install_github('AndrewLJackson/COZIGAM')` to do that. Also please edit your question with the `dput(head(sdmdata2))` *not* `head(dput(smdata2))`, @DavidRobinson just made a typo – rawr Apr 21 '15 at 19:17
  • 2
    In your `dput`, it looks like your data has a column named `altitud` with no "e", but in your model, you specify `s(altitude)` with an "e". – Gregor Thomas Apr 21 '15 at 19:38
  • @Gregor That is because I forgot to translate it to English, in my script it is written in Spanish, sorry for the mistake. I am going to try to install the cozigam package from the link rawr provided and run everything again. – Karla Enher Apr 21 '15 at 20:14
  • Yup, that's also probably why you're getting an error. The function is looking for a column with an "e", and it's not there. And that's exactly what the error is saying: "object 'altitude' not found" – Gregor Thomas Apr 21 '15 at 20:30
  • I have solved the misspelling, but the same error comes up. And when I try to install the package from the link given by @rawr, R returns this error: "file ‘R/cozigam.R’ has the wrong MD5 checksum" – Karla Enher Apr 21 '15 at 21:55
  • I get that, too, but the package still works. are you on a windows machine? does the installation fail or just give the error and continue? – rawr Apr 21 '15 at 22:03
  • Yes, Windows 8.1. It fails to install. It seems to be installed because a folder is created under the name "COZIGAM-master" in the R win-library, but if I call the package (`library(COZIGAM)` or `library(COZIGAM-master)` it doesn't work. I refresh the packages tab in RStudio and it just doesn't appear either. @rawr – Karla Enher Apr 21 '15 at 22:17
  • hm.. I just installed it on a windows machine (although win7), and it installed fine. do you have [Rtools](http://cran.r-project.org/bin/windows/Rtools/) installed? You should have seen a message to install it when you run `install_github` if you dont have it already. Have you installed packages from github before? Also was the previous version of COZIGAM working for you? I was getting errors because the older version wasn't working with r > 3.0. – rawr Apr 21 '15 at 22:44

0 Answers0