[R] R-Help : running MIX package

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Jan 28 10:52:02 CET 2005


On 28-Jan-05 Jeanhee Hong wrote:
> Hello all. I am inexperienced with  R and am clumsily trying to work
> through it for specific multiple imputations Id like to run for my
> thesis.In running the MIX package, I keep getting an error message
> regarding the use of the prelim.mix command. 
>  
> Error in as.integer.default(list(alcohol = c(1, 1, 1, 1, 1, 1, 1, 1, 1,
>: 
>         (list) object cannot be coerced to integer
>  
> I cannot find the source of this error. I am assuming its somewhere in
> the format of my data but cant quite seem to figure it out. I have
> followed the procedures in the manual in terms of listing categorical
> variables first and making sure they take positive integer values...Has
> anyone encountered this same error? Any help would be appreciated.Thank
> you.

I have not seen such an error message myself, but the occurrence
of "list" in it is ominous! According to the R code of prelim.mix,
this should not be introduced by prelim.mix itself and so is likely
to be somehow present in the data you submit to the function (which
cannot be checked without looking at how you define your data).

Please try the following. The function call prelim.mix(x,p)
assumes that x is a *matrix* whose first p columns are the values
of the p categorical variables (coded, as you note, as positive
integers).

So make sure that x is indeed a *matrix* and not some other R
structure (which may, e.g. a data-frame, look like a matrix but
isn't one). 'matrix' is a very specific data structure in R,
and is not to be confused with other structures which may look
like matrices.

One way to ensure this could be to use

  x<-as.matrix(your.data.frame)

(assuming that "your.data.frame" already has its columns satisfying
the requisite conditions). Another (which is what I've mainly
used) is to construct x by using 'cbind': I've tended to find
that for the sort of data one often gets, some preliminary
manipulation of the categorical variables (at least) is required
so as to get them into the required form, and this is best done
separately. So, once you have established your p categorical
variables cat1,...,catp and your k continuous variables
cont1,...,contk, something like

  x <- cbind(cat1,cat2,...,catp,cont1,cont2,...,contk)

would create a matrix called "x".

Hoping this helps,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 28-Jan-05                                       Time: 09:52:02
------------------------------ XFMail ------------------------------




More information about the R-help mailing list