R version 2.13.1 (2011-07-08) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i386-pc-mingw32/i386 (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > library(foreign) > library(MASS) > library(boot) > library(Amelia) ## ## Amelia II: Multiple Imputation ## (Version 1.2-18, built: 2010-11-04) ## Copyright (C) 2005-2011 James Honaker, Gary King and Matthew Blackwell ## Refer to http://gking.harvard.edu/amelia/ for more information ## > library(MatchIt) ## ## MatchIt (Version 2.4-18, built: 2011-04-26) ## Please refer to http://gking.harvard.edu/matchit for full documentation ## or help.matchit() for help with commands supported by MatchIt. ## > library(Zelig) ## ## Zelig (Version 3.5, built: 2010-01-20) ## Please refer to http://gking.harvard.edu/zelig for full ## documentation or help.zelig() for help with commands and ## models supported by Zelig. ## ## Zelig project citations: ## Kosuke Imai, Gary King, and Olivia Lau. (2009). ## ``Zelig: Everyone's Statistical Software,'' ## http://gking.harvard.edu/zelig. ## and ## Kosuke Imai, Gary King, and Olivia Lau. (2008). ## ``Toward A Common Framework for Statistical Analysis ## and Development,'' Journal of Computational and ## Graphical Statistics, Vol. 17, No. 4 (December) ## pp. 892-913. ## To cite individual Zelig models, please use the citation format printed with ## each model run and in the documentation. ## Attaching package: 'Zelig' The following object(s) are masked from 'package:MatchIt': user.prompt Warning message: '.readRDS' is deprecated. Use 'readRDS' instead. See help("Deprecated") > > > 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") -- Imputation 1 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -- Imputation 2 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -- Imputation 3 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 -- Imputation 4 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -- Imputation 5 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 > > > #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 row col newtradeMean newtradeSD [1,] 1 3 30.0 5.0 [2,] 2 3 29.0 5.0 [3,] 4 3 28.0 5.0 [4,] 6 3 31.0 4.0 [5,] 9 3 32.0 3.0 [6,] 16 3 34.0 3.0 [7,] 18 3 30.0 2.0 [8,] 19 3 34.0 4.0 [9,] 21 3 26.0 5.0 [10,] 22 3 32.0 4.0 [11,] 23 3 30.0 5.0 [12,] 24 3 29.0 5.0 [13,] 27 3 28.0 5.0 [14,] 28 3 31.0 4.0 [15,] 39 3 32.0 3.0 [16,] 40 3 34.0 3.0 [17,] 41 3 30.0 2.0 [18,] 45 3 34.0 4.0 [19,] 46 3 26.0 5.0 [20,] 52 3 32.0 4.0 [21,] 53 3 30.0 5.0 [22,] 55 3 29.0 5.0 [23,] 58 3 28.0 5.0 [24,] 62 3 31.0 4.0 [25,] 63 3 32.0 3.0 [26,] 71 3 34.0 3.0 [27,] 72 3 30.0 2.0 [28,] 78 3 34.0 4.0 [29,] 79 3 26.0 5.0 [30,] 80 3 32.0 4.0 [31,] 81 3 30.0 5.0 [32,] 86 3 29.0 5.0 [33,] 91 3 28.0 5.0 [34,] 95 3 31.0 4.0 [35,] 96 3 32.0 3.0 [36,] 97 3 34.0 3.0 [37,] 99 3 30.0 2.0 [38,] 100 3 34.0 4.0 [39,] 101 3 26.0 5.0 [40,] 104 3 32.0 4.0 [41,] 105 3 30.0 5.0 [42,] 106 3 29.0 5.0 [43,] 107 3 28.0 5.0 [44,] 109 3 31.0 4.0 [45,] 111 3 32.0 3.0 [46,] 112 3 34.0 3.0 [47,] 115 3 30.0 2.0 [48,] 131 3 34.0 4.0 [49,] 133 3 26.0 5.0 [50,] 154 3 32.0 4.0 [51,] 155 3 31.0 3.0 [52,] 156 3 31.0 4.0 [53,] 158 3 32.0 5.0 [54,] 159 3 33.0 6.0 [55,] 160 3 34.0 4.0 [56,] 164 3 35.0 3.0 [57,] 168 3 20.0 4.0 [58,] 169 3 21.0 2.0 [59,] 64 4 7.0 4.0 [60,] 139 4 8.0 1.0 [61,] 18 7 2.0 1.2 [62,] 19 7 2.1 0.3 [63,] 38 7 2.2 0.4 [64,] 57 7 2.0 0.3 [65,] 76 7 2.5 0.4 [66,] 94 7 2.3 0.3 [67,] 95 7 2.5 0.2 [68,] 114 7 2.1 0.3 [69,] 132 7 1.9 0.4 [70,] 133 7 1.8 0.3 [71,] 152 7 1.7 0.3 [72,] 170 7 2.9 0.3 [73,] 171 7 2.0 0.2 [74,] 12 8 0.0 0.3 [75,] 46 8 0.0 0.2 [76,] 169 8 1.0 0.3 [77,] 18 9 0.3 0.3 [78,] 19 9 0.4 0.1 [79,] 37 9 0.5 0.1 [80,] 38 9 0.3 0.2 [81,] 56 9 0.2 0.2 [82,] 57 9 0.3 0.3 [83,] 75 9 0.2 0.3 [84,] 76 9 0.4 0.1 [85,] 94 9 0.5 0.1 [86,] 95 9 0.3 0.2 [87,] 113 9 0.2 0.2 [88,] 114 9 0.3 0.3 [89,] 132 9 0.3 0.3 [90,] 133 9 0.4 0.1 [91,] 151 9 0.5 0.1 [92,] 152 9 0.3 0.2 [93,] 170 9 0.2 0.2 [94,] 171 9 0.3 0.3 > > #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") amelia starting beginning prep functions Variables used: tariff polity pop gdp.pc intresmi signed fiveop usheg running bootstrap -- Imputation 1 -- setting up EM chain indicies 1(41) 2(17) 3(0) saving and cleaning running bootstrap -- Imputation 2 -- setting up EM chain indicies 1(39) 2(7) 3(0) saving and cleaning running bootstrap -- Imputation 3 -- setting up EM chain indicies 1(38) 2(18) 3(2) 4(0) saving and cleaning running bootstrap -- Imputation 4 -- setting up EM chain indicies 1(41) 2(15) 3(1) 4(0) saving and cleaning running bootstrap -- Imputation 5 -- setting up EM chain indicies 1(40) 2(22) 3(1) 4(0) saving and cleaning > > #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") amelia starting beginning prep functions Variables used: tariff polity pop gdp.pc intresmi fiveop usheg noms.signed.2 running bootstrap Error in muPriors[priors[, 1:2]] <- priors[, 3] : NAs are not allowed in subscripted assignments >