region.N for non-euclidean models

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

region.N for non-euclidean models

Postby samanthamcfar » Fri Apr 27, 2018 2:47 pm

Hello Murray,

I'm having trouble running region.N for my models that include non-euclidean distances. I'm using the "habitat model for connectivity" method from the noneuclidean vignette. My top two models both include non-euclidean distances:

wsar.fit.noneuc.g0.10km <- secr.fit(WSARCH,mask=wsar_10km_mask, model = list(noneuc~bio, g0~t), trace=FALSE, details = list(userdist = fn2), fixed = list(sigma=1), method = "Nelder-Mead")

wsar.fit.NULL.noneuc.10km <- secr.fit(WSARCH,mask=wsar_10km_mask, model = list(D~bio, noneuc~bio), trace=FALSE, details = list(userdist = fn2), fixed = list(sigma=1), method = "Nelder-Mead")

fn2 is the function provided from the vignette.

However, when I attempt to run region.N to estimate N within my population range, I keep getting the following error:
region.N(Top_Model, popmask, spacing = 2000, se.N = TRUE)
Error in euc/sig : non-conformable arrays

Any suggestions?

Thanks
Sam
samanthamcfar
 
Posts: 2
Joined: Fri Apr 27, 2018 1:30 pm

Re: region.N for non-euclidean models

Postby murray.efford » Sat Apr 28, 2018 7:11 am

region.N fails also with the possum model in the vignette. It seems this can be fixed by a small change in fn2 (coercing sig1 and sig2 to vectors before 'outer'):

Code: Select all
fn2 <- function (xy1, xy2, mask) {
  if (missing(xy1)) return("noneuc")
  xy1 <- addCovariates(xy1, mask)
  xy2 <- addCovariates(xy2, mask)
  sig1 <- as.numeric(covariates(xy1)$noneuc)   # sigma(x,y) at detectors
  sig2 <- as.numeric(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
}


I hope this works for you.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: region.N for non-euclidean models

Postby murray.efford » Sat Apr 28, 2018 7:49 pm

I tracked this down to an internal function (predictD) that returned a 1-column matrix instead of a vector. It should be fixed in the next release, but that is not imminent. In the meantime use the modified fn2 in my last post.
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: region.N for non-euclidean models

Postby samanthamcfar » Mon Apr 30, 2018 10:36 am

Thank you so much Murray. I changed the fn2 code and am re-running my non-euc models now, I will let you know if this fixes the issue!

Thanks,
Sam
samanthamcfar
 
Posts: 2
Joined: Fri Apr 27, 2018 1:30 pm


Return to analysis help

Who is online

Users browsing this forum: No registered users and 6 guests