user2762495
user2762495

Reputation: 1423

Error with R lfe package felm call: rank problems, chol() problems

I am using R to compute an instrumental variable regression. Specifically, I am calling felm from package lfe. The response variable is cost, and id and dates are factors that will be used for fixed effects. I am almost sure that my data is not rank deficient in any way, but no matter how I slice it, I keep getting this error:

Error in if (rank == N) return(chol(mat)) : argument is of length zero

When I tried debugging line by line, I was stepping deeper and deeper into various package function calls, and I couldn't make sense of it. Here's summary information about the data frame, limited to just the rows I'm feeding into the call. You can see that the only NA's are in the "cost" field.

data frame summary

Here is the call that generates the "argument of length zero" error.

trial_model = felm(formula = cost ~ covariate.P_t | id + dates | (covariate.TiPt ~ covariate.AiPt) | id,data=rawDataSimple,subset=rows_to_use)

I get the same error when I include this argument:

na.action=na.omit

I get the same error when I also include this argument:

exactDOF="rM"

So I'm stuck. Any thoughts on how to diagnose this problem, either in the felm call or in my data frame?

Upvotes: 1

Views: 2814

Answers (2)

pbaylis
pbaylis

Reputation: 1624

I've gotten a similar error with felm calls in the past at various times for different reasons. For posterity, here is my list of solutions that worked at some point, in increasing order of effort required:

  • Restarting R/RStudio/Computer
  • Updating installed packages
  • Updating RStudio
  • Updating R
  • Removing a bad RAM module

[I updated my answer because I ran into this again.]

Upvotes: 0

user2762495
user2762495

Reputation: 1423

It turned out to be an issue with the specific versions of R and R-Studio that I had installed. We upgraded to the latest R and R-Studio, and felm worked just fine after that.

Upvotes: 0

Related Questions