I would like to forecast the probability of a binary outcome using logistic regression at t+1, using all previous data points. I am new to forecasting so any help would be appreciated.

The raw data is in the form:

Time | Correct
1      0
1      1
2      1
3      0
3      0
3      1
4      1
5      0

I have averaged the data over each day to produce:

Time | AVG. Correct
1      0.5
2      1
3      0.3
4      1
5      0

I know that there is a linear trend in the data, such that as time progresses the average correct value increases.

Using this information would it be possible to use logistic regression to forecast the next time step (t = 6). How would you account for the linear trend in the data for a logistic regression model?.


You could fit a simple logistic regression model and include time as a covariate, this would imply a linear time trend.

Note that in the regression, the time trend is negative and insignificant – you simply have too few observations to make any statements regarding the coefficient of a linear time trend.

See this R-code:

# data input
dat <- data.frame(time=c(1,1,2,3,3,3,4,5),

res <- glm(correct ~ time + 1, data=dat, family=binomial)

# the time trend is negative and insignificant!

# predict 'correct' probability at time t=6
predict(res, newdata=data.frame(time=6), type="response")

# 0.2710599 
  • 1
    $\begingroup$ Thanks for your response, the data is just a made up example. Could you please explain what you mean as having the time as the covariate? $\endgroup$ – Sagar Patel Jun 13 '17 at 17:28
  • $\begingroup$ I mean that time should be a right-hand-side variable (regressor, covariate, independent variable, explanatory variable) in a logistic regression model. $\endgroup$ – mzuba Jun 14 '17 at 12:09
  • $\begingroup$ This is attempting to model correctness as a function of time? But...just...why? $\endgroup$ – bibliolytic Oct 5 '17 at 13:05
  • $\begingroup$ 'correct' is simply the name of the LHS variable. I do not think that it has a meaningful interpretation in the context of modelling itself. $\endgroup$ – mzuba Oct 5 '17 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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