I am new to gaussian mixture models and I am trying to learn how to use normalmixEM in R. I have read the documentation and in order to learn more about how it works I am trying to fit a mixture model to a fake data set that I created, however I get the following error and I am not sure why:
"Error: NA/NaN/Inf in foreign function call (arg 5)"
Code:
S=(t(t(runif(5,0,1))))
Initialprops=S/sum(S)
values=matrix(0L, nrow = 10000, ncol =1)
means=matrix(0L, nrow = 10000, ncol =1)
sigma=matrix(0L, nrow = 10000, ncol =1)
for (i in (1:10000))
{values[i,1]=runif(1,0,1)
means [i,1]=i
sigma[i,1]=(2^(i-1))
}
normalmixEM(values,Initialprops,means,sigma,5)
For the fake data set I just used a set of 10000 random numbers from a (0,1) uniform distribution. I used a set of 5 normalized random numbers for the initial mixing proportions. For the means I used the sequence 1, 2, 3, ... and for the sigma I used the sequence 1, 2, 4, 8 ...
Thank you!