'How come I only get NA when running the felm (fixed effects linear model) code in R?

dput(TandC[1:5, ])

Hi guys! I want to run this fixed effects linear model in R, but I get this strange error when I run the code, followed by an output full of "NA". This is the error I get:

Warning in chol.default(mat, pivot = TRUE, tol = tol) : the matrix is either rank-deficient or indefinite

And this is my model:

m6a <- felm(ihs(RD_expenses) ~ merger_it_post1 + merger_it_post2 + merger_it_post3 + age + ihs(rd_expenses_pre1) + ihs(employees_pre1) + ihs(profit_pre1) + factor(year)
       | company | 0 | company,
       data = TandC,
       na.action,
       subset = RD_expenses > pcts[1] & RD_expenses < pcts[2])

summary(m6a)

The merger_it variables are dummies and the rest are covariates. I do have some NAs in the profit_pre1 for example, but this is because those variables are formed based on tje period variable.

I have no idea what I am doing wrong, as the model without the covariates (so only the merger dummies and fixed effects) is working perfectly fine.

Can anyone help me out? Much appreciated!!



Solution 1:[1]

Last time I encountered this error, it was because my dataframe has NAs that made it impossible to compute the model. I see that you wrote na.action - maybe you wanted to specify to ignore all NAs? Like this

    m6a <- felm(ihs(RD_expenses) ~ merger_it_post1 + merger_it_post2 + merger_it_post3 + age + ihs(rd_expenses_pre1) + ihs(employees_pre1) + ihs(profit_pre1) + factor(year)
           | company | 0 | company,
           data = TandC,
           na.omit,
           subset = RD_expenses > pcts[1] & RD_expenses < pcts[2])

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Stefano Barbi