Connectivity models: Continuously varying σ using gdistance

56 views
Skip to first unread message

Clayton Lamb

unread,
Sep 10, 2018, 10:55:39 AM9/10/18
to secr...@googlegroups.com
I am attempting to fit connectivity models for a large grizzly bear CR dataset. My goal is to create a connectivity/movement resistance surface. However, even my null models (noneuc~1) appear to fail, having 0’s in the VC matrix and beta parameters with SE=0. Has anyone else had this issue? I have tried standardizing my mask covariates (which isn’t the issue her anyways, as there aren’t any covariates added), using different subsets of my data, different detection functions, different mask spacing.


For example:

This is my mode structure:
csecr.null <- secr.fit(capthist = grizzCH, mask = GBmask, detectfn = "HHN",
                       details = list(userdist = fn3), model = list(D ~ 1, noneuc ~ 1, g0~ 1),
                       fixed = list(sigma = 1))

And the resulting
Beta parameters (coefficients) 
              beta    SE.beta        lcl        ucl
D        28.059163 0.04801771  27.965050  28.153276
lambda0 -37.429932 0.00000000 -37.429932 -37.429932
noneuc    3.912023 0.00000000   3.912023   3.912023

Variance-covariance matrix of beta parameters 
                  D lambda0 noneuc
D       0.002305701       0      0
lambda0 0.000000000       0      0
noneuc  0.000000000       0      0


--
Clayton Lamb, PhD Candidate
South Rockies Grizzly Bear Project
S.Boutin and S.Nielsen Labs
Biological Sciences, University of Alberta 
e: 
ctl...@ualberta.ca
p: 778-215-0334
t: 
@ClaytonTLamb
w: 
www.lamb-eco-research.ca

John

unread,
Sep 11, 2018, 12:28:33 PM9/11/18
to secr
Clayton,

You sure you are using the right user distance function? In the vignette, fn2 is used for landscape resistance models.

Clayton Lamb

unread,
Sep 13, 2018, 11:08:46 PM9/13/18
to secr, John
Just an update: John and I had a productive discussion in a side thread and I think we found the issue to my problem, which was 0’s in my variance covariance matrix and SE’s for the noneuc parameter.

The issue was related to fixing sigma at 1, which was perhaps too small for grizzly bears.. So I set it to an average sigma value for the species of 6000 and the models began to fit much better. 

The working model looks like this:
csecr.hii <- secr.fit(capthist = grizzCH.d, mask = GBmask.d,detectfn = "HHN",
                       details = list(userdist = fn3), model = list(D ~ 1, noneuc ~ hii, lambda0~bk + Trap_Type),
                      start=csecr.null, fixed = list(sigma = 6000))

The final piece is interpreting what the results from the model mean. The noneuc.hii parameter (human influence index) had a negative beta value (see plot). John and I discussed that this should mean that sigma is actually larger under high human influence, i.e., a large noneuc makes things effectively closer together, shrinks the space, therefore this means in reality that sigma is larger and the animals are moving more/farther in areas of high human influence?

Hopefully this 1) can help someone else with these models, and 2) can stimulate discussion on how to interpret…

Cheers,
Clayton



On Sep 11, 2018, at 10:28 AM, John <john....@maine.edu> wrote:

Clayton,

You sure you are using the right user distance function? In the vignette, fn2 is used for landscape resistance models.

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Sutherland

unread,
Sep 14, 2018, 1:19:48 AM9/14/18
to Clayton Lamb, secr, John Clare
Interesting stuff here. 

I'm curious (and will read up about) the rationale behind fixing sigma, and whether there is a link function for the noneuc model? My understanding of the cost distance functions in R, which i assume are being used here (?) is that there is a d_cost = d*cost calculation,  and having a cost surface the goes negative can cause problems depending on  the link function.

Will be keeping an eye on this thread - lots to still learn about these models!

Chris
Screen Shot 2018-09-13 at 8.38.20 PM.png

John Clare

unread,
Sep 14, 2018, 10:08:19 AM9/14/18
to Chris Sutherland, Clayton Lamb, secr
Murray can certainly answer more thoroughly or correct me, but I think the parameters associated with noneuc are fit using a log-link (with an intercept by default). The userdistance function and calls to noneuc seem to do a lot of things, but in the context of landscape resistance, if a1 = 1/(2 * sigma^2), log(cost) = a2 + a3 (z(x)+z(x'))/2 with one covariate. A call to noneuc~1 (without fixing sigma) introduces what looks like nonidentifiability of sigma and noneuc, or nonidentifiability of a1 and a2 above. Things either move farther, or spaces are closer together—many possible combinations are (equally) likely. Fitting a model with noneuc ~ covariate retains an intercept for noneuc, so same issue. So it seems like either one must be fixed (distance or a2 is known, and sigma is uncertain, or sigma is 'known' but a2 is uncertain) or the intercept must be specified as nonexistent within the model call (e.g., noneuc~covariate-1), in which case log(cost) =  a2 (z(x)+z(x'))/2. This is how it's described in the 2013 paper.  noneuc~covariate-1 probably would have been a much quicker solution!






On Sep 14, 2018, at 12:19 AM, Chris Sutherland <chris...@gmail.com> wrote:

Interesting stuff here. 

I'm curious (and will read up about) the rationale behind fixing sigma, and whether there is a link function for the noneuc model? My understanding of the cost distance functions in R, which i assume are being used here (?) is that there is a d_cost = d*cost calculation,  and having a cost surface the goes negative can cause problems depending on  the link function.

Will be keeping an eye on this thread - lots to still learn about these models!

Chris


On Thu, Sep 13, 2018, 23:08 Clayton Lamb <ctl...@ualberta.ca> wrote:
Just an update: John and I had a productive discussion in a side thread and I think we found the issue to my problem, which was 0’s in my variance covariance matrix and SE’s for the noneuc parameter.

The issue was related to fixing sigma at 1, which was perhaps too small for grizzly bears.. So I set it to an average sigma value for the species of 6000 and the models began to fit much better. 

The working model looks like this:
csecr.hii <- secr.fit(capthist = grizzCH.d, mask = GBmask.d,detectfn = "HHN",
                       details = list(userdist = fn3), model = list(D ~ 1, noneuc ~ hii, lambda0~bk + Trap_Type),
                      start=csecr.null, fixed = list(sigma = 6000))

The final piece is interpreting what the results from the model mean. The noneuc.hii parameter (human influence index) had a negative beta value (see plot). John and I discussed that this should mean that sigma is actually larger under high human influence, i.e., a large noneuc makes things effectively closer together, shrinks the space, therefore this means in reality that sigma is larger and the animals are moving more/farther in areas of high human influence?

Hopefully this 1) can help someone else with these models, and 2) can stimulate discussion on how to interpret…

Cheers,
Clayton



On Sep 11, 2018, at 10:28 AM, John <john....@maine.edu> wrote:

Clayton,

You sure you are using the right user distance function? In the vignette, fn2 is used for landscape resistance models.

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Clayton Lamb, PhD Candidate
South Rockies Grizzly Bear Project
S.Boutin and S.Nielsen Labs
Biological Sciences, University of Alberta 
e: 
ctl...@ualberta.ca
p: 778-215-0334
t: 
@ClaytonTLamb
w: 
www.lamb-eco-research.ca

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
<Screen Shot 2018-09-13 at 8.38.20 PM.png>
Screen Shot 2018-09-13 at 8.38.20 PM.png

Chris Sutherland

unread,
Sep 14, 2018, 10:42:12 AM9/14/18
to John Clare, Clayton Lamb, secr

Hi John,

 

Thanks. Indeed, all the applications we use and the way our fitting function is set up is to drop the intercept, although recently we have considered exploring ways of/reasons to include the intercept – like those Murray has implemented (by we, I mean the Royle et al scr-connectivity paper and the Sutherland et al non-euc paper).

 

So, if I understand you correctly, fitting the ~X-1 model means you don’t have to assume a sigma value like Clay did? Seems like a better solution.

 

Regarding the cost function, and given it is the same formulation as I am familiar with (thanks for saving me the reading J), here is some behavior I found when standardizing covariate cost surfaces (this is just an fyi I found interesting, and potentially probalematic):

 

Basically, if d_cost = f(d_euc * cost), consider the example where the resistance parameter is positive, i.e., cost function should evaluate to > 1 and d_cost should be greater than d_euc. Good to think of just a single move from one pixel to a neighbor here, but it scales to the path. This script shows that constraint isn’t respected when the covariate is negative to positive as is the case with scaling.

 

I might be wrong here, so happy to be corrected!

 

a2 <- 0.5                    #positive cost

cov <- seq(0,3,length=20)     #some values of (c1-c2)/2 covariate values

covS <- scale(cov)           #scaled

 

#evaluate the toy cost function

cost1 <- exp(a2 * cov)

cost2 <- exp(a2 * covS)

 

#plot it

par(mfrow=c(1,2))

plot(cost1 ~ cov,ylim=c(0,5)); abline(h=1)

plot(cost2 ~ cov,ylim=c(0,5)); abline(h=1)

 

 

 

 

From: John Clare <john....@maine.edu>
Sent: Friday, September 14, 2018 10:08 AM
To: Chris Sutherland <chris...@gmail.com>
Cc: Clayton Lamb <ctl...@ualberta.ca>; secr <secr...@googlegroups.com>
Subject: Re: Connectivity models: Continuously varying σ using gdistance

 

Murray can certainly answer more thoroughly or correct me, but I think the parameters associated with noneuc are fit using a log-link (with an intercept by default). The userdistance function and calls to noneuc seem to do a lot of things, but in the context of landscape resistance, if a1 = 1/(2 * sigma^2), log(cost) = a2 + a3 (z(x)+z(x'))/2 with one covariate. A call to noneuc~1 (without fixing sigma) introduces what looks like nonidentifiability of sigma and noneuc, or nonidentifiability of a1 and a2 above. Things either move farther, or spaces are closer together—many possible combinations are (equally) likely. Fitting a model with noneuc ~ covariate retains an intercept for noneuc, so same issue. So it seems like either one must be fixed (distance or a2 is known, and sigma is uncertain, or sigma is 'known' but a2 is uncertain) or the intercept must be specified as nonexistent within the model call (e.g., noneuc~covariate-1), in which case log(cost) =  a2 (z(x)+z(x'))/2. This is how it's described in the 2013 paper.  noneuc~covariate-1 probably would have been a much quicker solution!

 

 

 

 

 


On Sep 14, 2018, at 12:19 AM, Chris Sutherland <chris...@gmail.com> wrote:

Interesting stuff here. 

 

I'm curious (and will read up about) the rationale behind fixing sigma, and whether there is a link function for the noneuc model? My understanding of the cost distance functions in R, which i assume are being used here (?) is that there is a d_cost = d*cost calculation,  and having a cost surface the goes negative can cause problems depending on  the link function.

 

Will be keeping an eye on this thread - lots to still learn about these models!

 

Chris

 

On Thu, Sep 13, 2018, 23:08 Clayton Lamb <ctl...@ualberta.ca> wrote:

Just an update: John and I had a productive discussion in a side thread and I think we found the issue to my problem, which was 0’s in my variance covariance matrix and SE’s for the noneuc parameter.

 

The issue was related to fixing sigma at 1, which was perhaps too small for grizzly bears.. So I set it to an average sigma value for the species of 6000 and the models began to fit much better. 

 

The working model looks like this:

csecr.hii <- secr.fit(capthist = grizzCH.d, mask = GBmask.d,detectfn = "HHN",
                       details = list(userdist = fn3), model = list(D ~ 1, noneuc ~ hii, lambda0~bk + Trap_Type),
                      start=csecr.null, fixed = list(sigma = 6000))

 

The final piece is interpreting what the results from the model mean. The noneuc.hii parameter (human influence index) had a negative beta value (see plot). John and I discussed that this should mean that sigma is actually larger under high human influence, i.e., a large noneuc makes things effectively closer together, shrinks the space, therefore this means in reality that sigma is larger and the animals are moving more/farther in areas of high human influence?

 

Hopefully this 1) can help someone else with these models, and 2) can stimulate discussion on how to interpret…

 

Cheers,

Clayton

 

Image removed by sender.



On Sep 11, 2018, at 10:28 AM, John <john....@maine.edu> wrote:

 

Clayton,

You sure you are using the right user distance function? In the vignette, fn2 is used for landscape resistance models.

--
You received this message because you are subscribed to the Google Groups "secr" group.

To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
Clayton Lamb, PhD Candidate
South Rockies Grizzly Bear Project
S.Boutin and S.Nielsen Labs
Biological Sciences, University of Alberta 
e: 
ctl...@ualberta.ca
p: 778-215-0334
t: 
@ClaytonTLamb
w: 
www.lamb-eco-research.ca

 

--
You received this message because you are subscribed to the Google Groups "secr" group.

To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

~WRD000.jpg
image002.png

John Clare

unread,
Sep 14, 2018, 11:18:57 AM9/14/18
to Chris Sutherland, Clayton Lamb, secr
Yeah, I think dropping the intercept is the most straightforward approach, or at least, it saves deriving sigma as the product of ‘fixed’ sigma and the intercept after the fact. (Sorry, Clayton—I’ve had a more favorable coffee load for thinking today than the last few!)

Interesting to see the scaling issue. I guess I would have expected that rescaling the value of a2 by multiplying it by the consensus variate sd would have produced the same thing. Yikes!

On Sep 14, 2018, at 9:42 AM, Chris Sutherland <chris...@gmail.com> wrote:

Hi John,

 

Thanks. Indeed, all the applications we use and the way our fitting function is set up is to drop the intercept, although recently we have considered exploring ways of/reasons to include the intercept – like those Murray has implemented (by we, I mean the Royle et al scr-connectivity paper and the Sutherland et al non-euc paper).

 

So, if I understand you correctly, fitting the ~X-1 model means you don’t have to assume a sigma value like Clay did? Seems like a better solution.

 

Regarding the cost function, and given it is the same formulation as I am familiar with (thanks for saving me the reading J), here is some behavior I found when standardizing covariate cost surfaces (this is just an fyi I found interesting, and potentially probalematic):

 

Basically, if d_cost = f(d_euc * cost), consider the example where the resistance parameter is positive, i.e., cost function should evaluate to > 1 and d_cost should be greater than d_euc. Good to think of just a single move from one pixel to a neighbor here, but it scales to the path. This script shows that constraint isn’t respected when the covariate is negative to positive as is the case with scaling.

 

I might be wrong here, so happy to be corrected!

 

a2 <- 0.5                    #positive cost

cov <- seq(0,3,length=20)     #some values of (c1-c2)/2 covariate values

covS <- scale(cov)           #scaled

 

#evaluate the toy cost function

cost1 <- exp(a2 * cov)

cost2 <- exp(a2 * covS)

 

#plot it

par(mfrow=c(1,2))

plot(cost1 ~ cov,ylim=c(0,5)); abline(h=1)

plot(cost2 ~ cov,ylim=c(0,5)); abline(h=1)

 

<image002.png>

 

 

 

From: John Clare <john....@maine.edu>
Sent: Friday, September 14, 2018 10:08 AM
To: Chris Sutherland <chris...@gmail.com>
Cc: Clayton Lamb <ctl...@ualberta.ca>; secr <secr...@googlegroups.com>
Subject: Re: Connectivity models: Continuously varying σ using gdistance

 

Murray can certainly answer more thoroughly or correct me, but I think the parameters associated with noneuc are fit using a log-link (with an intercept by default). The userdistance function and calls to noneuc seem to do a lot of things, but in the context of landscape resistance, if a1 = 1/(2 * sigma^2), log(cost) = a2 + a3 (z(x)+z(x'))/2 with one covariate. A call to noneuc~1 (without fixing sigma) introduces what looks like nonidentifiability of sigma and noneuc, or nonidentifiability of a1 and a2 above. Things either move farther, or spaces are closer together—many possible combinations are (equally) likely. Fitting a model with noneuc ~ covariate retains an intercept for noneuc, so same issue. So it seems like either one must be fixed (distance or a2 is known, and sigma is uncertain, or sigma is 'known' but a2 is uncertain) or the intercept must be specified as nonexistent within the model call (e.g., noneuc~covariate-1), in which case log(cost) =  a2 (z(x)+z(x'))/2. This is how it's described in the 2013 paper.  noneuc~covariate-1 probably would have been a much quicker solution!

 

 

 

 

 


On Sep 14, 2018, at 12:19 AM, Chris Sutherland <chris...@gmail.com> wrote:

Interesting stuff here. 

 

I'm curious (and will read up about) the rationale behind fixing sigma, and whether there is a link function for the noneuc model? My understanding of the cost distance functions in R, which i assume are being used here (?) is that there is a d_cost = d*cost calculation,  and having a cost surface the goes negative can cause problems depending on  the link function.

 

Will be keeping an eye on this thread - lots to still learn about these models!

 

Chris

 

On Thu, Sep 13, 2018, 23:08 Clayton Lamb <ctl...@ualberta.ca> wrote:

Just an update: John and I had a productive discussion in a side thread and I think we found the issue to my problem, which was 0’s in my variance covariance matrix and SE’s for the noneuc parameter.

 

The issue was related to fixing sigma at 1, which was perhaps too small for grizzly bears.. So I set it to an average sigma value for the species of 6000 and the models began to fit much better. 

 

The working model looks like this:

csecr.hii <- secr.fit(capthist = grizzCH.d, mask = GBmask.d,detectfn = "HHN",
                       details = list(userdist = fn3), model = list(D ~ 1, noneuc ~ hii, lambda0~bk + Trap_Type),
                      start=csecr.null, fixed = list(sigma = 6000))

 

The final piece is interpreting what the results from the model mean. The noneuc.hii parameter (human influence index) had a negative beta value (see plot). John and I discussed that this should mean that sigma is actually larger under high human influence, i.e., a large noneuc makes things effectively closer together, shrinks the space, therefore this means in reality that sigma is larger and the animals are moving more/farther in areas of high human influence?

 

Hopefully this 1) can help someone else with these models, and 2) can stimulate discussion on how to interpret…

 

Cheers,

Clayton

 

<~WRD000.jpg>



On Sep 11, 2018, at 10:28 AM, John <john....@maine.edu> wrote:

 

Clayton,

You sure you are using the right user distance function? In the vignette, fn2 is used for landscape resistance models.

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

--
Clayton Lamb, PhD Candidate
South Rockies Grizzly Bear Project
S.Boutin and S.Nielsen Labs
Biological Sciences, University of Alberta 
e: 
ctl...@ualberta.ca
p: 778-215-0334
t: 
@ClaytonTLamb
w: 
www.lamb-eco-research.ca

 

--
You received this message because you are subscribed to the Google Groups "secr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Murray Efford

unread,
Sep 14, 2018, 9:51:01 PM9/14/18
to secr
The rationale for fixing sigma is on p10 of secr-noneuclidean.pdf; it's implied but not stated that sigma and noneuc are confounded (John's point). The default link function for noneuc is log.
I suspect Clayton's original issue could have been fixed by choosing a better start value for noneuc. Note I suppressed the intercept when emulating Chris's 2014 example in the appendix to secr-noneuclidean.pdf.

<~WRD000.jpg>



To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
Clayton Lamb, PhD Candidate
South Rockies Grizzly Bear Project
S.Boutin and S.Nielsen Labs
Biological Sciences, University of Alberta 
e: 
ctl...@ualberta.ca
p: 778-215-0334
t: 
@ClaytonTLamb
w: 
www.lamb-eco-research.ca

 

--
You received this message because you are subscribed to the Google Groups "secr" group.

To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

Chris Sutherland

unread,
Sep 14, 2018, 9:59:56 PM9/14/18
to Murray Efford, secr

Thanks Murray!!

<~WRD000.jpg>

 

To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

 

--
Clayton Lamb, PhD Candidate
South Rockies Grizzly Bear Project
S.Boutin and S.Nielsen Labs
Biological Sciences, University of Alberta 
e: 
ctl...@ualberta.ca
p: 778-215-0334
t: 
@ClaytonTLamb
w: 
www.lamb-eco-research.ca

 

--
You received this message because you are subscribed to the Google Groups "secr" group.

To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.

<Screen Shot 2018-09-13 at 8.38.20 PM.png>

--

You received this message because you are subscribed to the Google Groups "secr" group.

To unsubscribe from this group and stop receiving emails from it, send an email to secrgroup+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages