## Econometrics Assignment Solution Using R Programming

• 7th Jan, 2022
• 23:49 PM
```library(AER)
library(quantmod)
library(NLP)

#Q1

#1
data(CASchools)
str(CASchools)

CA<-CASchools
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
table(CA\$mathx)
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