R won't run model because it insists the data is not an UnmarkedFrame Occu Subject

517 Views Asked by At

I am trying to create a dual-species occupancy model using unmarkedFrameOccuMulti. I've been successful in producing the UMF and have even got a basic plot of the detections but when I try to run an individual model I get the error message;

Error in occu(~1, ~Vill_Dist, umf) : Data is not an unmarkedFrameOccu object.

I've made sure the csvs have the same number of rows etc. I'm a bit mythed because I can't find much online and the UMF itself has ran perfectly, just R can't seem to seperate out the aspects of it?

S <- 2 # number of species M <- 354 #number of sites - i.e. number of sites with actual data (#i.e. not NAs/transects that were taken - some transects were done 14 times, others as little as 2 times) J <- 9.07 #average number of visits per transect

y <- list(matrix(rbinom(354, 1, 0.456)), #species 1 leopard
      matrix(rbinom(354, 1, 0.033))) #species 2 wolf

So the above is code I'm following from the R help on unmarkedoccumulti. The ordering of the numbers is based on the rbinom function. i.e. 0.033% of the sites surveyed wolves were seen.

obscov <- read.csv("grazcov2.csv")

Error message is ObsCovData needs M*obsNum of rows

umf <- unmarkedFrameOccuMulti(y=y, siteCovs = predcovs2, obsCovs = NULL)
predcovs2

summary(umf)
plot(umf)

umf

m1 <- occu(~1, ~Vill_Dist, umf) - this is the code that doesn't work - Vill_Dist being one of the covariates in the csv - spellt correctly/same etc.

I was expected to produce a model that would predict occurence of leopards/wolves based off the covariates.

As I was writing this out I had an idea for what might be going wrong. I couldn't get the model to work previously because I was putting in the detection data in csv format rather than using the simple binomial function. Is it simply that R cannot mix csv/imported data and the binomial data?

0

There are 0 best solutions below