Question on Log-Likelihood. Thanks in advance.

#1
Question is: There are two lists of data, Y and X. Y is either 1 or 0, and X can be any number. And I have a logistic regression of Logit=B1*X, where B1 is the coefficient of X, and Logit is the Logit of Prob(Y=1).

Now, the question asks me to plot "Log-Likelihood versus B1". I only know how to get a single value of log-likelihood in R (logLik function), by passing in the logit regression.

So what exactly does he mean by plotting log-likelihood versus B1, even though my understanding is that log-likelihood is only a value?

Anyone know of any command in R that can do it?

Thanks in advance!
 
#2
Interesting. I was just messing with something similar for my research (it's about penalized logistic regression with unobserved catagorical covariates, but anyway...)

Here's the deal. Think back to your math stat class and someone says whats the log likelihood function associated with a binomial process? You'll have a function that sums over stuff involving p_i. You'll need a binomial index, a realization, and probability. The index might be 1, and the realization might be 0 or 1.


In a logistic regression those p's are modeled as 1/(1+exp(-eta_i)). Where eta is a line from the design matrix corresponding to the ith probability--matrix multiplied against beta. That is, eta_i = X_i * b. As beta changes so does p. And consequently so does the log likelihood of what you observed.

In this case \(p_i = 1/(1+exp(-x_i*b))\)

The trick then is to set up a seq(low_b, high_b) in R for the beta(b). Recalculate the vector of p_i (one per a row in your design.. ie one per an x) for each new b in the sequence. Then recalculate the log likelihood. And then plot log likelihood versus b.

Now there maybe an automated way to do this in R, I dunno. But it really only takes a bit.
 
Last edited by a moderator: