Caret Error for TrainControl, method="repeatedCV" - r

Using the following code
trnCtrl=trainControl(method='repeatedCV', number=10, repeats=5)
I get the error
Warning message: repeats has no meaning for this resampling method.
Even stranger, it worked fine until I did a reinstall of Caret. Note that I have already removed R, and reinstalled all packages 2x...

I appreciate that this is an old question but after looking through the Caret source code all I can deduce is that the problem is occurring when declaring the sampling method.
The following snippet has been pulled directly from the Caret repo:
if(!is.na(repeats) & !(method %in% c("repeatedcv", "adaptive_cv")))
warning("`repeats` has no meaning for this resampling method.", call. = FALSE)
My guess is the condition is failing when evaluating the method. You've specified the method as repeatedCV whereas it's actually named repeatedcv.
Again I appreciate that this question is old and it could well be the name has changed since 2013. In which case, ignore this answer.

I also got the same error and the reason was I typed "repeatecv", wrong method.
When I changed to right name, "repeatedcv" it worked.
Try,
trnCtrl=trainControl(method='repeatedcv', number=10, repeats=5)

Related

How to fix the error "argument "modelName" is missing, with no default" when using MVN package

I am using the MVN package, in R, to find whether each class of the dataset iris is multivariate normal or not.
I used the below code earlier in the day and generated results from it. However, I went to revisit it and now keep getting the following error message:
Error in mvn(data = iris[Species == m[1], 1:4], mvnTest = c("mardia")) :
argument "modelName" is missing, with no default
Can not figure out what this means and how to fix it !
Code:
#Mardia's Test
SM<-mvn(data=iris,subset="Species", mvnTest="mardia")
SM$multivariateNormality
SetosaPlot<-mvn(data=iris, subset="Species", multivariatePlot="qq")
You loaded the mclust package. When you did so you should have seen a warning
The following object is masked from ‘package:MVN’: mvn
So now mvn() is calling mclust::mvn() (i.e. the mvn function in the mclust package) rather than MVN::mvn().
In general you can make sure you get the version from the MVN package by using
MVN::mvn(data=iris, subset="Species", multivariatePlot="qq")
If you want to know where R is finding mvn, try find("mvn")
In general, to resolve these kinds of problems you should start a clean R session, so that you know you're starting with no packages loaded.
(By the way, no real data set is ever truly multivariate normal; you're not testing "whether it is MVN or not", but rather whether it is close enough to MVN that you can't reject the null hypothesis of multivariate normality ...)

How to fix lmer error: "Error in as(value, fieldClass, strict=FALSE) :"?

I'm getting a strange error when I run an lmer function in r.
I've tried changing the variable types (all of them are numeric or factor) and removing the NA before analysis, but nothing seems to work.
model_1 <- lmer(Q14 ~ gender * time + (1|OMID), data=data)
summary(model_1)
Specifically, my error message reads:
Error in as(value, fieldClass, strict = FALSE) :
internal problem in as(): “labelled” is(object, "numeric") is TRUE, but the metadata asserts that the 'is' relation is FALSE
Not sure why this is happening, but I can't seem to find any answers for it. Any help would be appreciated.
Thanks!
I think lmer has a problem with 'labelled' data. If you un-label the predictors it should work fine.
I had the same error: the code for the lme-formula worked perfectly fine and one day I encountered that error. The solution in my case was simply to restart the R session, reload the data - in my case from SPSS via library("haven")::read.sps and after that load library("lme4") and execute the lme-formula.
So, if the formula worked before without any error, maybe just clean the project environment and re-run the most crucial code without any additional packages loaded. Maybe it's just some "cross-contamination" between packages or an unwanted effect of any package on the dataframe.

r msm BLAS/LAPACK routine 'DGEBAL' gave error code -3

I'm trying to make a basic markov model using the package msm and things were working fine until I've suddenly started receiving the following error code. I don't know why it's suddenly started throwing this as it was working fine earlier, and I don't think I've changed anything. The error code seems to be pointing to the linear algebra library but I don't know what to do with it exactly ...
Error in balance(baP$z, "S") :
BLAS/LAPACK routine 'DGEBAL' gave error code -3
The code is as follows:
statesDistMatrix2 <- matrix(c(.1,0,0,.1), nrow = 2, ncol = 2)
msm1 <- msm(error ~ stop_datetime, subject = TRIP_ID, data = train_245_mk,
qmatrix = statesDistMatrix2, control=list(fnscale=5000,maxit=500))
From this document http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.230.5929&rep=rep1&type=pdf about LAPACK
It seems that (section Error Indicators and Warnings)
"Errors or warnings detected by the routine: INFO < 0
If INFO = -i, the ith parameter had an illegal value."
Still from this document, the third parameter which seems to be the problem in your case has to be real. Chances are that some complex value appears at some point in the process. Make sure that this parameter only has real values. Sometimes, some operations can lead to results such as 1 + 0.000000001j and this is problematic, try to call the function by taking only the real part of the argument you pass in.
Hope this helps.

Error: could not find function "makeLearner" using h2o package

I'm using h2o package and trying to create a learner using the below given code
install.packages("h2o")
library("h2o")
h2o.learner <- makeLearner("regr.h2o.deeplearning",predict.type = "response")
But I'm getting this error
> h2o.learner <- makeLearner("regr.h2o.deeplearning",predict.type = "response")
Error: could not find function "makeLearner"
Note: Few months back I used this code without any problem.
Any idea what could be possible thing for this error?
The correct code for this is simply
library(mlr)
h2o.learner = makeLearner("regr.h2o.deeplearning")
The makeLearner() is not part of H2O. It appears to be part of the mlr package. It also seems that mlr does have h2o support, so it might be as simple as adding a library(mlr) to the top of your script? (Making sure that the mlr package has been installed, already, of course.)

R caret: rfe nnet "undefined columns selected"

I am running into problems when applying recursive feature selection to nnet models with caret::rfe; I get the following error message:
Error in { : task 1 failed - "undefined columns selected"
The actual task is more complex than the following example, but I am confident that this is a similar problem:
library(caret)
rfe(x = iris[,1:3],
y = iris[,4]/max(iris[,4]),
sizes = c(2),
method="nnet",
rfeControl = rfeControl(functions = caretFuncs)
)
I know this error can occur when trying to select more features than there are available in x (e.g. see https://stats.stackexchange.com/questions/18362/odd-error-with-caret-function-rfe), but this does not seem to be the problem here. I also ran very similar calls in earlier versions of caret, without this problem occurring.
I use R 3.3.1 and caret 6.0.71.
Thank you very much for your help.
EDIT: I went through the archived versions of caret and found that the example code is working in caret versions <= 6.0.62.
I went through the archived versions of caret and found that the example code is working in caret versions <= 6.0.62. This also solves the problems my original code had. I reported this issue on the caret github.
EDIT: The problem is now fixed : https://github.com/topepo/caret/issues/485

Resources