-2

I'm new using R and my doubt is really basic. I have several dependent variables (x) and one independent variable (y), and I'd like to generate different regression models with 10-folds-cross-validation in order to select the better one. All my values are numerical.

They recommended me to use Caret package and I made some tests. I had no troubles using linear regressions (lm or glm) but when I use other regressions like logreg I have an error.

What I introduce is:

 Datos_AGB <- read.table("plotstatistics.txt",header=TRUE) 
 ctrl <- trainControl(method = "repeatedcv", number = 10, repeats = 10)
 modelFit <- train(AGB~HOMEmean+WDmean, data=Datos_AGB, method = 'logreg', trControl=ctrl)

And I receive this error:

Something is wrong; all the RMSE metric values are missing:
>       RMSE        Rsquared    Min.   : NA   Min.   : NA    1st Qu.: NA   1st Qu.: NA    Median : NA   Median : NA    Mean   :NaN   Mean   :NaN 
> 3rd Qu.: NA   3rd Qu.: NA    Max.   : NA   Max.   : NA    NA's   :9   
> NA's   :9     Error in train.default(x, y, weights = w, ...) :
> Stopping 50: In eval(expr, envir, enclos) :   model fit failed for
> Fold06.Rep01: ntrees=3, treesize= 8 Error in logreg(resp = y, bin = x,
> ntrees = param$ntrees, tree.control = logreg.tree.control(treesize =
> param$treesize),  :    some non binary data among binary predictors

I don't know if I have to introduce other parameters or to do some steps before.

I'd like that someone explained me how to solve this and how to get non-linear regressions.

milos.ai
  • 3,882
  • 7
  • 31
  • 33
Pablo
  • 463
  • 1
  • 5
  • 12

1 Answers1

0

All my values are numerical

That's the issue. Note the error message

some non binary data among binary predictors

logreg requires binary predictors.

Max

topepo
  • 13,534
  • 3
  • 39
  • 52