0

I'm having a bit of trouble specifying a formula in the optimal.cutpoints() function of the OptimalCutpoints package in R.

The information about the function states that X is:

either a character string with the name of the diagnostic test variable (then method 'optimal.cutpoints.default' is called), or a formula (then method 'optimal.cutpoints.formula' is called). When 'X' is a formula, it must be an object of class "formula".

I can't figure out how I apply this in in the function as I keep getting errors. I have tried a number of different variations

X = variable1 + variable2 + variable3
X = ("variable1", "variable2", "variable3")
X = ("variable1" + "variable2" + "variables3")

None of this seems to work. Is anyone familiar with how to code this into that function?

user3585829
  • 945
  • 11
  • 24
  • 1
    This sounds more like an R syntax issue than one with optimalcutpoints. Can you show the code you've got so far, ideally with a reproducible example (see http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Calimo May 13 '17 at 07:15
  • From the help of `optimal.cutpoints`: `X = y ~ x` Right side of ~ must contain the name of the variable that distinguishes healthy from diseased individuals (y), and left side of ~ must contain the name of the diagnostic test variable (x). – Marco Sandri May 13 '17 at 12:14
  • Thanks, but with multiple x variables this doesn't seem to work. This is what I've now tried and I get and error that this is an invalid formula: cutpointA <- optimal.cutpoints(X = y ~ x1 + x2 + x3 + x4 + x5, status = "y",tag.healthy = 0, methods = "Youden", data = data, categorical.cov = NULL, pop.prev = NULL, ci.fit = TRUE) – user3585829 May 13 '17 at 12:59

0 Answers0