[R] aregImpute: beginner's question

From: Anders Schwartz Corr <corr_at_fas.harvard.edu>
Date: Sun 10 Jul 2005 - 08:33:10 EST

Hello R-help,

Thanks for everyone's very helpful suggestions so far. I am now trying to use aregImpute for my missing data imputation. Here are the code and error messages. Any suggestions would be very much appreciated.

Sincerely,

Anders Corr

########################################

#Question for R-Help on aregImpute

########################################


#DOWNLOAD DATA (61Kb)
download.file("http://www.people.fas.harvard.edu/~corr/tc.csv","C:/R") tc <- read.csv("tc.csv", header = TRUE)
d <- as.data.frame(tc)
n <- naclus(d)
plot(n); naplot(n) # Show patterns of NAs

#RUN aregImpute
set.seed(5)
f <- aregImpute(~y +
podb2+propdemocracy+avetrade1984dollars+concentration+cycle+polarity+propmid+terrgainer+ demgainer+ fedgainer+ popdengainer+ urbpopgainer+ tradeopgainer+ gdppcgainer+ terrloser+ demloser+ fedloser+ popdenloser+ urbpoploser+ tradeoploser+ gdppcloser, n.impute=100, defaultLinear=TRUE, data=d) par(mfrow=c(2,3))
plot(f, diagnostics=TRUE, maxn=2)
fmi <- fit.mult.impute(y ~
podb2+propdemocracy+avetrade1984dollars+concentration+cycle+polarity+propmid+terrgainer+ demgainer+ fedgainer+ popdengainer+ urbpopgainer+ tradeopgainer+ gdppcgainer+ terrloser+ demloser+ fedloser+ popdenloser+ urbpoploser+ tradeoploser+ gdppcloser, lm, f,

                       data=d)







> ########################################
>
> #Question for R-Help on aregImpute
>
> ########################################
>
>
> #DOWNLOAD DATA (61Kb)
> download.file("http://www.people.fas.harvard.edu/~corr/tc.csv","C:/R")
trying URL `http://www.people.fas.harvard.edu/~corr/tc.csv' Content type `text/plain' length 62770 bytes opened URL
downloaded 61Kb

> tc <- read.csv("tc.csv", header = TRUE)
> d <- as.data.frame(tc)
> n <- naclus(d)
> plot(n); naplot(n) # Show patterns of NAs
>
> #RUN aregImpute
> set.seed(5)
> f <- aregImpute(~y +

podb2+propdemocracy+avetrade1984dollars+concentration+cycle+polarity+propmid+terrgainer+ demgainer+ fedgainer+ popdengainer+ urbpopgainer+ tradeopgainer+ gdppcgainer+ terrloser+ demloser+ fedloser+ popdenloser+ urbpoploser+ tradeoploser+ gdppcloser, n.impute=100, defaultLinear=TRUE, data=d) Iteration:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Error in lm.fit.qr.bare(f$tx, f$ty) :

NA/NaN/Inf in foreign function call (arg 1)
> par(mfrow=c(2,3))
> plot(f, diagnostics=TRUE, maxn=2)

2222222222222222222222> fmi <- fit.mult.impute(y ~
podb2+propdemocracy+avetrade1984dollars+concentration+cycle+polarity+propmid+terrgainer+ demgainer+ fedgainer+ popdengainer+ urbpopgainer+ tradeopgainer+ gdppcgainer+ terrloser+ demloser+ fedloser+ popdenloser+ urbpoploser+ tradeoploser+ gdppcloser, lm, f,
+                        data=d)

Error in impute.transcan(xtrans, imputation = i, data = data, list.out = TRUE, :
        inconsistant naming of observations led to differing length vectors
>


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 Jul 10 08:41:23 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:27 EST