unmarkedFrameGDS questions

64 views
Skip to first unread message

Erik Johnson

unread,
Apr 28, 2021, 9:45:26 PM4/28/21
to unmarked
Hello all,

I'm new to the group, and although I have searched to find an answer to this question, I haven't been able to do so (I apologize if I've overlooked this somewhere).

In short, I have a study with 3 visits to 45 sites (20 in habitat A and 25 in habitat B). I want to compare Prothonotary Warbler density between the two habitats, and adjust for visit-level covariates (observer and wind, for starters). I am using three distance bins: 0-25, 26-50, and 51-100 m.

In trying to build the unmarkedFrameGDS, I am running into issues, particularly associated with yearlySiteCovs. The code below seems to be 

y <- PROW.GDISTSAMP[,2:10] # columns 2-10 contain observations in 3 distance intervals from 3 survey periods

breaks <- c(25,50,100)
R <- 45 # survey points
T <- 3 # number of survey visits

# site-level covariates
covs <- data.frame(habitat=PROW.GDISTSAMP[,11]) # Habitat A vs Habitat B

# survey-level covariates: called "yearlySiteCovs" in this R package
wind1 <- PROW.GDISTSAMP[,12]
wind1.f <- as.factor(wind1)
wind2 <- PROW.GDISTSAMP[,13]
wind2.f <- as.factor(wind2)
wind3 <- PROW.GDISTSAMP[,14]
wind3.f <- as.factor(wind3)
wind.df <- data.frame(wind1.f, wind2.f, wind3.f)

surveyor1 <- PROW.GDISTSAMP[,15]
surveyor1.f <- as.factor(surveyor1)
surveyor2 <- PROW.GDISTSAMP[,16]
surveyor2.f <- as.factor(surveyor2)
surveyor3 <- PROW.GDISTSAMP[,17]
surveyor3.f <- as.factor(surveyor3)
surveyor.df <- data.frame(surveyor1.f, surveyor2.f, surveyor3.f)

# Organize data into an Unmarked Data frame for Generalized Distance Sampling
umf <- unmarkedFrameGDS(y=y, siteCovs=covs, yearlySiteCovs=list(Obs=surveyor.df, Wind=wind.df), survey="point", unitsIn="m", dist.breaks=breaks, numPrimary=T)

in viewing "umf" it appears that the survey-level covariates have been duplicated (6 columns for Wind and 6 columns for Observer, whereas there should be three each, i.e., one for each of three site visits). 

Thanks for any help or insights in fixing this issue!
Erik

Ken Kellner

unread,
Apr 29, 2021, 8:10:56 AM4/29/21
to unmarked
Hi Erik,

It looks like there is a bug with viewing some umfs, in which the yearlySiteCovs get duplicated when it is printed to the console. I'll get that fixed but in the meantime it shouldn't affect your analyses. You can confirm by looking at the yearlySiteCovs by themselves :

yearlySiteCovs(umf)

should be a data frame with two columns (Obs/Wind) each of which is T*number of sites in length as expected. This is what will be used in the analysis.

Ken

Erik Johnson

unread,
Apr 30, 2021, 8:39:52 AM4/30/21
to unmarked
Ok, thanks for that insight Ken!

Both yearlySiteCovs(umf) and str(umf) seem to indicate that each of these variables are a single column of 135 rows (T = 3, Nsites = 45), so I believe that matches what you're saying. 

But...I'm getting a "fatal error" message in R when I run a model, and am forced to restart the session. I have the latest R version (4.0.5) and this error is occurring both in Rstudio and the RGui Console. E.g.:
m1 <- gdistsamp(~1, ~1, ~1, umf, keyfun="halfnorm", output="density", unitsOut="ha", K=50)

Thanks again for the help!
Erik

Ken Kellner

unread,
Apr 30, 2021, 8:51:25 AM4/30/21
to unmarked
Erik,

That's not good, and hard to troubleshoot. Can you email me your code and data off-list so I can try to figure out the issue? con...@kenkellner.com

Ken

Ken Kellner

unread,
May 3, 2021, 12:37:23 PM5/3/21
to unmarked
To follow up on this, the issue was a missing distance breakpoint.

breaks <- c(25,50,100)

should have been 

breaks <- c(0,25,50,100)

I've added a more informative error message to better handle this situation.

Ken

Reply all
Reply to author
Forward
0 new messages