Unable to add covariates using '/' in trapfile

130 views
Skip to first unread message

Ana Gracanin

unread,
Oct 3, 2020, 11:15:44 PM10/3/20
to secr
Hello, 

I've been unsuccessful in adding my covariates through the trapfile. 

I've followed the instructions as per page 3 of the 'secr data input' manual, using '/' to delineate covariates.

The covariates do not appear (I've tried as many different ways as I could think of: importing with excel, as a csv comma delimited, with no effort data, with effort data displayed in a string, etc).

However, when I import it using the shiny secrdesignapp it works perfectly, and the covariates appear... 

Any help would be most appreciated! :)

Kind regards, 
Ana

Details: 

#Create capture history file
A1_sug_caphistory<-read.capthist(captfile = "A1_SUG_captfile.txt",
                                 trapfile = "A1_SUG_trapfile.txt",
                                 covnames = c('EU'),
                                 detector = "count")

... later when I run a model: 

#Run secr model
fitted <- secr.fit(A1_sug_caphistory, mask = A1_mask, detectfn = 'HN', 
                   model = list(D~EU, g0~1, sigma~1), trace = FALSE, ncores = 4)

I get the error: "EU" variable not found. Neither is "v1" found if I run it with the automatic name for the covariates. 
A1_SUG_captfile.txt
A1_SUG_trapfile.txt

Murray Efford

unread,
Oct 5, 2020, 6:22:18 PM10/5/20
to secr
Hello Ana

Covariates are used either to model density (D) or detection parameters (g0, sigma etc.). Covariates for D must be covariates of the mask object, i.e. defined for each mask point. Your EU is a detector covariate (and is properly read as such if you specify trapcovnames rather than covnames in read.capthist). If your aim is to model D then you will need to stratify the mask points according to that (habitat?) variable. The function addCovariates() can be useful for rolling out data from another data source across all mask points. So this works for me:

m1 <- addCovariates(A1_mask, traps(A1_sug_caphistory))
plot(m1, cov = 'EU')
fitted <- secr.fit(A1_sug_caphistory, mask = m1, detectfn = 'HN', + model = list(D~EU, g0~1, sigma~1), trace = FALSE, ncores = 4)

Murray
Reply all
Reply to author
Forward
0 new messages