0
$\begingroup$

Suppose I have a simple dataset of numerous observations, each with a continuous numerical variable $x$ and a binary numerical variable $y$ (with values 0 for unsatisfactory, 1 for satisfactory).

How can I predict how many of many of my observations would satisfy $y=1$ when the average $x$ in my dataset increases, say by 50%?

I was thinking of starting with a logistic regression model, but I'm not sure how to proceed.

Any guidance would be much appreciated.

$\endgroup$
2
  • $\begingroup$ Hi @ezrarusk, what do you mean by "I'm not sure how to proceed?". Are you using a specific software/language (R, Pythom, SAS)? $\endgroup$
    – lulufofo
    Commented Mar 27 at 6:34
  • $\begingroup$ @lulufofo I'm using R $\endgroup$
    – ezrarusk
    Commented Mar 30 at 20:07

1 Answer 1

1
$\begingroup$

You can fit a model and use it to predict the probability of any given instance to be $1$, conditional on your predictor value.

As you write, one possible model is a logistic regression.

Note that the effect of increasing the predictor by 50%, or by any other increment, will depend on what you increase the value from. Here is some R code that illustrates this (note the type="response" part in the predict()s that ensure we gat probability predictions):

set.seed(1)
xx <- runif(100)
prob <- 1/(1+exp(-(xx+0.5)^2-2*(xx-0.5)))
obs <- runif(length(xx))<prob

model <- glm(obs~xx,family="binomial")

xx_plot <- seq(min(xx),max(xx),by=0.01)
plot(xx,obs,pch=19)
lines(xx_plot,
    predict(model,newdata=data.frame(xx=xx_plot),type="response"),
    col="red")

predict(model,newdata=data.frame(xx=c(0.6,0.9)),type="response")
# 0.7800048 0.9282456
predict(model,newdata=data.frame(xx=c(0.2,0.3)),type="response")
# 0.3869597 0.4928357

If you can now assume that your instances are independent, you can calculate the expected number of $y=1$ for each predictor value. Or use the binomial distribution to get a handle on the entire distribution of the number of $1$s for a constant predictor value, or possibly generalizations of the binomial for different probabilities coming from different predictor values.

$\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.