After the following R commands:
a.out<-amelia(bd2,m=5 ,idvars =c("bd_id","cty"),noms=c("race4","outc")) ,
I received this error message:
"Error in if (sum(non.vary == 0)) { :
argument is not interpretable as logical"
What that means?
I used the current versions of R and Amelia on Windows
The data contains more than 100,000 records, with 6 variables. They are all factors except bwt3, a continuous variable.
See below the first rows of the data frame bd2:
> head(bd2)
bd_id
race4
outc
cty
bwt3
1989-35129
1
1
0
2665
1989-43790
2
1
0
3685
1989-44528
1
1
0
3402
1989-48485
1
1
0
3175
1989-49402
1
1
0
3742
1989-55241
4
1
0
3941
Thanks you for any help.
Ndiaye
Hi,
Thanks for your advice. The problem indeed seems to be -cbind()-.
Matthijs
On 17 dec 2009, at 07:00, amelia_at_lists_gking_harvard_edu wrote:
> amelia_at_lists_gking_harvard_edu Thursday, December 17 2009 Volume 01 : Number 067
>
>
>
>
> ----------------------------------------------------------------------
>
> Date: Wed, 16 Dec 2009 13:09:51 -0500
> From: Matt Blackwell <blackwel(a)fas.harvard.edu>
> Subject: Re: [amelia] error for manipulated data sets?
>
> Hi Matthijs,
>
> One thing you may want to check is the length of the new variable you
> created against the number of rows in the dataset. In addition, cbind
> might be creating problems. Perhaps you could try this alternative
> method of adding a variable:
>
> ##### begin code #####
> a.out.final <- a.out
> for(i in 1:10){
> <create new variables>
> a.out.final$imputatations[[i]][,"newvarname"] <- <new variables>
> }
> ##### end code #####
>
> Where you can replace newvarname with a more substantive name.
>
> I hope this helps,
> matt.
>
> On Tue, Dec 15, 2009 at 12:00 PM, Matthijs de Zwaan <m.dezwaan(a)gmail.com> wrote:
>> Dear Amelia Listers
>> I have a data set which gives me the counts of a number of religious groups, in 3 cities for 60 years. I use these counts to generate an index for religious diversity in each available year.
>>
>> I had missing data, which I imputed using AmeliaII in R. I included both the counts and the index to generate the imputed values, and then used the "new" counts to generate the index again (overwriting the imputed index). I also generated a number of other variables using the index (squared, interactions etc). I gather the originally imputed data and my new variables using:
>> ##### begin code #####
>> a.out.final <- a.out
>> for(i in 1:10){
>> <create new variables>
>> a.out.final$imputatations[[i]] <- cbind(a.out$imputations[[i]], <new variables>)
>> }
>> ##### end code #####
>> where a.out is the original Amelia output. This works fine, as far as I can see. however, when I now ask for a summary(a.out.final), I get an error message. The first past of the message is the same as for summary(a.out), but then I get:
>>
>>
>> Fraction Missing for individual variables:
>> -----------------------------------------
>>
>> Error in `row.names<-.data.frame`(`*tmp*`, value = c("cityid", "year", :
>> invalid 'row.names' length
>>
>> ("cityid" and "year" are obviously my panel/time indicators )
>> Does this mean that I have made a mistake, or am trying to do something that cannot be done? Or is it simply due to the fact that Zelig can no longer recognise what was originally missing and what not? I am new to R and Zelig, and such (unintelligible) error messages scare me!
>>
>> Thanks again for your time,
>> Matthijs de Zwaan
>> -
>> Amelia mailing list served by Harvard-MIT Data Center
>> [Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
>> More info about Amelia: http://gking.harvard.edu/amelia
>>
>>
>
> ------------------------------
>
> End of amelia_at_lists_gking_harvard_edu V1 #67
> ***********************************************
>
> -
> Amelia mailing list served by Harvard-MIT Data Center
> [Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
> More info about Amelia: http://gking.harvard.edu/amelia
-
Amelia mailing list served by Harvard-MIT Data Center
[Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
More info about Amelia: http://gking.harvard.edu/amelia
Dear Amelia Listers
I have a data set which gives me the counts of a number of religious groups, in 3 cities for 60 years. I use these counts to generate an index for religious diversity in each available year.
I had missing data, which I imputed using AmeliaII in R. I included both the counts and the index to generate the imputed values, and then used the "new" counts to generate the index again (overwriting the imputed index). I also generated a number of other variables using the index (squared, interactions etc). I gather the originally imputed data and my new variables using:
##### begin code #####
a.out.final <- a.out
for(i in 1:10){
<create new variables>
a.out.final$imputatations[[i]] <- cbind(a.out$imputations[[i]], <new variables>)
}
##### end code #####
where a.out is the original Amelia output. This works fine, as far as I can see. however, when I now ask for a summary(a.out.final), I get an error message. The first past of the message is the same as for summary(a.out), but then I get:
Fraction Missing for individual variables:
-----------------------------------------
Error in `row.names<-.data.frame`(`*tmp*`, value = c("cityid", "year", :
invalid 'row.names' length
("cityid" and "year" are obviously my panel/time indicators )
Does this mean that I have made a mistake, or am trying to do something that cannot be done? Or is it simply due to the fact that Zelig can no longer recognise what was originally missing and what not? I am new to R and Zelig, and such (unintelligible) error messages scare me!
Thanks again for your time,
Matthijs de Zwaan
-
Amelia mailing list served by Harvard-MIT Data Center
[Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
More info about Amelia: http://gking.harvard.edu/amelia
Dear Amelia Listers,
I am new to R, Zelig and Amelia. I think my question is rather straight
forward, but couldn't find an answer on the Amelia list. Please excuse me if
I missed something…
I am using Amelia to create ten new data sets for my missing data. I need to
change the variables in the newly imputed data (I need to create an
interaction variable with my variable with missing values). I do this by
manipulating in turn each of the imputed data sets after having saved those
sets using write.amelia(). Now, how do I again collect those data sets into
an object that Amelia/Zelig can work with?
Thanks for your time,
Matthijs
Tomas
Thanks for the response. The first method you propose for exploration
could be very useful. I guess I didn't think of it in thee terms and
I probably should have.
The second approach is very similar to what I was thinking of doing if
all else fails. I would have imputed the expected values and just use
that for EFA. (I would do this either through imputing a large number
of times and averaging the imputed values, or just use the EM
algorithm probably through SPSS MVA.) I guess this does the same
thing that you approach proposes.
The problem with this approach is that it underestimates the
uncertainty of the unknown values. For most analysis rubin's rules
can be used to combine all point estimates as long as they have a
standard error. Mplus will now give you standard errors for the
loadings so that is very useful. But the decision on the number of
factors to extract is problematic. (Even without any missing data it
is problematic.) Lets say I establish a rule on the number of factors
to extract. I impute m times. Analyze the m datasets and I get 3
factors for a 1/3*m datasets, 4 for 1/3*m and 5 for 1/3*m. How many
to extract then? Go with the median? Why? Why not?
Of course, one solution is not to bother. Just do it and consider the
problem when (if) it arises. I can totally imagine that all
imputations would give me the same results. Problem solved then.
There also might be something else I am missing. It is not entirely
clear what the advantage of any of the above is to listwise deletion.
etc.
Thanks for your quick input.
L
On Dec 7, 2009, at 5:58 PM, Tomáš Kubiš wrote:
> Hi Levente,
> if I understood your issue right, you have MI data and want to
> conduct fa on this data. I faced the same problem and came up with
> two ways how to conduct such an analysis.
>
> First, you can use imputations separately, conduct the fa on each
> one of them and observe if there are significant differences in the
> loadings of factors in comparisson to an unimputed dataset. Moreover
> you can observe if imputaions differ among themselves. For pure
> exploration, this will help you to identify dimensions and you can
> generalize the result in that you build an average of loadings for
> each factor and thus get one set of factors.
>
> Second, you can take the covariance or correlation matrices of the
> imputed datasets and build an average of them. Then you can conduct
> the fa on this average cor or cov matrix. You have one matrix and
> thus get again one set of factors.
>
> As you said, it is difficult to find literature and I didn't find
> support for any of these two methods. I would be inclined to use the
> second one and make an average of cor matrices because it is the
> input into the factor analysis.
>
> Good luck with your analysis and I hope that you will get some more
> scientific help.
>
> Regards,
>
> Tomas
>
> 2009/12/7 Levente Littvay <levi(a)littvay.com>
> Dear Amelia List
>
> Does anyone know of a good and accessible way to analyze multiply
> imputed data using exploratory factor analysis? (Possibly, would
> Zelig know how to do this?) Anything else? SPSS won't do it.
> Mplus won't do it (as far as I can see). I found very little by way
> of published work on the topic. I could use a bit of guidance.
>
> Thanks
>
> Cheers
>
> Levente Littvay
> Assistant Professor
> Department of Political Science
> Central European University
> -
> Amelia mailing list served by Harvard-MIT Data Center
> [Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?
> info=amelia
> More info about Amelia: http://gking.harvard.edu/amelia
>
Dear Amelia List
Does anyone know of a good and accessible way to analyze multiply
imputed data using exploratory factor analysis? (Possibly, would
Zelig know how to do this?) Anything else? SPSS won't do it. Mplus
won't do it (as far as I can see). I found very little by way of
published work on the topic. I could use a bit of guidance.
Thanks
Cheers
Levente Littvay
Assistant Professor
Department of Political Science
Central European University
-
Amelia mailing list served by Harvard-MIT Data Center
[Un]Subscribe/View Archive: http://lists.gking.harvard.edu/?info=amelia
More info about Amelia: http://gking.harvard.edu/amelia