Hi Melanie,
Thanks for reporting this bug. Amelia should have a more graceful error
message for setting prior values on nominal variables. Thus, it is better in
this case to use "ords".
More technical discussion for the curious:
Even though dichotomous variables can be specified as either "noms" or
"ords", Amelia does not handle them both identically. Ordinals are imputed
on the scale of the original variable and then converted into one of the
ordinal categories, while nominal variables are broken up into k-1 dummy
variables in the imputation and then the final imputation is reformed from
these variables (where k is the number of categories). These processes are
identical when there are only 2 categories. The error you see is because
"noms" moves the variable around in the data matrix and Amelia never tells
the priors matrix. We'll fix this up in a future release.
Also: thanks a ton for the short, reproducible example!
Cheers,
matt.
~~~~~~~~~~~
Matthew Blackwell
PhD Candidate
Institute for Quantitative Social Science
Department of Government
Harvard University
url:
http://people.fas.harvard.edu/~blackwel/
On Mon, Aug 1, 2011 at 4:17 PM, Melanie Goodrich
<melaniegoodrich(a)gmail.com>wrote;wrote:
Hello,
I have a dataset with dichotomous variables that has missingness that I am
trying to use Amelia to address. In addition, I need to include
observational priors (ridge priors are not an option).
Given the data I am using, I originally tried to run Amelia with these
dichotomous variables identified as "noms". However, I got the follwoing
error message when I did this:
"
Error in muPriors[priors[, 1:2]] <- priors[, 3] :
NAs are not allowed in subscripted assignments
"
According to the documentation (footnote 8 on page 17): "Dichotomous (two
category) variables are a special case of nominal variables. For these
variables, the nominal and ordinal methods of transformation in Amelia
agree." So, I was particularly confused by this error message given that
I had already tried running the exact same code with the only difference
being that I had used "ords" to identify my dichotomous variables. And that
code had worked.
For now, I have the code running using using the "ords" option instead of
the "noms". I can only assume that the introduction of priors is causing
the problem. It is not clear to me why this should be, though. Also the
fact that, contrary to the documentation, I am not getting the same results
for the ordinal and the nominal methods makes me wonder if the two methods
are not actually identical, in which case maybe it does matter which option
I use (beyond, of course, the matter of which method actually runs!).
I would appreciate any guidance you can offer as to what is causing this
error message. I have attached code, and the resulting output, replicating
the problem with the freetrade data, in case that helps clarify the issue.
Thank you in advance for your assisstance.
Best,
Melanie Goodrich
http://www.linkedin.com/in/melaniegoodrich