Hi,
I’m a PhD student and I’m working on a two years CMR data (collected from my PhD project) of a subterranean population of Strinati’s cave salamander. We performed the study inside a cave, equipped with a 1m square grid of 5x42 plots, where we captured and photographed the ventral patterns of individuals, noting sex (M, F and SA – subadults) and capture site. This protocol was done about once a month in the last two years (i.e., 1 session and 30 occasions). I added some of the trap covariates that we registered (i.e., surface temperature of cave wall during the peak activity and distance from the entrance).
I followed the RBS worked example for preparing and analyzing the data. I was able to create the data2oscr object and the state space object. However, I have troubles when I try to run models, for example with the base model (m1) it says "Error in nlm(msLL.sex, scrFrame = scrFrame, p = pv, pn = pn, D = D, nG = nG, : non-finite value supplied by 'nlm'.", while if I try to add trap covariates (m2) I receive the message “Error in dm.trap[[s]][[k]] %*% c(t.beta[s, ]) : non-conformable arguments”.
I’m wondering if there is an underlying problem with data setting, because I repeated multiple times data formatting and analysis and I believe those are correct. Attached the R code and scrFrame plot.
I would appreciate any advice, thank you in advance!
Giacomo Rosa
library(devtools)
library(oSCR)
ss.edf<-read.table("str.edf”,header=1)
ss.tdf<-read.table("str.tdf ",header = 1)
head(ss.edf)
Detector Session ID Sex Occasion
1 B4 1 1 SA 1
2 B5 1 3 SA 1
3 B8 1 4 M 1
4 B9 1 5 SA 1
5 A10 1 6 F 1
6 E10 1 7 M 1
head(ss.tdf)
Detector X Y t.oper sep Temp Distance
1 A1 1 1 1 / 12.87 1
2 A2 1 2 1 / 12.83 2
3 A3 1 3 1 / 11.97 3
4 A4 1 4 1 / 11.83 4
5 A5 1 5 1 / 11.70 5
6 A6 1 6 1 / 11.73 6
ss.data<-data2oscr(edf=ss.edf,
sess.col=2,
id.col=3,
occ.col=5,
trap.col=1,
sex.col=4,
tdf=list(ss.tdf),
K=c(30),
ntraps= 210,
trapcov.names=c("Temp","Distance"),
sex.nacode = "SA",
tdf.sep="/")
names(ss.data)
ss.sf<-ss.data$scrFrame
names(ss.sf)
caphist <- ss.sf$caphist
traps <- ss.sf$traps
trapCovs <-ss.sf$trapCovs
indCovs<-ss.sf$indCovs
sf<-make.scrFrame(caphist = caphist, traps = traps, indCovs=indCovs, trapCovs = trapCovs, type = "scr")
plot(sf,jit=2)
ss.ss<-make.ssDF(scrFrame=sf,buffer=3,res=0.5)
str(ss.ss)
plot(ssDF=ss.ss,scrFrame=sf)
m1<-oSCR.fit(model=list(D~1, #density
p0~1,#detection
sig~1), #spaceuse
scrFrame=sf,ssDF=ss.ss)
m2<- oSCR.fit(model=list(D~1, #density
p0~Temp,#detection
sig~1), #spaceuse
scrFrame=sf,ssDF=ss.ss)
--
You received this message because you are subscribed to the Google Groups "oSCR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to oscr_package...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oscr_package/33e8a756-a887-438e-aef4-150e8db50f3an%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/oscr_package/b3368b65-2778-4c08-b670-84487472407cn%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/oscr_package/ba58e6d1-403c-4d7c-86f2-bc90595580e5n%40googlegroups.com.
Hi Filipe,
Can I check two things. First, does the null model work? I.e., no covariates at all, not even an offset. Second, if the null model does work, what happens when you add the offset?
The reason I ask is that something happened a little while ago that caused the offset to sometimes produce strange results (errors).
Chris
To view this discussion visit https://groups.google.com/d/msgid/oscr_package/CAE%2BwgF3htBGiJ7xP%3DLmKvedMcgneft25Zuw8Hi3y%3Du4HQxVffw%40mail.gmail.com.
Dear Andy and Chris,
Thanks for your quick reply.
I did run the full null model and the model with only the offset and both work.
model1 <- oSCR.fit(model = list(D ~ 1, # model describing variation pixel density (D(si))
p0 ~ 1, # model describing variation in baseline encounter prob/rate (p0)
sig ~ 1), # model describing variation in sigma (space use)
encmod = "P",
scrFrame = reduced.cheetah, # the scrFrame object
ssDF = state.space.cheetah, # the ssDF object
trimS = 1.5*buffer)
Fitting model: D~1, p0~1, sigma~1, asu~1
Using ll function 'msLL.nosex'
Hold on tight!
2025-01-10 23:41:47.396115
p0.(Intercept) | sig.(Intercept) | d0.(Intercept) |
Model: D ~ 1 p0 ~ 1 sig ~ 1
Run time: 0.7168333 minutes
AIC: 203.998
Summary table:
Estimate SE z P(>|z|)
p0.(Intercept) -1.087 0.319 -3.412 0.001
sig.(Intercept) 9.015 0.178 50.592 0.000
d0.(Intercept) -5.994 0.328 -18.302 0.000
*Density intercept is log(individuals per pixel)
Nhat(state-space) = exp(d0.)*nrow(ssDF)
(caution is warranted when model contains density covariates)
model2 <- oSCR.fit(model = list(D ~ 1, # model describing variation pixel density (D(si))
p0 ~ offset(log.effort), # model describing variation in baseline encounter prob/rate (p0)
sig ~ 1), # model describing variation in sigma (space use)
encmod = "P",
scrFrame = reduced.cheetah, # the scrFrame object
ssDF = state.space.cheetah, # the ssDF object
trimS = 1.5*buffer)
Fitting model: D~1, p0~offset(log.effort), sigma~1, asu~1
Using ll function 'msLL.nosex'
Hold on tight!
2025-01-10 23:44:53.359599
p0.(Intercept) | sig.(Intercept) | d0.(Intercept) |
Model: D ~ 1 p0 ~ offset(log.effort) sig ~ 1
Run time: 0.959 minutes
AIC: 188.5243
Summary table:
Estimate SE z P(>|z|)
p0.(Intercept) -6.049 0.310 -19.499 0
sig.(Intercept) 9.082 0.178 50.969 0
d0.(Intercept) -5.921 0.335 -17.701 0
*Density intercept is log(individuals per pixel)
Nhat(state-space) = exp(d0.)*nrow(ssDF)
(caution is warranted when model contains density covariates)
The error only occurs when I include the ‘placement’; that’s why I connected the error to the ‘placement’ covariate.
model3 <- oSCR.fit(model = list(D ~ 1, # model describing variation pixel density (D(si)) p0 ~ offset(log.effort) + placement, # model describing variation in baseline encounter prob/rate (p0) sig ~ 1), # model describing variation in sigma (space use) encmod = "P", scrFrame = reduced.cheetah, # the scrFrame object ssDF = state.space.cheetah, # the ssDF object trimS = 1.5*buffer) )Fitting model: D~1, p0~placement + offset(log.effort), sigma~1, asu~1 Using ll function 'msLL.nosex' Hold on tight!2025-01-10 23:57:02.156934p0.(Intercept) | sig.(Intercept) | t.beta.placementriverbank | t.beta.placementtrail | t.beta.placementwaterhole | d0.(Intercept) | Error in solve.default(myfit$hessian) : Lapack routine dgesv: system is exactly singular: U[3,3] = 0
I read the topic in the group regarding the strange results with the offset. Do you suggest using solely log(effort) without the offset? I tried, and it ran without errors, but I got a warning message and NAs in ‘t.beta.placementriverbank’.
model5 <- oSCR.fit(model = list(D ~ ndvi.z, # model describing variation pixel density (D(si))
p0 ~ log.effort + placement, # model describing variation in baseline encounter prob/rate (p0) sig ~ 1), # model describing variation in sigma (space use) encmod = "P", scrFrame = reduced.cheetah, # the scrFrame object ssDF = state.space.cheetah, trimS = 1.5*buffer) )Fitting model: D~ndvi.z, p0~log.effort + placement, sigma~1, asu~1 Using ll function 'msLL.nosex' Hold on tight!2025-01-11 00:18:51.164638p0.(Intercept) | sig.(Intercept) | t.beta.log.effort | t.beta.placementriverbank | t.beta.placementtrail | t.beta.placementwaterhole | d0.(Intercept) | d.beta.ndvi.z | Model: D ~ ndvi.z p0 ~ log.effort + placement sig ~ 1 Run time: 8.552833 minutes AIC: 173.0383 Summary table: Estimate SE z P(>|z|)
p0.(Intercept) -8.077 0.000 -Inf 0.000t.beta.log.effort 1.463 0.082 17.898 0.000t.beta.placementriverbank -18.855 NaN NaN NaNt.beta.placementtrail -1.891 0.660 -2.865 0.004t.beta.placementwaterhole 1.289 0.509 2.535 0.011sig.(Intercept) 9.249 0.152 60.908 0.000d0.(Intercept) -5.667 0.394 -14.383 0.000d.beta.ndvi.z 0.778 0.420 1.855 0.064*Density intercept is log(individuals per pixel) Nhat(state-space) = exp(d0.)*nrow(ssDF) (caution is warranted when model contains density covariates)Warning message:In sqrt(diag(solve(myfit$hessian))) : NaNs produced
Thanks for your assistance,
Best,
Filipe
--
Filipe Rocha, PhD
Associação BIOPOLIS /CIBIO - Research Center in Biodiversity and Genetic Resources
University of Porto
e-mail: filipe...@cibio.up.pt
Campus de Vairão,
Rua Padre Armando Quintas
4485-661, Vairão
Portugal
--
You received this message because you are subscribed to a topic in the Google Groups "oSCR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/oscr_package/vbZ1OqfQe6A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to oscr_package...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/oscr_package/CANjB3vRgwpEynbV0tYZwwzVRBOy%2BcVmx7eQ_f_5ytHmuy1h6oQ%40mail.gmail.com.