Error in match(x, table, nomatch = 0L) : 'match' requires vector arguments

123 views
Skip to first unread message

Jessica Gouvea

unread,
Apr 16, 2020, 9:59:52 PM4/16/20
to unmarked
Hi community!

I'm trying to run the occuMulti script but I think I'm doing something wrong imputting data. This is the script I'm using:

# Import data
setwd("~/Jéssica/i/Ocupacao/3dias")
mtridac.data <- read.csv("detec3dias.csv", row.names = 1, header = T, na.strings = "-")
str(mtridac.data)
canis.data <- read.csv("canis3dias.csv", row.names = 1, header = T, na.strings = "-")
str(canis.data)


S <- 2 # number of species
M <- 58 #number of sites
J <- 45 #number of occ

y <- list(as.matrix(mtridac.data),
          as.matrix(canis.data))

names(y) <- c("anteater", "dog")

siteCovs <- read.csv("sitecov500m.csv", row.names = 1, header = T)

obsCovs <- read.csv("obscov3dias.csv", row.names = 1, header = T)

library(unmarked)
umf <- unmarkedFrameOccuMulti(y=y, siteCovs=siteCovs, 
                              obsCovs=list(temp=obsCovs[,c("temp1", "temp2", "temp3", "temp4", "temp5",
                                                                "temp6", "temp7", "temp8", "temp9", "temp10",
                                                                "temp11", "temp12", "temp13", "temp14", "temp15",
                                                                "temp16", "temp17", "temp18", "temp19", "temp20",
                                                                "temp21", "temp22", "temp23", "temp24", "temp25",
                                                                "temp26", "temp27", "temp28", "temp29", "temp30",
                                                                "temp31", "temp32", "temp33", "temp34", "temp35",
                                                                "temp36", "temp37", "temp38", "temp39", "temp40",
                                                                "temp41", "temp42", "temp43", "temp44", "temp45")],
                                           day=obsCovs[,c("day1", "day2", "day3", "day4", "day5",
                                                               "day6", "day7", "day8", "day9", "day10",
                                                               "day11", "day12", "day13", "day14", "day15",
                                                               "day16", "day17", "day18", "day19", "day20",
                                                               "day21", "day22", "day23", "day24", "day25",
                                                               "day26", "day27", "day28", "day29", "day30",
                                                               "day31", "day32", "day33", "day34", "day35",
                                                               "day36", "day37", "day38", "day39", "day40",
                                                               "day41", "day42", "day43", "day44", "day45")]))
umf                     # look at data
summary(umf)     # summarize      
plot(umf)               # visualize

Until here I got it without Error. But when I try to fit the models, this Error is showed:

null <- occuMulti(~1, ~1, umf, match() ) # fit a model

Error in match(x, table, nomatch = 0L) : 
  'match' requires vector arguments

What's going on?

Thanks everybody! 

Gabriel Patricio Andrade Ponce

unread,
Apr 16, 2020, 11:38:23 PM4/16/20
to unma...@googlegroups.com
Hi Jessica,
I think it is because you forgot the occuMulti sintaxis, that is a little bit different from occ.

When you fit an occuMulti model you must add the psi (occformulas) and p (detformulas) formulas, which are vectors of what you wish to model.
The det formulas must be a vector equal to your species number in this case 2: c("~1","~1"), here we state that no covs affect the anteater and doc detections.
On the other hand occ formulas object is  a vector of the same length as your umf@fDesing (this calls your design matrix) columns, in this case three: 1. Anteater psi, 2. Dog psi and Anteater|dog psi. You can express it like this c("~1", "~1", "~1") in the case you want to model the conditional occupancy.

So you can try this

null <- occuMulti(c("~1","~1"), c("~1", "~1", "0"), umf ) # model without interactions or covs

Hope I have been clear enough to help you, if not I think the package documents can be very useful to get the occuMulti sintaxis.


--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/3c23e2fa-fc82-4abd-9860-da6445ffedd1%40googlegroups.com.


--
Gabriel P. Andrade-Ponce
Biólogo - Universidad Nacional de Colombia
MSc y Estudiante de Doctorado -Instituto de Ecología A.C.
Xalapa, Veracruz, México

Jessica Gouvea

unread,
Apr 17, 2020, 8:23:54 AM4/17/20
to unmarked
Hi Gabriel,

I'm new at occuMulti analysis, and have read the package documents, but this wasn't clear to me. Now I understand how it works.
Thank you so much! 
To unsubscribe from this group and stop receiving emails from it, send an email to unma...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages