Page 1 of 1
Noneuc and hcov

Posted:
Tue Oct 24, 2017 2:32 pm
by bgerber
Murray,
Is there a limitation in secr when using hcov and noneuc together?
I am getting this error when hcov is present, but not when I remove it:
Error in (function (f, p, ..., hessian = FALSE, typsize = rep(1, length(p)), :
missing value in parameter
The script I am testing looks like,
secr.fit(input, model=list(D~elev, g0~1, noneuc~Country),fixed = list(sigma = 1), hcov="Sex",detectfn = 0,
details = list(userdist = fn2), mask=mask.poly, sessioncov=session_covar)
fn2 is the function you provide in secr-noneuclidian.pdf.
thanks
Cheers,
brian
Re: Noneuc and hcov

Posted:
Tue Oct 24, 2017 3:28 pm
by murray.efford
Hi Brian
Not that I am aware. I can't reproduce your problem (see below). Perhaps you have a missing covariate value?
Murray
- Code: Select all
## adapting example in secr-noneuclidean.pdf
## Sex is coincidentally a covariate in ovposs
ovmask <- addCovariates(ovmask, ovforest)
fit2 <- secr.fit(ovposs, mask = ovmask, detectfn = "HHN", hcov = 'Sex', trace = FALSE,
details = list(userdist = fn2), model = noneuc ~ forest,
fixed = list(sigma = 1))
predict(fit2)
# $`session = 49, h2 = F, forest = nonbeech`
# link estimate SE.estimate lcl ucl
# D log 14.4925 1.028879 12.61213 16.6532
# lambda0 log 0.1013 0.008944 0.08522 0.1204
# noneuc log 27.5720 1.037152 25.61302 29.6808
# pmix logit 0.4484 0.033304 0.38440 0.5142
#
# $`session = 49, h2 = M, forest = nonbeech`
# link estimate SE.estimate lcl ucl
# D log 14.4925 1.028879 12.61213 16.6532
# lambda0 log 0.1013 0.008944 0.08522 0.1204
# noneuc log 27.5720 1.037152 25.61302 29.6808
# pmix logit 0.5516 0.033304 0.48578 0.6156
Re: Noneuc and hcov

Posted:
Tue Oct 24, 2017 4:18 pm
by bgerber
Murray,
Something is going wrong on my end. I am running the below code (fitting the ovposs data) and I get the same error. Fit2 returns, "Error in (function (f, p, ..., hessian = FALSE, typsize = rep(1, length(p)), :
missing value in parameter".
If I remove the hcov, the model runs just fine. Did I do something incorrectly with fn2? I copied it from the pdf without alteration.
If I remove the first qualifier to fn2 (if(missing(xy1)....), the error becomes 'parameters in model not consistent with detectfn etc. : noneuc.'
thanks
brian
_________________________________________
library(secr)
library(rgdal)
options (digits = 4)
datadir <- system.file("extdata", package = "secr")
ovforest <- rgdal::readOGR (dsn = paste0(datadir,"/OVforest.shp"), layer = "OVforest")
fn2 <- function (xy1, xy2, mask) {
if (missing(xy1)) return("noneuc")
xy1 <- addCovariates(xy1, mask)
xy2 <- addCovariates(xy2, mask)
sig1 <- covariates(xy1)$noneuc # sigma(x,y) at detectors
sig2 <- covariates(xy2)$noneuc # sigma(x,y) at mask points
euc <- edist(xy1, xy2)
sig <- outer (sig1, sig2, FUN = function(s1, s2) (s1 + s2)/2)
euc / sig
}
leftbank <- read.table(paste0(datadir,"/leftbank.txt"))[21:195,] # for plotting only
ovposs <- OVpossumCH[[1]] # February 1996
ovmask <- make.mask(traps(ovposs), buffer = 120, type = "trapbuffer",
poly = ovforest[1:2,], spacing = 7.5, keep.poly = FALSE)
ovmask <- addCovariates(ovmask, ovforest)
fit2 <- secr.fit(ovposs, mask = ovmask, detectfn = "HHN", hcov = 'Sex', trace = FALSE,
details = list(userdist = fn2), model = noneuc ~ forest,
fixed = list(sigma = 1))
Re: Noneuc and hcov

Posted:
Tue Oct 24, 2017 4:30 pm
by murray.efford
I don't see anything wrong there... What version of secr are you using?
Murray
(incidentally, I realise my call to readOGR could be simpler - readOGR (dsn = datadir, layer = "OVforest") works and is clearer)
Re: Noneuc and hcov

Posted:
Tue Oct 24, 2017 4:49 pm
by bgerber
Well, we got that sorted.
I had R 3.4.0, which was only allowing me to download secr 3.0.1 from cran. I manually downloaded and installed secr 3.1.0, which made me realize I didn't have R 3.4.2. I downloaded and installed this version of R and installed secr 3.1.0, and all is well now.
Sorry to bother you over an R version issue!
Cheers,
brian
Re: Noneuc and hcov

Posted:
Tue Oct 24, 2017 5:12 pm
by murray.efford
Glad you could sort that out. I don't know what changed in R or secr to cause the problem, but there's no need to investigate unless the problem reappears.
Murray