biodiverse / spOccupancy

Single-species, Multi-species, and Integrated Spatial Occupancy Models
https://www.jeffdoser.com/files/spoccupancy-web/
GNU General Public License v3.0
52 stars 8 forks source link

Issue with sfMsPGOcc detection non detection data set up #26

Closed zaarakidwai closed 1 year ago

zaarakidwai commented 1 year ago

Hi,

While running the multi species model, I realized that the data doesn't look the way I entered it, I am wondering if I am setting up things incorrectly. The detection-non detection data is coming all wrong. For the ease of understanding the problem, I am submitting a simple example here. For instance if my data is:

browser<-c(1,0,1,1,NA,0,1,1,0) grazer<-c(0,1,1,NA,NA,1,0,0,0) mixed<-c(1,1,1,0,1,1,0,NA,1) replicates<-c("1","2","3")

Ideally, the data frame should come out as:

replicates browser grazer mixed
1 1 1 0 1 2 2 0 1 1 3 3 1 1 1 4 1 1 NA 0 5 2 NA NA 1 6 3 0 1 1 7 1 1 0 0 8 2 1 0 NA 9 3 0 0 1

OR 1 2 3 browser 1 01 grazer 011 mixed 111 browser 1NA0 grazer NANA1 mixed 011 browser 110 grazer 000 mixed 0NA1

However, with occupancy modelling it is coming out as:

No matter how I set up the data frame, the data is coming out as : species data browser 1 grazer 0 mixed 1 browser 1 grazer NA mixed 0 browser 1 grazer 1 mixed 0 browser 0 grazer 1 mixed 1 browser NA grazer NA mixed 1 browser 0 grazer 0 mixed 0 browser 1 grazer 1 mixed 1 browser 0 grazer 1 mixed 1 browser 0 grazer NA mixed 1

which is completely incorrect since it is distributing the detection non detection data across the species resulting in incorrect occupancy results. I have saved my detection non detection data in csv as the following format. browser 1 browser 0 browser 1 browser 1 browser NA browser 0 browser 1 browser 1 grazer 0 grazer 0 grazer 1 grazer 1 grazer NA grazer NA grazer 1 grazer 0 grazer 0 mixed 1 mixed 1 mixed 1 mixed 0 mixed 1 mixed 1 mixed 0 mixed NA mixed 1

I tried changing the code for ymat in multi species occupancy modelling (sfMsPGOcc) to make the array with species name as columns and plots as rows but it didn't work either.

I would appreciate your help in this regard.

regards, Zaara

zaarakidwai commented 1 year ago

I think I fixed it. I had to sort my data by plot and then by replicate to fix the issue. Thanks.