'How to use glmnet in R with response variables that are proportions

I am trying to run a penalized logistic regression in R. My response variables are proportions (they are winning percentages for a sports team), and I have the number of total games played by each team.

My impression from the documentation for glmnet is that I should be able to run glmnet to get penalized logistic regression for these proportions, as long as I make the weights the number of games played.

However, when I run this code

fit = glmnet(mat, wins/games ,family = "binomial", weights = games)

I get this error:

Error in lognet(xd, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : 
one multinomial or binomial class has 1 or 0 observations; not allowed

This error seems to be the standard error for trying to run logistic regression on non-binary responses. But the documentation really does seem to say that proportions should be okay. I've checked and my vectors of wins and games really seem to be fine:

wins = 16  8 10  7  7  6  5  2  1  1  1  1  0 11 11  5  5  4  3  3  2  1  0  9  6  4  4  3  2  1  0  0
games = 24 16 15 14 12 11  9  6  5  5  5  5  4 19 17 11 10 10  7  7  6  5  4 18 11 11 10  7  6  5  4  4

I haven't found anything online that's particularly helpful. I've found sources (like the documentation) that say that proportions should be possible, but no examples actually doing it. I've also found examples where someone fits data that is wildly non-binary (and not even a proportion), thereby resulting in this error message.

Any help or insight into what is going wrong, or even a minimal working example (I don't include mat because I'm using a ton of predictors), would be so appreciated!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source