Noneuc and hcov

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

Noneuc and hcov

Postby bgerber » Tue Oct 24, 2017 2:32 pm

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
bgerber
 
Posts: 18
Joined: Wed Dec 12, 2007 1:01 pm

Re: Noneuc and hcov

Postby murray.efford » Tue Oct 24, 2017 3:28 pm

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
murray.efford
 
Posts: 531
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Noneuc and hcov

Postby 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))
bgerber
 
Posts: 18
Joined: Wed Dec 12, 2007 1:01 pm

Re: Noneuc and hcov

Postby murray.efford » Tue Oct 24, 2017 4:30 pm

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)
murray.efford
 
Posts: 531
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Noneuc and hcov

Postby bgerber » Tue Oct 24, 2017 4:49 pm

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
bgerber
 
Posts: 18
Joined: Wed Dec 12, 2007 1:01 pm

Re: Noneuc and hcov

Postby murray.efford » Tue Oct 24, 2017 5:12 pm

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
murray.efford
 
Posts: 531
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand


Return to analysis help

Who is online

Users browsing this forum: No registered users and 1 guest