[R] aregImpute: beginner's question

Anders Schwartz Corr corr at fas.harvard.edu
Sun Jul 10 00:33:10 CEST 2005



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
>




More information about the R-help mailing list