8
$\begingroup$

I have the following generalized linear model. The object glmDV is modeled as a proportion of successes over total trials. The objects x_i are continuous variables.

What does this look like in mathematical notation?

winp.glm = glm(glmDV ~ x1 + x2 + x3 + x4 + x5 + x6 + x7, 
               data=myData, family=binomial("logit"))
$\endgroup$
  • 1
    $\begingroup$ Note that, if your response is a proportion instead of a set of 0s & 1s (which I gather is what you have based on your description), you should use a weights argument w/ ?glm, where the weights are the number of total trials for each observation. $\endgroup$ – gung - Reinstate Monica Mar 2 '17 at 16:19
10
$\begingroup$

For a binary logistic regression, the usual use case for the binomial GLM with a logit link, you're modeling the probability that your dependent variable is a "success" (or "yes"), conventionally coded as $1$. The way that you're doing this is by modeling the log odds. So rather than modeling the mean of the response as in OLS, you're modeling the change in the log odds: $$\Pr(y=1)=\theta=\text{logit}^{-1}(\beta_0+\beta_1x_1+\beta_2x_2+...+\beta_7x_7)$$

Where $\text{logit}(x)=\log(\frac{x}{1-x})$ and $\text{logit}^{-1}(x)=\frac{\exp(x)}{1+\exp(x)}$.

A more thorough, very approachable explanation of this can be found in Agresti, An Introduction to Categorical Data Analysis.

But to your particular question, you state that you're modeling the proportion of successes. This is not actually what a binomial GLM is used to do. However, what you're really after is what a binomial GLM does, and is still possible in R. It just requires a slight tweak to what you're doing. In the case where you have a finite number of trials $n$ which may have $y \in \{0...n\}$ successes, you can still use the same model, which has density $$\Pr(y) \sim \binom{n}{y}\theta^y(1-\theta)^{n-y}$$ Because your values $n$ are fixed by experimental design, and $y$ is your observed successes, you're performing inference on the parameter $\theta$ in the same way as the more typical binary response case (above), in which $n$ is fixed at 1, $y$ takes the value 1 with probability $\theta$, and $\theta$ is a function of your parameters. For the case of the logit link, then we model $$\text{logit}(\theta)=\beta_0+\beta_1x_1+...+\beta_ix_i$$, chiefly because this transformed $\theta$ exists on the whole real line, rather than the unit interval. (Other desirable properties of the logit link are described in Agresti, including validity of the coefficients even in settings where nonrandom samples like case-control designs are used; this is not the case for, e.g., probit link functions.)

In terms of R, simply create an object (which you term glmDV) that is a 2-column matrix, the first column the number of successes $y$ and the second the total number of failures $n-y$. The rest of the statement remains the same!

$\endgroup$
  • $\begingroup$ This cross-validation was very helpful. I will check Agresti out at the library. Thank you for your help. $\endgroup$ – user2205916 Jan 16 '14 at 13:16
  • $\begingroup$ @Sycorax or @user2205916, specifically how do you pass the "2-column matrix" containing numbers of successes and failures to R, and how does R make use of this? I am familiar with the use of glm and, to my knowledge, it only accepts a 1 column response variable, not two columns. Please correct me if I am wrong and cite relevant documentation if possible. Thank you! $\endgroup$ – clarpaul Mar 2 '17 at 15:45
  • $\begingroup$ @clarpaul stat.ethz.ch/R-manual/R-patched/library/stats/html/glm.html First paragraph of "Details" in the glm documentation. A good way to learn about how R functions work is to Google the function name; this usually turns up the relevant documentation. You can also type ?glm into an R console $\endgroup$ – Reinstate Monica Mar 2 '17 at 15:55
  • $\begingroup$ @Sycorax, thank you for looking that up for me. I put it into practice yesterday, and it seemed to work! $\endgroup$ – clarpaul Mar 4 '17 at 13:50

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.