0
$\begingroup$

first of all, I am super happy that I found this great community. I am currently having trouble in my logistic regression analysis in that I get the error message display

Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred

I read a lot about the issues of perfect separation in this forum. A colleague told me that he is always using the log transformation of his data for his analysis (not logistic regression) and I noticed, that once I transformed the data, I won't get the error message anymore. Could this be a solution as well?

For background information, this is my data structure:

model <- glm(formula = Customer.group ~ Price.Index , family = binomial())

With Customer.group being yes (1) or no (0) and Where Price.Index is a calculated measure for each customer consisting of the weighted sum of a price paid for a product in a category divided by the average price in this category. So it is not actual observed data, but a calculated measure.

$\endgroup$
  • 1
    $\begingroup$ I'm a bit puzzled by your dependent variables, if it is a sum of prices divided by an average price, is that not some continuous numerical response rather than a yes/no (or some integer out of a larger integer total)? So why use logistic regression? $\endgroup$ – Björn Jan 23 '17 at 13:22
  • 1
    $\begingroup$ I am rather surprised that your colleague thinks log transforming makes separation go away. Can you show us the result of your models with and without log transforming PriceIndex so we can see the difference? $\endgroup$ – mdewey Jan 23 '17 at 13:28
  • 1
    $\begingroup$ Hi Björn, my dependent variable is "Customer.Group" being binary as yes/no for indicating whether the customer is part of the group. My independent variable is the continuous price index which varies between ~0.1 and ~10 $\endgroup$ – Gabi Schneider Jan 23 '17 at 13:53
0
$\begingroup$

Without seeing your data, it is difficult to diagnose why you would be receiving such an error.

That said, one error you have made is including both the glm and lm functions together. This is incorrect. Instead, your formula should be of the format:

model <- glm(Customer.Group ~ Price.Index, data=yourdata, family="binomial") summary(model)

Before you attempt to use a log transformation, ensure that your glm formula is inputted correctly as above, and then report back your findings.

$\endgroup$
  • $\begingroup$ Hi Michael! Thanks so much! I tried this formula and I still get the error message with the non-transformed data. I also used the safeBinaryRegression package to assess if there is a perfect separation which was found in my data. Therefore, I used the brglm package to run a Firth regression (which was successul). But because I wasn't sure what diagnostic statistics and model fit estimates to use for Firth regression, I tried to run the glm model again this time with the log-transformed data. I am just wondering, if this procedure would be statistically correct or if it wouldn't make sense. $\endgroup$ – Gabi Schneider Jan 23 '17 at 13:46
  • $\begingroup$ Log transformations are typically used for wide distributions, so whether it would make sense or not depends on whether your data fits this criteria. I would not be able to diagnose more accurately without seeing your data up front. $\endgroup$ – Michael Grogan Jan 23 '17 at 14:04
  • $\begingroup$ Ok, I understand. What information about the data do you need? I have a large sample of 100,000 observations. These are the summary statistics for the independent variable price index: Min: 2.10 - 1st Qu: 2.31 - Median: 2.60 - Mean: 2.89 - 3rd Qu.: 3.17 - Max. 12.7 - When I look at the graph, the distribution does not seem to be wide at all $\endgroup$ – Gabi Schneider Jan 23 '17 at 15:58
  • $\begingroup$ If this is the case, then I do not see the rationale for a log transformation. You should not be receiving an error for glm if you are running it correctly. $\endgroup$ – Michael Grogan Jan 23 '17 at 15:59

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.