2

I want to run a logistic regression:

lrm(formula = dat$law ~ dat$argor + dat$trust.cen + dat$argor*dat$trust.cen + 
  dat$trust.abs + dat$argor*dat$trust.abs)

but I get this error:

Error in if (!length(fname) || !any(fname == zname)) { :
missing value where TRUE/FALSE needed

Other posts have this error, but I cannot solve the problem with any of those solutions. Any help?

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 4
    Welcome to SO! Please read this and edit your question afterwards: https://stackoverflow.com/a/5963610/4132844 – scoa May 28 '17 at 10:02
  • 1
    For starters, you could specify the formula correctly. Try `y ~ x + y + z, data = xy)`. Notice I don't use `$`. – Roman Luštrik May 28 '17 at 10:07
  • 1
    @RomanLuštrik Its perfectly correct to specify vectors in a formula, without a `data` argument, as the question does. At least, that's true for `lm` - I don't know about this `lrm` function mentioned in the question... – Spacedman May 28 '17 at 10:14
  • 1
    Where does the `lrm` function come from? – Spacedman May 28 '17 at 10:14
  • @Spacedman It's from the `rms` package, I assume: http://finzi.psych.upenn.edu/R/library/rms/html/lrm.html – RHertel May 28 '17 at 11:50

1 Answers1

1

The error happens when you use $ in the formula. Strangely it's an issue that affects lrm but not lm. The solution is to not use $ as per Roman in the comments. Fortunately you can work around this by referring the dataset law in the data term:

lrm(formula = law ~ argor + trust.cen + argor*trust.cen + trust.abs + argor*trust.abs, data = law)
MBorg
  • 1,345
  • 2
  • 19
  • 38