**Ln ((D**[equation 1a]

_{i}/(1 – D_{i})) = βX**D**= probability y = 1 =

_{i}**e**[equation 1b ]

^{Xβ}/ ( 1 + e^{Xβ})Where :

**D**= ’odds ratio’ or ’odds’

_{i}/ (1 – D_{i})**E[y|X] = Prob(y = 1|X) = p = e**[equation 1c]

^{Xβ}/ (1 + e^{Xβ})In other words, the probability that y = 1 can be represented by the logistic function:

**e**[ equation 1d] or substituting t for XB:

^{Xβ}/ ( 1 + e^{Xβ})**e**[equation 1e]

^{t}/ ( 1 + e^{t})Often, we will see the logistic function represented as:

**1/ ( 1 + e**[equation 2]

^{-t})Algebraically, one could show that these are equivalent, or alternatively, you could evaluate the functions numerically and graphically using R.

Graphing the formulation in equations 1b-1e or

**e**in R gives the following:

^{t}/ ( 1 + e^{t}){code}

# define t-values

t <- seq(-4, 4, length=100)

# sigmoid/logistic = exp(t)/(1 + exp(t))= probability y =1

y <- exp(t)/(1 + exp(t))

plot(t, y, type="l", lty=2, xlab="t value",

ylab="Density", main="Sigmoid/Logistic Distribution exp(t)/(1 + exp(t))")

Graphing 1/ ( 1 + e

^{-t}) gives the following:

{code}

# sigmoid/logistic = 1/(1 + exp(-t))= probability y =1

y <- 1/(1 + exp(-t))

plot(t, y, type="l", lty=2, xlab="t value",

ylab="Density", main="Sigmoid/Logistic Distribution 1/(1 + exp(-t))")

You can also show, numerically, that both functions give the same value evaluated at the same level of t:

**t = 4 ( or XB = 4)**

**e**

^{4}/ ( 1 + e^{4}) = 0.9820138

**1 / ( 1 + e**

^{-4}) = 0.9820138{ code}

t <-4

exp(t)/(1+ exp(t))

1/(1+exp(-t))

I also defined the likelihood function as follows:

**L(β) = ∏f(y, β) = ∏ e**[equation 3]

^{Xβ}/ (1 + e^{Xβ}) ∏ 1/(1 + e^{Xβ})Which is (probability y=1)*(probability y = 0) or the joint density of y.

We've already worked with probability y = 1;

**e**If 'p' is the probability y = 1, then 1-p would give the probability that y = 0. This would be

^{t}/ ( 1 + e^{t}).**1 - [e**. This turns out to be the term in the second product above in equation 3.

^{t}/ ( 1 + e^{t})]**(prob y =0) = 1/ ( 1 + e**[equation 4]

^{t})Note, this is different from equation 2 in that the 't' is positive and not negative. We can check that these equations give the correct results numerically as follows:

**For t = 3, p(y = 1) :**

**e**

^{4}/ ( 1 + e^{4}) = 0.9820138

p(y = 0) = 1/ ( 1 + e

p(y = 0) = 1/ ( 1 + e

^{4}) = 0.01798621Note, the simpler calculation (1-p) gives us the same result: 1-0.9820138 = 0.0179862

{code}

1/(1+exp(t))

This can be graphed as well:

{code}

y0 <- 1/(1 + exp(t))

plot(t, y0, type="l", lty=2, xlab="t value",

ylab="Density", main="Sigmoid/Logistic Distribution 1/(1 + exp(t))")

## No comments:

## Post a Comment

Note: Only a member of this blog may post a comment.