The freetrade data frame in the Amelia package has economic and political data o
ID: 3757441 • Letter: T
Question
The freetrade data frame in the Amelia package has economic and political data on nine developing countries in Asia from 1980 to 1999. These 9 variables include year, country, average tariff rates, Polity IV score, total population, gross domestic product per capita, gross international reserves, a dummy variable for if the country had signed an IMF agreement in that year, a measure of financial openness and a measure of US hegemony. Unfortunately, this data has missing values You will perform the following linear regression to predict the value of tariff lm(data-freetrade,tariff year+country+polity+poptgdp. pc+intresmi+signed+fiveop+usheg) (a) Perform the regression using listwise deletion (b) Perform the regression using mean imputation (c) Perform the regression using multiple imputation in particular, multivariate imputation by chained equations. Note: you will have to find an imputation method that will work with this data! (d) Compare the coefficients for each of the regression models. Which method for dealing with missing values do you think is best for this data?Explanation / Answer
Regression using listwise deletion:
set.seed(33333)
y <- rnorm(1000)
x1 <- y*2 + rnorm(1000, sd=.2)
x2 <- y*5 + rnorm(1000, sd=.5)
y[sample(1:1000, 10)] <- NA
x1[sample(1:1000, 10)] <- NA
x2[sample(1:1000, 10)] <- NA
mydata <- data.frame(y, x1, x2)
covMatrix <- cov(mydata, use="pairwise.complete.obs")
#Listwise Deletion
listwiseDeletion <- lm(y ~ x1 + x2, data=mydata)
observations <- length(listwiseDeletion$na.action) #30 rows deleted due to listwise deletion
coef(listwiseDeletion)
(Intercept) x1 x2
0.001995527 0.245372245 0.100001989
#Pairwise Deletion --- but missing intercept
pairwiseDeletion <- mat.regress(y="y", x=c("x1","x2"), data=covMatrix, n.obs=observations)
pairwiseDeletion$beta
y
x1 0.1861277
x2 0.1251995
#Pairwise Deletion --- tried to add intercept, but received error when fitting model
mydata$intercept <- 0
covMatrixWithIntercept <- cov(mydata, use="pairwise.complete.obs")
pairwiseDeletionWithIntercept <- mat.regress(y="y", x=c("intercept","x1","x2"), data=covMatrixWithIntercept, n.obs=observations)
Something is seriously wrong the correlation matrix.
In smc, smcs were set to 1.0
Warning messages:
1: In cov2cor(C) :
diag(.) had 0 or NA entries; non-finite result is doubtful
2: In cor.smooth(R) :
I am sorry, there is something seriously wrong with the correlation matrix,
cor.smooth failed to smooth it because some of the eigen values are NA.
Are you sure you specified the data correctly?
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.