Re: [R] Warning when using 'prelim.mix' from the package 'mix'

From: Ted Harding <Ted.Harding_at_nessie.mcc.ac.uk>
Date: Sun 21 Aug 2005 - 20:18:42 EST


On 21-Aug-05 Laurent Valdes wrote:
> 'sodexquan' is an data frame of numeric variables with some missing
> values.
> I would like to approximate these missing values using some algorithm.
> I thereby chose the mix package.
> But when trying to run the 'prelim.mix' function (aka the function that
> will prepare the data for further calculations), R says:
>
> prelim.mix(truc,0)
> Error in as.integer.default(list(c(32, 52, 32, 27, 34, 35, 35, 28, 42,

>: 

> the object (list) can't be converted in 'integer'
>
> I roughly translated the word in english, because it was localized in
> french.
>
> I would like to correct this.
>
> Laurent

Read the documentation for 'mix' carefully: The data supplied MUST be a MATRIX (as well as satisfying other conditions on the structure such as having the "categorical" variables leftmost in the columns with levels coded as successive integers from "1" upwards).

While it is not clear from your description what you precisely did (where does that thing called "truc" -- perhaps best translated into English as "thingummy" -- come from, and what sort of thingummy is it supposed to be?), the result of your attempt suggests that you may have passed a dataframe to 'prelim.mix', and this will not work.

You must first convert it to a matrix.

You may, however, have violated some other requirement, such as the requirement that the columns for categorical variables may contain only integers.

Another thing to note is that in the call

  prelim.mix(some.matrix,p)

the integer "p" is the number of categorical variables (corresponding to the first p columns of "some.matrix", and it is a fact about the 'mix' package that p must be at least 1: it will not work if p = 0.

Apart from the requirement that p >= 1, all of the above information is available from ?prelim.mix

Overall, what you have stated suggests that you may have tried to use 'mix' for data consisting of "continuous" variables with some missing values (implied by your use of "p=0"). As pointed out above, this will not work -- 'mix' is for use with data which contain both "categorical" and "continuous" variables, using a multinomial model for the combinations of levels of the former, and a multivariate normal model for the latter with means conditional on the factor levels of the former.

If you have data which consist entirely of variables of one kind only, with some missing values, then you should use a different package: 'cat' if all the variables are "categorical", 'norm' if all the variables are "continuous".

The package 'mix' will not, for instance, recognise that "p=0" means that all variables are continuous and consequently use 'norm' instead; nor recognise that "p = number of columns" means that all variables are categorical and use 'cat' instead. You have to make that choice yourself.

Hoping this helps,
Ted.



E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861
Date: 21-Aug-05                                       Time: 11:18:33
------------------------------ XFMail ------------------------------

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Aug 21 20:38:18 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:40:13 EST