Turning Logistic Binomial Regression with one Continuous and one Categorical predictor into an equation

32 Views Asked by At

Basically, I have this data in which the response variable is a binary outcome (1 or 0), no visits or there was a visit. The two predictor variables are Box Height (High or Low) and Distance to Pasture (km). The model works all fine, but I can't seem to find the probability for say, when distance is 0 and box height is High.

marsupials <- read.csv("Marsupial_Data.csv") # same with this


###Distance and Height model
fit1 <- glmer(Visit ~ PastureDistance + BoxHeight * (1|Site), data=marsupials, family=binomial(link="logit"))

#summary (gives co-efficients)
summary(fit1) 


#prediction times
# predict using the model
predictions <- predict(fit1, marsupials)
predictions



xv <- seq(min(marsupials$PastureDistance), max(marsupials$PastureDistance), 0.01)
yv <- predict(fitDis, data.frame(PastureDistance = xv), type = "response")


#The Jitter Plot
ggplot(marsupials, aes(PastureDistance, Visit, color = BoxHeight))+
  geom_point(size= 4, position=position_jitter(h=0.02,w=0.00))+ 
  scale_color_manual(values = c("darkgreen", "brown"), name = "Nest Box Height")+
  stat_smooth(size = 2, method = "glm", method.args = list(family = binomial), colour = "#4B2D0B")+
  theme_classic()+
  xlab("Distance to Pasture (km)")+
  ylab("Presence")+
  labs(fill = "Box Height")+
  theme(axis.title = element_text(size=18),
        axis.text = element_text(size=18),
        legend.text = element_text(size=12),
        legend.title = element_text(size=14))

Here's my code. I have to apologise as I am really quite new to all this so my explanations and my layout aren't the best.

The summary gives me co-efficients but I can't quite figure out how to interpret them.

Here is an image because I cannot format apparently: enter image description here

i understand if you use exp(-19.064) you are meant to get the probability but this doesn't seem right to me as it gives a probibility of 5.255451e-09 which is uhhh... very small chance.

Here's what my data looks like: (https://i.stack.imgur.com/Pjx8H.png)

Any help would be muchly appreciated

0

There are 0 best solutions below