0
$\begingroup$

I am trying to perform a logistic regression with the lm() function in R. My model is:

lm(xrd ~ VariableA*Post, data = DatasetXRD)

this is a difference-in-differences model, the R code is based on Oscar Torres-Reyna's Differences-in-Differences (using R).

Some general info regarding my data:

I have applied pseudo adoption in my model (in the Post variable). So I state that some companies will apply a certain rule after a year even though they do not apply it. However VariableA will remain 0 (no application of the rule) for these companies. This will result into a value of 1 for companies that do apply it, and a value of 0 for companies that do not apply it (in that specific year, it could be that they will apply it in a later year).

VariableA and Post are both dummy variables (value= 0 or 1).

The third row of text in my lm table is showing NAs.

Coefficients: (1 not defined because of singularities)
                       Estimate Std. Error t value Pr(>|t|)    
(Intercept)              43286       4865   8.897   <2e-16 ***
VariableA                4900       6362   0.770    0.441    
Post                    -4904       6849  -0.716    0.474    
VariableA:Post            NA         NA      NA       NA  

As shown in the table, this is because of singularities. After a google search I have found that this is because of collinearity.

I have run the cor() function trying to see if this would lead to a perfect correlation, since that would prove that I have collinearity issues, but I don't find the results convincing.

cor(Dataset$VariableA, Dataset$Post)

This leads to the following output: 0.5890362. Correlation is not 1, so that does not mean that my independent variables are not perfectly collinear (in my own words: they do not perfectly explain each other?)

I have also ran:

alias(didreg, complete = TRUE, partial = FALSE,
      partial.pattern = FALSE)

I have read in a previous question that was similar that this will show collinearity, however I will admit that I do not fully understand how to interpret the output of the table below.

Model :
xrd ~ VariableA * Post

Complete :
                   (Intercept) VariableA Post
VariableA:Post        0           1        0   

Why I am having collinearity problems?

$\endgroup$
1
  • 2
    $\begingroup$ This is more of a stats question than a programming question. But for the programming part, you should be using glm() rather than lm() if you really want logistic regression. For the stats part, collinearity just means that one variable can be written as a linear combination of others: z might not be perfectly correlated with x or y, but you have collinearity if you can find a and b so that z is perfectly correlated with ax + by (or similarly with more than 2 in the linear combination). $\endgroup$ Commented Jul 4, 2021 at 12:59

1 Answer 1

1
$\begingroup$

The collinearity is not between those two variables. They both have coefficients. Rather it is a joint collinearity between the two variables and the interaction variable. The interaction variable is the one that has the NA coefficient.

Collinearity does not need to be between only two variable but can exist between three or more variables. If any number of variables can exactly predict another variable in the model, then multi-collinearity exists and the predicted variable is given an NA by the regression function. The process of dropping coefficients from consideration is called “aliasing” by the R authors. Changing to logistic regression will not solve this problem.

$\endgroup$
1
  • $\begingroup$ Hi DWin, Thanks for your reply. It indeed is a case of multicollinearity. I computed post based on variableA. I thought I had eliminated the collinearity issue by applying a trick with a random nummer generator. I now see wij it does not worm and I have found a fix! Thank you so much for your reply :) $\endgroup$ Commented Jul 4, 2021 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.