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