# How to do logistic regression in R when outcome is fractional?

I'm reviewing a paper which has the following biological experiment. A device is used to expose cells to varying amounts of fluid shear stress. As greater shear stress is applied to the cells, more of them start to detach from the substrate. At each level of shear stress, they count the cells that remain attached, and since they know the total number of cells that were attached at the beginning, they can calculate a fractional attachment (or detachment).

If you plot the adherent fraction vs. shear stress, the result is a logistic curve. In theory, each individual cell is a single observation, but obviously there are thousands or tens of thousand of cells, so the data set would be gigantic, if it was set up in the usual way (with each row being an observation).

So, naturally, my question (as stated in the title) should make sense now. How do we do a logistic regression using the fractional outcome as the D.V.? Is there some automatic transform that can be done in glm?

Along the same lines, if there were potentially 3 or more (fractional) measurements, how would one do this for a multinomial logistic regression?

-

The glm function in R allows 3 ways to specify the formula for a logistic regression model.

The most common is that each row of the data frame represents a single observation and the response variable is either 0 or 1 (or a factor with 2 levels, or other varibale with only 2 unique values).

Another option is to use a 2 column matrix as the response variable with the first column being the counts of 'successes' and the second column being the counts of 'failures'.

You can also specify the response as a proportion between 0 and 1, then specify another column as the 'weight' that gives the total number that the proportion is from (so a response of 0.3 and a weight of 10 is the same as 3 'successes' and 7 'failures').

Either of the last 2 ways would fit what you are trying to do, the last seems the most direct for how you describe your data.

-
Awesome. Thank you! – thecity2 Apr 19 '12 at 20:19
@EvanZ: don't forget to accept this answer if it solves your problem ... – Ben Bolker Apr 19 '12 at 20:47

As a start, if you have a dependent variable that is a proportion, you can use Beta Regression. This doesn't extend (with my limited knowledge) to multiple proportions.

For Beta Regression overview and an R implementation check out betareg.

-
 Thanks! That looks like what I need for the binomial case. – thecity2 Apr 19 '12 at 16:15

I'v been using nnet::multinom (package nnet is part of MASS) for a similar purpose, it accepts continuous input in [0, 1].

-
 Great! I have that package, and didn't realize it had this capability. – thecity2 Apr 19 '12 at 16:15 @cbeleites: Does it allow the dependent to be [0,1]? I though that was a function for a nominal dependent (predictors should be scaled to [0,1]... – B_Miner Apr 19 '12 at 17:27 @B_Miner: yes, the dependent can be in [0, 1]. The function fits an artificial neural network without hidden layer and with logistic sigmoid. And yes, it is recommended to scale the predictors roughly to [0, 1] as well for better convergence. – cbeleites Apr 19 '12 at 19:07