I am trying to run an occupancy analysis using the R package Unmarked. I normally work with very large sets of data that include point (repeated) count survey data for multiple species of birds with associated data for site covariates such as habitat type(s) and detection covariates such as time, temperature, cloud cover, wind, observer, etc. I have in the past used PRESENCE Software but would like to use R instead as I am trying to stream line this process. I have imported the data and attempted to build an unmarkedFrameOccu data frame using the following data as practice (normally my data sets include 8-10 site variables and 10-12 detection covariates):
| Site | Species | D1 | D2 | D3 | Date1 | Date2 | Date3 | Temp1 | Temp2 | Temp3 | Time1 | Time2 | Time3 | Grass | Woods | Water |
| 1 | GOEA | 1 | 0 | 1 | 0.07 | 0.16 | 0.25 | 0.56 | 0.67 | 0.67 | 0.56 | 0.67 | 0.67 | 0.413333 | 0.578333 | 0.39 |
| 2 | BAEA | 0 | 0 | 0 | 0.07 | 0.16 | 0.27 | 0.89 | 0.78 | 0.78 | 0.89 | 0.78 | 0.78 | 0.356667 | 0.563333 | 0.43 |
| 3 | BAEA | 0 | 0 | 0 | 0.07 | 0.16 | 0.27 | 0.56 | 0.45 | 0.45 | 0.56 | 0.45 | 0.45 | 0.3 | 0.42 | 0.471667 |
| 4 | GOEA | 1 | 0 | 1 | 0.14 | 0.16 | 0.27 | 0.34 | 0.87 | 0.87 | 0.34 | 0.87 | 0.87 | 0.218333 | 0.51 | 0.511667 |
| 5 | GOEA | 0 | 1 | 1 | 0.14 | 0.16 | 0.27 | 0.98 | 0.38 | 0.38 | 0.98 | 0.38 | 0.38 | 0.158333 | 0.08 | 0.55 |
| 6 | BAEA | 0 | 1 | 0 | 0.14 | 0.14 | 0.27 | 0.56 | 0.54 | 0.54 | 0.56 | 0.54 | 0.54 | 0.098333 | 0.47 | 0.578333 |
| 7 | BAEA | 1 | 0 | 0 | 0.14 | 0.14 | 0.27 | 0.76 | 0.978 | 0.978 | 0.76 | 0.978 | 0.978 | 0.471667 | 0.341667 | 0.453333 |
| 8 | GOEA | 1 | 1 | 1 | 0.12 | 0.14 | 0.27 | 0.9 | 0.67 | 0.67 | 0.9 | 0.67 | 0.67 | 0.528333 | 0.385 | 0.261667 |
| 9 | GOEA | 0 | 0 | 1 | 0.16 | 0.17 | 0.27 | 0.12 | 0.39 | 0.39 | 0.12 | 0.39 | 0.39 | 0.578333 | 0.158333 | 0.075 |
| 10 | BAEA | 0 | 0 | 0 | 0.16 | 0.17 | 0.35 | 0.23 | 0.85 | 0.85 | 0.23 | 0.85 | 0.85 | 0.563333 | 0.105 | 0.11 |
The following is the script I used:
library(unmarked)
data=read.csv("SDataR.csv")
head(data)
y=data[3:5]
head(y)
siC=data[15:17] ###Site data Grass, Woods, Water)###
head(siC)
suC=data[6:11] ###Survey data Date, Time, Temp###
head(suC)
So far so good, the next line of script:
data1=unmarkedFrameOccu(y=y,siteCovs=siC,obsCov=suC)
And returns the error message:
Error in validObject(.Object) :
invalid class “unmarkedFrame” object: obsCovData does not have M*obsNum rows
If I enter this line of script it will build the data frame without the ObsCov:
data1=unmarkedFrameOccu(y=y,siteCovs=siC)
R will build that frame without error. I just get the error message when I try and build the frame with the ObsCov (observation covariates) and I simply don’t know the reason. Any help would be greatly appreciated.
Lastly, I have multiple species in each data set (some data sets 128 species). Can I build all species into one “unmarkedFrameOccu” data frame then call out a species as I need it or do i need a separate unmarkedFrameOccu for each species?
Thanks
Brian
--
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.
For more options, visit https://groups.google.com/d/optout.
> ##Add in the detection data rows - columns for detection and site name## > y<-data[,1:3] > > ##Check to see if y is in the right format## > ##If yes it is - proceed## > n<-nrow(data) > > ##Now to add in the site-specific co-variates-treatment,distance from road## > blgr.site<-data[,8:13] > > ##Check dataframe created## > str(blgr.site) 'data.frame': 3330 obs. of 6 variables: $ Set.distance : Factor w/ 8 levels "0m","120m","150m",..: 1 6 7 8 2 3 4 5 1 6 ... $ Distance.fromroad: int 0 30 60 90 120 150 180 210 0 30 ... $ Trap.Status : Factor w/ 3 levels " NEW","NEW","NILL": 3 3 3 3 3 3 3 3 3 3 ... $ Species : Factor w/ 8 levels "BS","DTT","LTG",..: NA NA NA NA NA NA NA NA NA NA ... $ Sex : Factor w/ 2 levels "F","M": NA NA NA NA NA NA NA NA NA NA ... $ Age : Factor w/ 2 levels "A","SA": NA NA NA NA NA NA NA NA NA NA ... > head(blgr.site) Set.distance Distance.fromroad Trap.Status Species Sex Age 1 0m 0 NILL <NA> <NA> <NA> 2 30m 30 NILL <NA> <NA> <NA> 3 60m 60 NILL <NA> <NA> <NA> 4 90m 90 NILL <NA> <NA> <NA> 5 120m 120 NILL <NA> <NA> <NA> 6 150m 150 NILL <NA> <NA> <NA> > ##Ok. Proceed## > > #create time factor and use as covariate > #observation level (time specific) covariates > blgr.obs<-data[,5:6] > > ##Check the format of the time factor data## > str(blgr.obs) 'data.frame': 3330 obs. of 2 variables: $ Date : Factor w/ 48 levels "1-May-16","10-Jul-16",..: 21 21 21 21 21 21 21 21 21 21 ... $ Trap.Night: int 1 1 1 1 1 1 1 1 1 1 ... > > ### to put everything together in unmarked data frame called blgr## > blgr<-unmarkedFrameOccu(y=y, siteCovs = blgr.site, obsCovs = blgr.obs) Error in validObject(.Object) : invalid class “unmarkedFrame” object: obsCovData does not have M*obsNum rows.
--
*** Three hierarchical modeling email lists ***
(1) unmarked (this list): for questions specific to the R package unmarked
(2) SCR: for design and Bayesian or non-bayesian analysis of spatial capture-recapture
(3) HMecology: for everything else, especially material covered in the books by Royle & Dorazio (2008), Kéry & Schaub (2012), Kéry & Royle (2016, 2021) and Schaub & Kéry (2022)
---
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/b8718d46-044b-4160-8a57-438aa5843133n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/f133a199-16f7-43ed-8e86-fda1eec6ae3en%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/unmarked/d61d2809-6de3-4c4a-a258-9094c1465252n%40googlegroups.com.