Login
Order Now
Support
Econometrics Task Using R Programming

Econometrics Task Using R Programming

  • 7th Jan, 2022
  • 23:49 PM

library(AER)
library(quantmod)
library(NLP)

#Q1

#1
data(CASchools)
str(CASchools)

CA<-CASchools
CA$avg_score<-(CA$read+CA$math)/2
CA$size<-CA$students/CA$teachers

#2
lm1<-lm(avg_score ~ income + I(income^2), data=CA)
summary(lm1)

#3
str(CA)
lm2<-lm(avg_score ~ income + I(income^2) + income*grades,data=CA)
summary(lm2)

#4
lm3<-lm(log(avg_score) ~ log(income), data=CA)
summary(lm3)

#5
i<-1
CA$mathx<-ifelse(CA$math>CA$read,1,0)
table(CA$mathx)
lm4<-glm(mathx ~ size+ grades + income + expenditure , data=CA, family=binomial(link="probit"))
lm5<-glm(mathx ~ size+ grades + income + expenditure , data=CA, family="binomial")

summary(lm4)
summary(lm5)


#Q2
data(CigarettesSW)


#1
Cigs<-CigarettesSW
str(Cigs)
Cigs_1995<-Cigs[which(Cigs$year==1995),]

str(Cigs_1995)
Cigs_1995$rprice<-Cigs_1995$price/Cigs_1995$cpi

Cigs_1995$salestax<-Cigs_1995$taxs-Cigs_1995$tax
summary(Cigs_1995$salestax)

#2
lm_1<-lm(log(packs) ~ log(rprice), data= Cigs_1995)
summary(lm_1)

#3
iv_1<-ivreg(log(packs)~log(rprice)|salestax, data=Cigs_1995)
summary(iv_1)

summary(iv_1, diagnostics=T)
#Wu-Hausman Tests indicate that there is no issue of endogeniety

#Q3

US<-read.csv("US_Macro.csv")
str(US)
US_ts<-ts(US$GDP_Growth, frequency = 4, start=c(1957,1))

ar.ols(US_ts, order=1, demean=F, intercept =T)
ar.ols(US_ts, order=2, demean=F, intercept =T)

Share this post

assignment helpassignment helperassignment expertsassignment writing services