0% found this document useful (0 votes)
51 views12 pages

Assignment 7: Chitresh Kumar

The document presents results from linear regression analyses conducted to examine the relationship between government expenditure on education (EE) and GDP per capita (GDP) in various countries. Several models are estimated, including an ordinary least squares regression of EE on GDP (Model 1), a regression of the squared residuals from Model 1 on GDP and GDP squared (Model 2), a regression with heteroscedasticity-consistent standard errors (Model 3), and a weighted least squares regression that weights observations by 1/GDP (Model 4). The results indicate a significant positive relationship between EE and GDP in all models. Model 2 suggests heteroscedasticity is present, which Model 3 and 4 aim to address.

Uploaded by

ChitreshKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views12 pages

Assignment 7: Chitresh Kumar

The document presents results from linear regression analyses conducted to examine the relationship between government expenditure on education (EE) and GDP per capita (GDP) in various countries. Several models are estimated, including an ordinary least squares regression of EE on GDP (Model 1), a regression of the squared residuals from Model 1 on GDP and GDP squared (Model 2), a regression with heteroscedasticity-consistent standard errors (Model 3), and a weighted least squares regression that weights observations by 1/GDP (Model 4). The results indicate a significant positive relationship between EE and GDP in all models. Model 2 suggests heteroscedasticity is present, which Model 3 and 4 aim to address.

Uploaded by

ChitreshKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Assignment 7

Chitresh Kumar
if(!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse, reshape, gplots, ggmap, RStata,haven,

data.table,margins,pastecs,MASS,lmtest,broom,car,stargazer,sandwich,knitr)
search()
theme_set(theme_classic())

pub<-read_dta('pubexp.dta')
head(pub)

## # A tibble: 6 x 3
## ee gdp p
## <dbl> <dbl> <dbl>
## 1 0.34 5.67 0.36
## 2 0.22 10.1 2.9
## 3 0.32 11.3 2.39
## 4 1.23 18.9 3.44
## 5 1.81 20.9 3.87
## 6 1.02 22.2 10.7

PART b
EE<-pub$ee/pub$p
GDP<-pub$gdp/pub$p
lm1<-lm(EE~GDP,data=pub)
summary(lm1)

##
## Call:
## lm(formula = EE ~ GDP, data = pub)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.21682 -0.08804 -0.01401 0.06517 0.38156
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.124573 0.048523 -2.567 0.0151 *
## GDP 0.073173 0.005179 14.128 2.65e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1359 on 32 degrees of freedom
## Multiple R-squared: 0.8618, Adjusted R-squared: 0.8575
## F-statistic: 199.6 on 1 and 32 DF, p-value: 2.65e-15

rs<-resid(lm1)
plot(EE,rs)

plot(lm1)
PART c
ressq<-rs^2
GDP_S<-GDP^2
lm2<-lm(ressq~GDP+GDP_S,data=pub)
glm2<-glance(lm2)
Rsq<-glm2$r.squared
chisq<-34*Rsq
pval<-1-pchisq(chisq,1)
print(chisq)

## [1] 9.961449

print(pval)

## [1] 0.001598522

PART d
cov1 <- hccm(lm1, type="hc1")
pub.HC1 <- coeftest(lm1, vcov.=cov1)
kable(tidy(pub.HC1))

term estimate std.error statistic p.value


(Intercept -0.1245728 0.0404140 -3.08242 0.0042041
)
GDP 0.0731732 0.0062116 11.78005 0.0000000

PART e
w<-1/GDP
lmwls<-lm(EE~GDP,weights=w,data=pub)
summary(lmwls)

##
## Call:
## lm(formula = EE ~ GDP, data = pub, weights = w)
##
## Weighted Residuals:
## Min 1Q Median 3Q Max
## -0.072028 -0.038561 -0.008488 0.027706 0.105415
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.092921 0.028904 -3.215 0.00298 **
## GDP 0.069321 0.004412 15.713 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.04451 on 32 degrees of freedom
## Multiple R-squared: 0.8853, Adjusted R-squared: 0.8817
## F-statistic: 246.9 on 1 and 32 DF, p-value: < 2.2e-16

You might also like