by bgerber » Tue Oct 24, 2017 4:18 pm
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))