Hello community i have the following error:
Error in X - Q$Mu : argument non numérique pour un opérateur binaire
Called from: transpose(X - Q$Mu)
Here is my code(r language), i hope it will be helpful i want to simulate a dataset and applying the gaussian distribution , but it gives me the error above
library(MixSim)
library(rlist)
Q <- MixSim(MaxOmega = 0.0, K = 2, p = 2)
A <- simdataset(n = 500, Pi = Q$Pi, Mu = Q$Mu, S = Q$S)
A
vk=data.frame(A$id)
v=count(vk,1)
v ########### count the elements of eah class (this exemple has 5 classes)
v[1,2]###### elements for class 1
v[2,2]######## elements for class 2
g <- function(X,sigma,i) {
return((1/2)*transpose(X-Q$Mu)*solve(Q$S[,,i])*(X-Q$Mu))-(1/2)*ln(sigma)+ln(v[i,2]/500)
}
g(A,sigma,1)
sigma=Q$Mu
mahalanobis(A, sigma, Q$S)
Q$Mu
ln(sigma)
Q$Mu
I want it to calculate this function Discriminant Gaussian distribution
P is the probability , Q$Mu is the mean Q$S[,,i] is the covariance matrix for class i
return()statement - Vasily A