Thanks for your help Murray. I apologise if the answers to my questions are obvious, I'm still learning the ins and outs of R and your guidance if very appreciated.
I have two more questions if that's okay?
Question 1) You said "To model differing density among sessions call secr.fit with model = D ~ session." however R produced a unique density estimate for each session just by adding " lapply(PossumCH[1:3]...)" like you mentioned above. See below:
> fits <- lapply(PossumCH[1:3], secr.fit, buffer = 275, trace = FALSE)
Warning message:
In bufferbiascheck(output, buffer, biasLimit) :
predicted relative bias exceeds 0.01 with buffer = 275
> class(fits) <- 'secrlist'
> predict(fits)
$`1`
link estimate SE.estimate lcl ucl
D log 0.4785431 0.1358555 0.2772920 0.8258566
g0 logit 0.5126066 0.1227146 0.2865418 0.7336291
sigma log 71.5382452 9.0716690 55.8507162 91.6321379
$`2`
link estimate SE.estimate lcl
D log 0.08781757 0.05349604 0.02920020
g0 logit 0.15430673 0.09784007 0.04028311
sigma log 127.92925888 48.18079019 62.65560244
ucl
D 0.2641053
g0 0.4423271
sigma 261.2040207
$`3`
link estimate SE.estimate lcl ucl
D log 0.7315003 0.21801774 0.4129512 1.2957770
g0 logit 0.2542963 0.05903097 0.1563082 0.3856347
sigma log 68.4717817 9.94469752 51.5857215 90.8853215
I can also get unique density estimates for each session by using model = D~session in secr.fit. See below:
> secr.fit(PossumCH, model = D~session, mask = masks, trace = FALSE, verify = FALSE)
secr.fit(capthist = PossumCH, model = D ~ session, mask = masks,
verify = FALSE, trace = FALSE)
secr 4.3.3, 16:38:18 04 Mar 2021
Model : D~session g0~1 sigma~1
Fixed (real) : none
Detection fn : halfnormal
Distribution : poisson
N parameters : 6
Log likelihood : -379.9028
AIC : 771.8057
AICc : 774.3511
Beta parameters (coefficients)
beta SE.beta lcl ucl
D -0.7366118 2.675597e-01 -1.2610192 -0.2122045
D.session2 -1.3370696 5.088190e-01 -2.3343365 -0.3398027
D.session3 0.1746731 3.381917e-01 -0.4881705 0.8375167
D.session4 -15.7691603 4.652433e-09 -15.7691603 -15.7691603
g0 -0.6407638 2.496777e-01 -1.1301232 -0.1514045
sigma 4.3505726 9.520928e-02 4.1639658 4.5371793
Variance-covariance matrix of beta parameters
D D.session2 D.session3
D 7.158818e-02 -5.782777e-02 -5.850716e-02
D.session2 -5.782777e-02 2.588967e-01 5.883713e-02
D.session3 -5.850716e-02 5.883713e-02 1.143736e-01
D.session4 -9.667793e-10 5.289717e-10 6.744524e-10
g0 -2.066598e-03 -1.216788e-03 4.165053e-05
sigma -9.988681e-03 -6.217177e-04 -2.538103e-04
D.session4 g0 sigma
D -9.667793e-10 -2.066598e-03 -9.988681e-03
D.session2 5.289717e-10 -1.216788e-03 -6.217177e-04
D.session3 6.744524e-10 4.165053e-05 -2.538103e-04
D.session4 2.164513e-17 -6.437811e-10 3.060474e-10
g0 -6.437811e-10 6.233897e-02 -7.200086e-03
sigma 3.060474e-10 -7.200086e-03 9.064807e-03
Fitted (real) parameters evaluated at base levels of covariates
session = 1
link estimate SE.estimate lcl ucl
D log 0.4787332 0.13041668 0.2833651 0.8087993
g0 logit 0.3450739 0.05642664 0.2441384 0.4622210
sigma log 77.5228377 7.39765175 64.3261229 93.4269018
session = 2
link estimate SE.estimate lcl ucl
D log 0.1257221 0.06154612 0.05068533 0.3118465
g0 logit 0.3450739 0.05642664 0.24413837 0.4622210
sigma log 77.5228377 7.39765175 64.32612285 93.4269018
session = 3
link estimate SE.estimate lcl ucl
D log 0.5701027 0.15231451 0.3407578 0.9538067
g0 logit 0.3450739 0.05642664 0.2441384 0.4622210
sigma log 77.5228377 7.39765175 64.3261229 93.4269018
session = 4
link estimate SE.estimate lcl
D log 6.786319e-08 1.848732e-08 4.016863e-08
g0 logit 3.450739e-01 5.642664e-02 2.441384e-01
sigma log 7.752284e+01 7.397652e+00 6.432612e+01
ucl
D 1.14652e-07
g0 4.62221e-01
sigma 9.34269e+01
There is quite a bit of difference in the density estimates in session 2 and 3 depending on which method I use to estimate the densities. I'm hoping you can please explain what method I should use and why?
Question 2)
The main goal of my research project is to determine the density of Short-eared Possums in different habitat types and work out whether habitat type is a predictor of density. I'm hypothesizing that rainforest habitat will have the highest density of possums. I'm planning to compare the AICc value of a model with habitat as a covariant to a model without the habitat covariate to determine whether habitat is a predictor of density. When trying to add the covariate "Habitat" to the mask I am getting an error which I'm hoping you can take a look at please? See below:
> setwd("C:/Users/lmcra/OneDrive/Desktop/Career/Uni/Honours/Data/Combined")
> library(secr)
> PossumCH <- read.capthist('CHistory_4sessions.txt', c("session1.txt", "session2.txt", "session3.txt", "session4.txt"), detector = "multi")
Session 4
No live releases
Duplicated or missing row names (animal ID)
> summary(PossumCH, terse = TRUE)
1 2 3 4
Occasions 8 7 8 9
Detections 63 10 51 0
Animals 17 5 18 0
Detectors 13 13 13 14
> masks <- make.mask(traps(PossumCH), buffer = 275, nx = 32, type = 'trapbuffer')
> covariatesource <- read.mask('HabitatCovariate.txt')
> masks <- addCovariates(masks, covariatesource)
> fitted <- secr.fit(PossumCH, mask = masks, detectfn = 'HN',
+ model = D~Habitat, trace = FALSE, verify = FALSE)
Error in D.designdata(mask, model$D, grouplevels, session(capthist), sessioncov) :
Habitat not found
It is saying that "Habitat" is not found so I went back into my HabitatCovariate text file and I removed the "#" symbol from the top row where the column headings are so that the word "Habitat" is read but then a different error message appears. See below:
> covariatesource <- read.mask('HabitatCovariate.txt')
Error in read.mask("HabitatCovariate.txt") :
non-numeric x or y coordinates
How do I get past this issue? I have attached my HabitatCovariate text file.
Cheers,
Lachlan