In: Math
Consider the data in the file Growth.csvwhich contains data on average growth rates over 1960-1995 for 65 countries, along with variables that are potentially related to growth. A complete description of the data is given in data description which is under the name Growth- Data Description and can be found on Blackboard.
Using this data, carry out the following empirical exercises:
Construct a table that shows the sample mean, std. deviation, minimum and maximum values for the variablesGrowth, Trade-Share, YearsSchool, Oil, Rev_Coups, Assasinations, and RGDP60.
Run a regression of Growthon TradeShare, YearsSchool,Rec_Coups, Assasinations and RGDP60.Show the output of this regression in R (take a screenshot and crop the output summary in your word file that contains your answers).
What is the value on the coefficient on Rev_Coups?Is it statistically significant? Do interpretation on this coefficient.
What is the value of the adjusted R-square? Do these variables explain the majority of country growth?
Use the regression to predict the average annual growth for a country that has average values for all regressors.
Repeat (3) but now assume that the country’s value for TradeShareis one std. deviation above its mean.
Notes: Please submit through email an individual word file with your answers WELL ORGANIZEDalong with your R code (.R file) at the end.
SOLUTION:-
Here is the R-console output. R-script is given below
> # rm(list=ls())
>
> # Creating a function for obtaining a structured output for
required statistics
>
> desc <- function(x){
+ m <- mean(x)
+ std <- sd(x)
+ mi <- min(x)
+ ma <- max(x)
+ out <- c(m,std,mi,ma)
+ return(out)
+ }
>
> # Aplying our function on all the columns.
> temp <- apply(df[,-1],2,desc)
> # Renaming the columns.
> rownames(temp) <- c("Mean","Standard Deviation"
,"Minimum","Maximum")
> # Now you can use "temp" or "t(temp)" for the representaion of
required table.
> t(temp)
Mean Standard Deviation Minimum Maximum
growth 1.9427154 1.8971198 -2.811944 7.1568546
oil 0.0000000 0.0000000 0.000000 0.0000000
rgdp60 3103.7846487 2512.6568456 366.999939 9895.0039060
tradeshare 0.5647030 0.2892703 0.140502 1.9926157
yearsschool 3.9850769 2.5420004 0.200000 10.0699997
rev_coups 0.1674501 0.2246798 0.000000 0.9703704
assasinations 0.2775641 0.4915284 0.000000 2.4666667
>
> #Now running regression
>
> model.linear <- lm(growth~., data=df[,-c(1,3)]) #-c(1,3)
will remove unwanted variables
> summary(model.linear)
Call:
lm(formula = growth ~ ., data = df[, -c(1, 3)])
Residuals:
Min 1Q Median 3Q Max
-3.6329 -0.9437 -0.0538 0.7567 5.1548
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.4897603 0.6895996 0.710 0.480372
rgdp60 -0.0004693 0.0001482 -3.167 0.002441 **
tradeshare 1.5616957 0.7579475 2.060 0.043776 *
yearsschool 0.5748461 0.1393379 4.126 0.000118 ***
rev_coups -2.1575029 1.1102915 -1.943 0.056769 .
assasinations 0.3540784 0.4773943 0.742 0.461218
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.582 on 59 degrees of freedom
Multiple R-squared: 0.3589, Adjusted R-squared: 0.3045
F-statistic: 6.605 on 5 and 59 DF, p-value: 6.065e-05
> # rev_coups coefficient value is -2.1575029 which is ot
significant at alpha = 0.05, 0.01
> # It is significant at alpha = 0.1(90% level of
significance).
>
> # Adjusted R-square is very bad it is 0.3045. We can say that
these variables
> # are not explaining the growth properly.
>
> #Now working for prediction
> #We have already calculated the average/mean value for all the
variables in the table temp
>
> df.pre <- temp [1,-c(1,2)]
> head(df.pre)
rgdp60 tradeshare yearsschool rev_coups assasinations
3103.7846487 0.5647030 3.9850769 0.1674501 0.2775641
>
> prediction <- predict(model.linear, newdata =
data.frame(t(df.pre)))
> prediction
1
1.942715
#########################################################################################################
# rm(list=ls())
# Creating a function for obtaining a structured output for required statistics
desc <- function(x){
m <- mean(x)
std <- sd(x)
mi <- min(x)
ma <- max(x)
out <- c(m,std,mi,ma)
return(out)
}
# Aplying our function on all the columns.
temp <- apply(df[,-1],2,desc)
# Renaming the columns.
rownames(temp) <- c("Mean","Standard Deviation"
,"Minimum","Maximum")
# Now you can use "temp" or "t(temp)" for the representaion of
required table.
t(temp)
#Now running regression
model.linear <- lm(growth~., data=df[,-c(1,3)]) #-c(1,3) will
remove unwanted variables
summary(model.linear)
# rev_coups coefficient value is -2.1575029 which is ot significant
at alpha = 0.05, 0.01
# It is significant at alpha = 0.1(90% level of significance).
# Adjusted R-square is very bad it is 0.3045. We can say that
these variables
# are not explaining the growth properly.
#Now working for prediction
#We have already calculated the average/mean value for all the
variables in the table temp
df.pre <- temp [1,-c(1,2)]
head(df.pre)
prediction <- predict(model.linear, newdata =
data.frame(t(df.pre)))
prediction