Luiz Alberto Lima
2015-Sep-27 05:54 UTC
[R] Error finding clusters for new data with FlexMix
Hello, I am trying to find the clusters for new data using FlexMix. I have the following code: library(flexmix) x <- c(0.605, 0.523, 0.677, 0.101, 0.687, 0.586, 0.517, 0.592, 0.653, 0.617) y <- c(0.222, 0.741, 0.182, 0.162, 0.192, 0.254, 0.745, 0.669, 0.198, 0.214) test <- c(0.720, 0.168, 0.520, 0.134, 0.558) model <- flexmix(y ~ x, data = data.frame(x = x, y = y), k=2) pred <- predict(model, newdata=data.frame(x = test)) clusters_train <- clusters(model) clusters_test <- clusters(model, newdata=data.frame(x = test)) When I execute the last line of the code, I receive the following error message:> clusters_test <- clusters(model, newdata=data.frame(x = test))Error in model.frame.default(model at terms, data = data, na.action = NULL, : variable lengths differ (found for 'x') What am I doing wrong? Thanks! [[alternative HTML version deleted]]