Search code examples
plotjuliaglmplots.jl

Julia: GLM plot logit function


I am working with a lot of data an just calculated a logistic regression using glm in julia. What I do is to check different effects on the job finding rate, which I have as 0 or 1. Now I would like to plot my results. I have the gilman/hill book where they do a similar exercise but in R (also with glm). What they do to plot is:

fit.1 <- glm(switch ~ dist, family=binomial(link="logit"))

jitter.binary <- (a, jitt=.05){
  ifelse(a==0, runif(length(a), 0, jitt), runif(length(a), 1-jitt, 1))
  }

switch.jitter <- jitter.binary(X)
plot(dist, switch.jitter)
curve(invlogit (coef(fit.1)[1] + coef(fit.1)[2]*x), add=TRUE)

My question is quite basic I think, how can I do something similar in julia as I am not very fond of the R code. And for plots I use Plots.jl

I hope someone will be able to help me, and if you need more information just let me know.

Cheers


Solution

  • using Plots
    plot(x, predict(fit1), seriestype = :line) #where x is your predictor variable
    

    Updated to include @pkofod 's comment