Error: obsCovs is not a matrix or a data frame

192 views
Skip to first unread message

Heather Levy

unread,
Aug 16, 2021, 9:23:12 AM8/16/21
to unmarked
Hello,

I am trying to run a single season occupancy model. Each point location had between 4-7 visits, with most having 6 visits. I am running into an error when trying to create the unmarked frame - Error in FUN(X{{i}}, ...): At least one element of obsCovs in not a matrix or a data frame. 

I have went though and tested each object included, as well as converted my data in both a matrix and data frame. I have also included a mix of different covariates to see where the issue lies with no luck. Any help would be greatly appreciated! I can post code from the console if that would be more helpful as well. 

data <- read.csv("Occupancy_Playback_Data.csv")
head(data)

data[data == ""] <- NA

as.matrix(data)

library(unmarked)

# Covariates

date <- as.data.frame(data[,10:16])

lunar <- data[,17:23]
pressure <- data[,24:30]
sky <- as.data.frame(data[,31:37])
temp <- data[,38:44]
wind <- data[,45:51]
noise <- data[,52:58]
playback <- as.matrix(data[,59:65])
time <- data[,66:72]

y = data[,1:7] # these are the detection histories
n <- nrow(data)
siteCovs <- data$Site
covs <- data.frame(data[,7:72])
obsCovs <- list(date = date, # dates and covariates
                ivel = c(playback))


obsCovs2 <- list(date = data[,10:16],
                 ivel = c(lunar, pressure, sky, temp, wind, noise, playback, time))

umf <- unmarkedFrameOccu(y = y, siteCovs = siteCovs, obsCovs = obsCovs2)

Heather Levy

unread,
Aug 18, 2021, 12:21:52 PM8/18/21
to unmarked
Update: 

Jim Baldwin kindly emailed me a solution that worked. 

obsCovs2 <- list(date = data[,10:16], lunar=lunar, pressure=pressure, sky=sky,
  temp=temp, wind=wind, noise=noise, playback=playback, time=time)
umf <- unmarkedFrameOccu(y = y, obsCovs = obsCovs2)

Reply all
Reply to author
Forward
0 new messages