library(foreign) library(MASS) library(boot) library(Amelia) library(MatchIt) library(Zelig) data(freetrade) #Test to see if imputation works without priors, without noms, and without ords a.out = amelia(freetrade, m=5, ts = "year", cs = "country") #Found the mean and standard deviation for each variable that has at least one NA #I created a matrix of the locations of the NAs(rows and columns), the means and SDs newtrade = which(is.na(freetrade), arr.ind = TRUE) newtradeMean = c(30,29,28,31,32,34,30,34,26,32,30,29,28,31,32,34,30,34,26,32,30,29,28,31,32, 34,30,34,26,32,30,29,28,31,32,34,30,34,26,32,30,29,28,31,32,34,30,34,26,32, 31,31,32,33,34,35,20,21,7,8,2.0,2.1,2.2,2.0,2.5,2.3,2.5,2.1,1.9,1.8,1.7,2.9, 2.0,0,0,1,.3,.4,.5,.3,.2,.3,.2,.4,.5,.3,.2,.3,.3,.4,.5,.3,.2,.3) newishtrade = cbind(newtrade,newtradeMean) newtradeSD = c(5,5,5,4,3,3,2,4,5,4,5,5,5,4,3,3,2,4,5,4,5,5,5,4,3,3,2,4,5,4,5,5,5,4,3,3,2,4,5, 4,5,5,5,4,3,3,2,4,5,4,3,4,5,6,4,3,4,2,4,1,1.2,.3,.4,.3,.4,.3,.2,.3,.4,.3,.3,.3, .2,.3,.2,.3,.3,.1,.1,.2,.2,.3,.3,.1,.1,.2,.2,.3,.3,.1,.1,.2,.2,.3) newishtrade = cbind(newtrade,newtradeMean, newtradeSD) newishtrade #Test to see if imputation works with priors, without noms, and with ords a.out = amelia(freetrade, m=5, ts = "year", cs = "country", priors = newishtrade, p2s=2, ords="signed") #Test to see if imputation works with priors, with noms, and without ords a.out = amelia(freetrade, m=5, ts = "year", cs = "country", priors = newishtrade, p2s=2, noms="signed")