csvToUMF - Site-level covariates ?

170 views
Skip to first unread message

Ben Nickley

unread,
Sep 22, 2015, 1:09:48 PM9/22/15
to unmarked
Hi,

I am new to unmarked and R, so I am having some difficulties getting started.  Any help would be greatly appreciated.

What I would like to do is use the csvToUMF() function to get my data, which is in LONG format, into an unmarkedFrame.  However, when I create the unmarked frame with csvToUMF(), all of my covariates are placed at the observation level.  Is there a way to specify site-level covariates using the csvToUMF() function?  

Below is the code I ran with a subset of my data.  The whole data set is much larger and includes many NAs.  I would like AREA and Route to be site-level covariates, and Time, Temp, Wind and Cloud to be observation-level covariates.  

> bacs=read.csv("bacsTEST.csv")
> head(bacs)
  PointName Date TotalBACS AREA Route Time Temp Wind Cloud
1        J1   55         1    5     1  734   56    1     0
2        J1   56         0    5     1  602   52    0     0
3        J1   57         0    5     1  606   62    0    85
4       J12   55         0    5     0 1045   74    1     1
5       J12   56         0    5     0  703   55    0     0
6       J12   57         0    5     0  652   65    0    85
> test.umf <- csvToUMF(filename="bacsTEST.csv", long = TRUE, type = "unmarkedFramePCount")
> summary(test.umf)
unmarkedFrame Object

5 sites
Maximum number of observations per site: 3 
Mean number of observations per site: 3 
Sites with at least one detection: 3 

Tabulation of y observations:
   0    1 <NA> 
  11    4    0 

Observation-level covariates:    ### All my covariates are at the observation level.  I want AREA and Route at the site level###
      AREA         Route          Time             Temp      
 Min.   :2.0   Min.   :0.0   Min.   : 602.0   Min.   :52.00  
 1st Qu.:2.0   1st Qu.:0.0   1st Qu.: 704.0   1st Qu.:56.50  
 Median :5.0   Median :1.0   Median : 734.0   Median :65.00  
 Mean   :3.8   Mean   :0.6   Mean   : 794.5   Mean   :64.07  
 3rd Qu.:5.0   3rd Qu.:1.0   3rd Qu.: 932.5   3rd Qu.:69.00  
 Max.   :5.0   Max.   :1.0   Max.   :1056.0   Max.   :80.00  
      Wind          Cloud         JulianDate
 Min.   : 0.0   Min.   : 0.00   Min.   :55  
 1st Qu.: 0.0   1st Qu.: 0.00   1st Qu.:55  
 Median : 0.0   Median : 1.00   Median :56  
 Mean   : 1.2   Mean   :34.47   Mean   :56  
 3rd Qu.: 0.5   3rd Qu.:80.00   3rd Qu.:57  
 Max.   :12.0   Max.   :90.00   Max.   :57  

bacsTEST.csv

Jeffrey Royle

unread,
Sep 22, 2015, 3:27:47 PM9/22/15
to unma...@googlegroups.com
hi Ben,
 I would remove the sitecovs from the data file and read them in as a seperate nsites x 2 matrix, say X and then when you create the unmarkedFrame do this
 
siteCovs(test.umf)<- X
 
regards
andy
 

--
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.

Ben Nickley

unread,
Sep 22, 2015, 5:28:44 PM9/22/15
to unmarked
Hey, that worked!  Thanks Andy.

Matt Giovanni

unread,
Apr 1, 2016, 7:48:13 AM4/1/16
to unmarked
Hi Andy. I tried adding sitecovs to a umf after creating with csvToUMF, but then R crashes every time I fit a basic occu model. Any tips? Thanks for your help as always.

data=read.csv("data.csv",header=TRUE)
summary(data)
sitecovs=data.frame(Length=data$Length,Facility=data$Facility,Month=data$Month)
summary(sitecovs)
umf=csvToUMF("data.csv", long = TRUE, type = "unmarkedFrameOccu")
siteCovs(umf)=data2
summary(umf)
mod=occu(~1 ~1,umf)

Matt
data.csv

Jeffrey Royle

unread,
Apr 3, 2016, 11:47:53 AM4/3/16
to unma...@googlegroups.com
hi Matt,
 Sorry I don't have any ideas off the top of my head. I'd have to roll up my sleeves and get into it but I don't have time in the short term here to do that. If you make progress or come up with some ideas let us know please...
regards
andy

Dan Linden

unread,
Apr 3, 2016, 5:33:48 PM4/3/16
to unmarked
Hi Matt,

You don't have data2 anywhere in your script, so I'm not sure what it looks like.  Also, "Month" seems to vary across observations so you wouldn't want that as a site-level covariate.  But you could grab length and facility from the obsCovs matrix created by csvToUMF and assign them as siteCovs:

siteCovs(umf) <- data.frame(Length=as.numeric(obsCovs(umf,matrices=T)$Length[,1]),
                            Facility=obsCovs(umf,matrices=T)$Facility[,1])

Now, with only 13 sites you will have problems fitting occupancy covariates.  In addition, you have only 8 detections from 1092 observations.  So this data set will undoubtedly give you problems with model fitting (null suggests psi=1 and p=0.007).
Reply all
Reply to author
Forward
0 new messages