Error using the clusGap function in R - r

I want to determine the optimal number of clusters with R using the gap statistics in the following way
library(cluster)
clusGap(datamatrix, FUN=kmeans, K.max=10, B=10)
However I get the error
Error: could not find function "clusGap"
What does this mean? I have the cluster package because I can use the other functions. Was this function removed or do I do something wrong?

I had an old version of the cluster package.

Related

R simulation periodic ARMA(1,1)

I'd like to simulate a\ periodic ARMA(1,1) using R. I found the R package perARMA but I don't understand how to use it.
There is the function makeparma that permit to simulated the parma(1,1). But I don't understand the input parameters and the model used to simulate the periodic stuff.
This is the source code provided by the package trying to simulate a parma(2,1):
T=12
nlen=480
p=1
a=matrix(0,T,p)
q=1
b=matrix(0,T,q)
a[1,1]=.8
a[2,1]=.3
phia<-ab2phth(a)
phi0=phia$phi
phi0=as.matrix(phi0)
b[1,1]=-.7
b[2,1]=-.6
thetab<-ab2phth(b)
theta0=thetab$phi
theta0=as.matrix(theta0)
del0=matrix(1,T,1)
PARMA21<-makeparma(nlen,phi0,theta0,del0)
parma<-PARMA21$y
I don't understand why we should specify two beta value. And why del0 is a matrix.
I solved using the R package sarima and for the simulation I used the function prepareSimSarima

Problems fitting arbitray distributions using the fitdistplus package

I am trying to fit my data using the fitdist() function from the fitdistrplus package in R. I succeeded using a normal and a lognormal distribution via key words 'norm' and 'lnorm' which I found via searching online.
I was not able to get other distributions working; the help of fitdist() says:
distr: A character string "name" naming a distribution for which the corresponding density function dname, the corresponding distribution function pname and the corresponding quantile function qname must be defined, or directly the density function.
I checked and when entering ?norm or ?norm into the R command line, neither function norm() nor lnorm() is found. This confuses me totally.
When I try for example fitdist(data, 'poisson'), I get the following error message:
Error in fitdist(data$time, "poisson") :
The dpoisson function must be defined
I am somewhat a noob in R, can anybody give a hint?
norm() in R is a different function to compute norms of a matrix, so not directly related to the normal distribution.
?Normal brings up the documentation related to the normal distribution, and you'll see the 4 functions dnorm, pnorm, qnorm and rnorm belonging to this family.
If you look at ?Lognormal you'll see the same convention with the typical 4 functions.
More generally, you can look-up ?Distributions, which links all of them. There you can see that the keyword for the poisson distribution should actually be pois.

package required for "mmetric" function in R

I'm trying out Naive Bayes classification using stock dataset in R. Now for displaying the final results I've seen a function mmetric taking testing data and prediction model as arguments. But while I'm trying the same I'm facing the error could not find function "mmetric". I have installed the rminer and list packages which are quotes as reference packages for these. But still I could not resolve it.
Any Suggestions to resolve the error?
I got same error but i updated my Rcpp package that will be needed by rminer to load on the system, hope this helps.

Deming Regression MCR package

I am using the "mcr" package for deming regression. When i try to use the functions
mc.analytical.ci()
mc.bootstrap()
i get an errer saying "could not find function "(one of the two functions above)" "
But I don't have any trouble using other functions, like
plotDifference()
Stangely they are not available, but the manual don't tell anything about not using them.
Anyway you can use them as:
mcr:::mc.analytical.ci()

R cannot find specific function in a package

I'm using the randomForest package (v 4.6-7) in R (v 2.15.3) and can easily use the function randomForest to create a model. However, when I try to predict on my test set, the predict.randomForest function cannot be found. I've also tried plotting with plot.randomForest only to get the same error, "could not find function."
I've already tried reinstalling the package (figuring maybe it was out of date) and made sure the spelling is absolutely correct. I cannot figure out what's causing this error, any ideas?
It appears that the functions of interest are not exported from the package.
If you use ls(package:randomForest) you'll get a list of the exported functions.
If you want to see all the functions available the use: ls(getNamespace("randomForest"), all.names=TRUE). Thanks #Joshua.
You'll see the functions you want there.
In order to refer to one of them explicitly, use: randomForest:::predict.randomForest()
or just make a object which inherits the class 'randomForest' and call predict() on it directly.

Resources