I have a data set which has 10 columns of binary data (n = 300) and I'm trying to use flexmix in R in order to explore the data by fitting a series of latent class models to it. The problem I have is that I can't cluster on 3 or more of the variables. Yet, Latent Gold, a nonfree piece of software which can be used for clustering has no problem fitting models when using all 10 columns so I cant but help think that there must be something I am doing wrong.
To give you an idea for the data, if I tabulate it for just 3 of the columns it looks like this:
as.data.frame(table(dat))
var1 var2 var3 Freq
1 0 0 0 152
2 1 0 0 65
3 0 1 0 10
4 1 1 0 45
5 0 0 1 33
6 1 0 1 8
7 0 1 1 0
8 1 1 1 10
My code when using stepFlexmix looks like this:
sFM <- stepFlexmix(~1, data = dat, k = 1:5, nrep = 5,
model = list(FLXMRglm(var1 ~ ., family = "binomial"),
FLXMRglm(var2 ~ ., family = "binomial"),
FLXMRglm(var3 ~ ., family = "binomial"))
)
which looks pretty similar to what is suggested in the flexmix intro on page 9 here (PDF warning).
The error it then kicks back is this:
*Error in model@preproc.y(model@y) :
for the binomial family, y must be a 2 column matrix
where col 1 is no. successes and col 2 is no. failures
Error in stepFlexmix(~1, data = dat, k = 1:2, nrep = 5,
no convergence to a suitable mixture
Any suggestions or ideas as to how to get this working would be greatly appreciated.