# How to do logistic regression in R when outcome is fractional (a ratio of two counts)?

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?

• Here are some examples regarding a multivariate outcome logistic regression: http://www.ats.ucla.edu/stat/r/dae/mlogit.htm Nov 25, 2013 at 21:43
• What you describe doesn't sound like you'll have independent observations (since cells presumably don't reattach as the shear is increased, the number still attached at each higher stress setting must be no more than the previous number); this dependence must be taken into account. (It's reminiscent of the situation with growth curves.) --- you can't just plug the numbers into a GLM as if they were independent... and none of the answers seem to address this issue. Nov 26, 2013 at 0:34
• @Glen_b Each experiment would be done with different cells, i.e. starting with "100%" attachment and applying a different value of shear stress. Nov 26, 2013 at 22:29
• Ah, okay. That would give independent results. Nov 26, 2013 at 22:32
• Oct 10, 2016 at 10:59

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.

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. Apr 19, 2012 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. Apr 19, 2012 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]... Apr 19, 2012 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. Apr 19, 2012 at 19:07