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

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 ...)

Related

BiodiversityR::accumcomp.long function not found

I am trying to use the function accumcomp.long in the Biodiversity.R package in order to adjust my species accumulation curves in ggplot.
However, calling the function accumcomp.long gives me an error, suggesting that this function perhaps does no longer exists.
accum.long1 <- accumcomp.long(Accum.1, ci=NA, label.freq=5)
Error in accumcomp.long(Accum.1, ci = NA, label.freq = 5) :
could not find function "accumcomp.long"
The function BiodiversityR::accumcomp.long
returns
Error: 'accumcomp.long' is not an exported object from 'namespace:BiodiversityR'
I am not certain whether this is an issue with the package, the way the package is loaded into my R space, or perhaps unrelated to the package simply the format of my data.
My community and environment files are of dataframe class. I have tried loading them as .csv files as well as .rda files, but the error remains.
??accumcomp.long
renders "No results found".
I am using R version 3.5.3 (2019-03-11)
Any suggestions as to what else I could try?
Thanks in advance!
I re-installed the package BiodiversityR and included force = T (as per this thread https://community.rstudio.com/t/could-not-find-function-error-even-though-fun-is-in-namespace-and-has-an-rd-file/91243). I then reloaded the package. I am not sure what force = T does, but the accumcomp.long function now works.

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.

Where did the forecast.Holtwinters go in R 3.4.3?

I'm using R Studio based on R 3.4.3. However, when I tried to call the forecast.HoltWinters function, R told me that "could not find function "forecast.HoltWinters"". Inspect the installed package (v8.2) told me that it's true, there is no forecast.HoltWinters. But the manual in https://cran.r-project.org/web/packages/forecast/ clearly stated that forecast.HoltWinters is still available.
I have also tried stats::HoldWinters, but it's working wrong. The code run fine on another computer, but it couldn't run at all on mine. Is there any solution?
Here is the code. Book2.csv has enough data to last more than 3 periods.
dltt <- read.csv("book2.csv", header = TRUE)
dltt.ts <- ts(dltt$Total, frequency=12, start=c(2014,4))
dltt.ts.hw <- HoltWinters(dltt.ts)
library(forecast)
dltt.ts.hw.fc <- forecast.HoltWinters(dltt.ts.hw) //Error as soon as I run this line
Fit a HoltWinters model using the HoltWinters function and then use forecast. Its all in the help for HoltWinters and forecast, namely "The function invokes particular _methods_ which depend on the class of the first argument". I'll copy the guts of it here:
m <- HoltWinters(co2)
forecast(m)
Note this will call the non-exported forecast.HoltWinters function, which you should never call directly using triple-colon notation as some may suggest.

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.)

Are there known compatibility issues with R package mgcv? Are there general rules for compatibility?

I use R version 2.15.1 (2012-06-22) and mgcv version 1.7-22
I load the following set of packages in R:
library(sqldf)
library(timeDate)
library(forecast)
library(xts)
library(tseries)
library(MASS)
library(mgcv)
It happens that I can not run a simple model (I omit the code). Even the sample code taken from the help pages:
dat = gamSim(1,n=400,dist="normal",scale=2)
b = gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
gives an error:
Error in qr.qty(qrc, sm$S[[l]]) :
NA/NaN/Inf in foreign function call (arg 5)
In addition: Warning message:
In smoothCon(split$smooth.spec[[i]], data, knots, absorb.cons, scale.penalty = scale.penalty, :
number of items to replace is not a multiple of replacement length
Note that everything works fine, if I just load the package mgcv and then use the sample code right away. It also works if I just load all the packages and run the sample code. It just does not work if I
load all packages
do some file reading, sqldf statements, ts operations and some models from package forecast.
if I then apply GAM, it does not work anymore.
Apparently the variable definitions in the general environment mess up the functioning of the package.
Are there any known issues? Are there general rules that I have to obey if I load various packages? Can I write code that "disturbed" the package mgcv?
# Richard there are 2 GAM related packages: gam and mgcv. Loading both libraries at the same time usually causes a conflict.
Loading mgcv as the first package solved my problem ... strange but true.

Resources