Weird predicted values from a distamp model

121 views
Skip to first unread message

Laura Cespedes

unread,
Jul 14, 2016, 9:48:31 AM7/14/16
to unmarked

Hello everyone,

Recently I asked if using backTransform is necessary before using predict to handle models constructed using distsamp. Reading previous posts I realize that I can just use predict, and not use backTransform but I am getting strange results. I have fitted several models using distsamp that includes categorical and continuous variables. I choose the best model for my data based on Akaike weights and now I am want to plot the results. The selected model has one categorical (habitat type, four categories) and one continuous site covariate (elevation) . Then I used the predict function , but I am getting very strange results when I predict for different values of elevation (continuous variable) keeping habitat constant (continuous variable). I get almost a straight line with negative slope, and I know from my raw data that the abundance at sites with very low elevation is extremely low (is almost 0). The results look really strange. Anybody know what can be happening? Below some of my code and results and attached the graph of the results:

#This is the best fit model that includes two variables explaining the state. I already try to use the other "keyfun" and results are consistent. I also checked the goodness of fit.
EH <- distsamp(~1~Elevation_meters+Updated_Habitat,  data, keyfun = "hazard")

#Data frame keeping habitat type constant. What I want is to see how abundance changes with elevation. This are the results that seem weird
habConst <-data.frame(Elevation_meters=seq(500,3500,length=20),Updated_Habitat=factor("Primary_forest",levels=unique(c$Updated_Habitat)))
pHabCost <-predict (EH,type="state",newdata=habConst,appendData=TRUE)

Predicted        SE    lower    upper Elevation_meters Updated_Habitat
1  4.823703 0.9515307 3.276961 7.100514         500.0000  Primary_forest
2  4.316239 0.8334872 2.956203 6.301976         657.8947  Primary_forest
3  3.862162 0.7305678 2.665735 5.595567         815.7895  Primary_forest
4  3.455855 0.6408574 2.402746 4.970536         973.6842  Primary_forest
5  3.092292 0.5626765 2.164687 4.417392        1131.5789  Primary_forest
6  2.766977 0.4945531 1.949247 3.927754        1289.4737  Primary_forest

I really appreciate if somebody can help me with this. What am I doing wrong? Thank you very much in advance!

Best,

Laura

predicted_elevation.pdf

Dan Linden

unread,
Jul 14, 2016, 9:53:37 AM7/14/16
to unmarked
Hi Laura, can you post the fitted model summary?

Laura Cespedes

unread,
Jul 14, 2016, 10:04:59 AM7/14/16
to unmarked
Hi Dan,

Thank you very much for your reply. Below the summary of the model:

Call:
distsamp(formula = ~1 ~ Elevation_meters + Updated_Habitat, data = data,
    keyfun = "hazard")

Density:
                                                             Estimate       SE            z  P(>|z|)
(Intercept)                                            1.112545   0.653367   1.703 8.86e-02
Elevation_meters                                -0.000704   0.000048  -14.681 8.57e-49
Updated_HabitatPrimary_forest          0.812995   0.636558   1.277 2.02e-01
Updated_HabitatSecondary_Growth -0.130172   0.729464  -0.178 8.58e-01
Updated_HabitatShade_coffee           0.395834   0.666968   0.593 5.53e-01
Updated_HabitatSun_coffee              -0.109645   0.947534  -0.116 9.08e-01

Detection:
 Estimate    SE    z   P(>|z|)
      2.6 0.118 22.2 8.16e-109

Hazard-rate(scale):
 Estimate    SE    z  P(>|z|)
     1.16 0.136 8.52 1.55e-17

AIC: 1426.65 

You think the error can be in this step? The raw data suggest almost an unimodal relationship between elevation and abundance, and these predicted values just seem weird. Thank you very much for your answer!

Best,

Laura

Dan Linden

unread,
Jul 14, 2016, 10:19:11 AM7/14/16
to unmarked
The model coefficient suggests a negative linear relationship between density and elevation.  Have you tried adding a quadratic effect?  Straight linear relationships with environmental gradients are sometimes not reasonable.

I would also suggest scaling your elevation values (km instead of m) and/or standardizing them. 

Laura Cespedes

unread,
Aug 3, 2016, 10:22:47 AM8/3/16
to unmarked
Hello everyone,

Just to post the solution of my problem. Thanks to the help of Dan Linden I figured most of things out. The main problem that I had is that I was only fitting models with linear relationships between elevation and abundance. So I fit quadratic models, the AIC values are lower and the results actually make sense! Also, when fitting this models I used the scale function. 

The selected model still includes one categorical and one continuous variable, and now I am having problems with the prediction for the categorical variable. But I will leave that for another post...

Best,

Laura
Reply all
Reply to author
Forward
0 new messages