Simply Explained Logistic Regression with Example in R

Keep in mind that the main premise of logistic regression is still based upon a typical regression model with a few methodical changes.Now, to find the probability of desired outcome, two things we must always be followed.1- That the probability can not be negative, so we introduce a term called exponential in our normal regression model to make it logistic regression.2- Since the probability can never be greater than 1, we need to divide our outcome by something bigger than itself.And based on those two things, our formula for logistic regression unfolds as following:1..Regression formula give us Y using formula Yi = β0 + β1X+ εi.2..We have to use exponential so that it does not become negative and hence we get P = exp(β0 + β1X+ εi).3..We divide that P by something bigger than itself so that it remains less than one and hence we get P = e( β0 + β1X+ εi)/e( β0 + β1X+ εi) +1.4..After doing some calculations that formula in 3rd step can be re-written as log(p/(1-p)) = β0 + β1X+ εi.5..log(p/(1-p)) is called the odds of probability..If you look closely it is the probability of desired outcome being true divided by the probability of desired outcome not being true and this is called logit function.Working:When you calculate total number of 1s and 0s you can calculate the value of log(p/(1-p)) quite easily and we know that this value is equal to β0 + β1X+ εi..Now you can put that value into the formula P = e(β0 + β1X+ εi)/e( β0 + β1X+ εi) +1 and get the value of P..That P will be the probability of your outcome being TRUE based on some given parameters.From a different perspective, let’s say you have your regression formula available with intercept and slope already given to you, you just need to put in the value of X to predict Y..But you know in logistic regression it doesn’t work that way, that is why you put your X value here in this formula P = e(β0 + β1X+ εi)/e( β0 + β1X+ εi) +1 and map the result on x-axis and y-axis..If the value is above 0.5 then you know it is towards the desired outcome (that is 1) and if it is below 0.5 then you know it is towards not-desired outcome (that is 0).A little bit of touch to Exponent’s functionalityLet say you have invested a dollar somewhere..Now in a year it will grow 50% of its previous value, so in 2018 if it was $1 then in 2019 it becomes $1.5 and in 2020 it becomes $2.25.. More details

Leave a Reply