2
$\begingroup$

I am looking at how landscape features might impact the presence of bat species using a binomial linear regression model in R. An example of one of my model is:

model <- lm(presence ~ distance_to_wood_rescaled
                      + distance_to_roost_rescaled
                      + Decid_%_cover
                      + Conif_%_cover
                      + Arable_%_cover
                      + Grass_%_cover
                      , data = data)

However, we know that as you move away from their roost you are less likely to record their presence. To account for this I wanted to use exp(distance_to_roost_rescaled) as its a decaying exponential curve. However, I am not sure if this is correct or whether this needs to be taking into account before being input into the model? How does one account for exponential decay of presence records as you move away from the roost?

EDIT

enter image description here

$\endgroup$

2 Answers 2

0
$\begingroup$

To fit a binomial, you need to do:

model <- glm(presence ~ distance_to_wood_rescaled
                      + distance_to_roost_rescaled
                      + Decid_%_cover
                      + Conif_%_cover
                      + Arable_%_cover
                      + Grass_%_cover
                      , data = data,family="binomial")

In the example code provided, you are fitted a regression model assuming gaussian distribution. To see whether you need to introduce the exponential, I guess you can visualize it like:

hist(data$distance_to_wood_rescaled[data$presence==1])

Assuming your presence is a binary 0,1.

Now regarding whether you need to model that exponential, it really depends on what your data looks like. My guess is that because we model the log-odds, you don't need to transform your data.

So let's assume a scenario where :

$$\frac{p}{1-p} = b_0 exp( b_1 * D)$$

where $D$ is the distance, $p$ is the probability of bat being present and $b_0$ and $b_1$ are constants.

We can simulate the data and you can see your distances will look like:

set.seed(222)
D = runif(1000,min=0,max=10)
OR = 5*exp(-1.25*D)
p = OR/(1+OR)
presence = rbinom(length(D),1,p)

par(mfrow=c(2,2))
plot(D,log(OR),ylab="Log odds (present)",xlab="distance",main="log odds vs Distance")
plot(D,p,ylab="Probability (present)",xlab="distance",main="prob vs dist")
hist(D[presence==1],cex.main=0.7,main="distribution of distances where present")
hist(D[presence==0],cex.main=0.7,main="distribution of distances where absent")

enter image description here

So you can see the distances of presence looks somewhat like an exponential decay. To summarize, in the linear model, we would model it as:

$$ log(\frac{p}{1-p}) = log(b_0) + b_1*D$$

So if your distances for present look like the above, I think the model you have now is ok, just remember to use glm() with binomial.

$\endgroup$
6
  • $\begingroup$ Thank you for your answer @StupidWolf. Unfortunately the absence data doesn't quite conform to your outputs above (I have edited my question to add in my graphs). Do you have any suggestions? as we want to account for those sites being further away having equal weight as those close by. Thanks. $\endgroup$
    – DFinch
    Jun 26, 2020 at 9:22
  • $\begingroup$ Hi @DFinch sorry i did not explain it clearly.. the top 2 plots i showed, those are simulated.. it will not be known in your data. you should only have the bottom 2 with distances and i assume thats what you have plotted $\endgroup$
    – StupidWolf
    Jun 26, 2020 at 9:24
  • $\begingroup$ If you are telling me that is the distribution, then seems like that distance doesn't have much of an effect.. so you can just leave it in the model as it is $\endgroup$
    – StupidWolf
    Jun 26, 2020 at 9:26
  • $\begingroup$ There is an option to add weights=.. within glm, but right now i think it's not very clear how you would like to implement this.. so how about just running the model first and see whether it makes sense? $\endgroup$
    – StupidWolf
    Jun 26, 2020 at 9:29
  • $\begingroup$ Ah ok. Thank you very much. I will run the models and see what they look like. $\endgroup$
    – DFinch
    Jun 26, 2020 at 9:41
0
$\begingroup$

If you are adding a term exp(distance_to_roost_rescaled) to your linear model then you are fitting a model that is very restricted.

Namely, it has a fixed rate of decrease of a factor $1/e \approx 0.37$ for every unit change in the distance.

Instead, often one would like to use a model that is able to have variable rate of decrease. Or at least, often there is no a priori knowledge about the rate and the model estimates the rate for which the fit is best.

It is possible to fit exponential models with a GLM (generalized linear model) that allows to have a linear function wrapped inside a non-linear function. For more complicated cases you can use a method that uses some optimiser algorithm (e.g. gradient descent).

For the R statistical language, you can read into the functions glm and nls .

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.