# How does one deal with lots of 1's when applying the logit function?

I have a dataframe containing many feature columns, one of them being Score, with values between 0 and 1 (if it helps: it represents the difficulty of a test. The closer to 1, the easier the test). I created an extra column that applies the logit function to each of these values.

The reason why I did this transformation is to do a logistic regression to predict the difficulty. However, many values will be inf because in the input there are values such as 0 and 1 (most of them are 1). What do I do with them? Should I apply the logistic function (inverse of logit) to 0 and 1's? Should I just eliminate them?

• You're predicting difficulty, based on difficulty? This is confusing.
– Gijs
Jul 12, 2021 at 8:56
• Logit or logistic regression is in my experience always implemented by a dedicated routine or through some more general routine such as code for generalized linear models. It is not equivalent to regression following a logit transform: in fact for the classic case with a binary outcome with values 0 and 1 logit doesn't yield any finite values at all. For your case with a more nearly continuous proportion as outcome you should not drop any values, but just use an appropriate routine in your unnamed software environment. Jul 12, 2021 at 9:34
• Indeed; your response or outcome is bounded and much of the point of logit regression is to respect that and also that it has a particular variance structure, so that for example as the mean approaches 0 or 1 so also the variance approaches zero. But as said logit regression is not regression on a logit-transfomed outcome. Some people would be happy in practice with a linear model fit to the untransformed data. Otherwise interest in applying a logit model to a continuous proportion is common in practice, but often only discussed in the context of generalized linear models. Jul 12, 2021 at 10:03
• Otherwise put, linear regression on the original data might work not too badly, although the ideal conditions for such a regression are unlikely to be met closely; logit regression using a generalized linear model routine is the alternative. Logit transformation of a continuous proportion is problematic because zeros and ones don't fit that recipe. Jul 12, 2021 at 10:06
• I would start with the book by Dobson and Barnett. I can't recall if they cover your application. Jul 12, 2021 at 10:39

What you seems to want is sometimes called fractional logistic regression, there are many Questions on this site, start with What is the difference between logistic regression and Fractional response regression? and search this site.

But very short:

• You should NOT transform the scores, use them directly as the outcome variable. Logistic regression will transform implicitly their expectation, not the scores themselves.

• Since your data is not really binomial, the likelihood function is not strictly correct, so use

• With R you would use something like

mod0 <- glm(score ~  ., family=quasibinomial, data=your_df)

• Thank you! I'm working in Python and I found and used this reference: statcompute.wordpress.com/2012/12/16/…. But I am getting a negative pseudo R^2, Log-Likelihood, LL-Null and LLR p-value. Is this something to worry about? Jul 13, 2021 at 6:50
• I have no experience with pseudo-R2. Negative loglik is as expected, but a negative p-value is impossible! Better for you to include the results (with some plots) in an edit to the Q Jul 13, 2021 at 15:18