# Untitled

unknown
plain_text
7 months ago
1.3 kB
1
Indexable
Never
```install.packages("ivmodel")
library(ivmodel)
card=card.data[,-35]

#endogenitas
lwage=as.matrix(card[,33])
educ=card[,c(4)]
exper=card[,(32)]
expersq=card[,c(34)]
black=card[,c(22)]
smsa=card[,c(23)]
south=card[,c(24)]

library(lmtest)
model=lm(lwage~educ+exper+expersq+black+smsa+south)
summary(model)

m<-data.frame(card\$educ, card\$exper, card\$expersq, card\$black, card\$smsa, card\$south)
cor(m)

##Uji keberadaan korelasi tiap variabel yang memiliki korelas kuat dengan residual model
m1<-data.frame(card\$educ, card\$exper, card\$expersq, model\$residuals)
cor(m1)

##Reduced from schooling#
#educ sebagai y
age=card[,c(25)]
age2=card[,c(5)]^2
black=card[,c(22)]
smsa=card[,c(23)]
south=card[,c(24)]
nearc4=card[,c(3)]
model1=lm(educ~age+age2+black+smsa+south+nearc4)
summary(model1)

#wage equation estimated by IV#
install.packages("ivpack")
library(ivpack)
Y=as.matrix(card[,33])
En<-cbind(schooling=educ,exper,expersq) #variabel endogenik
W<-cbind(black,smsa,south)#variabel eksogenik
z<-cbind(age,age2,nearc4)#variabel instrumen
iv<-ivreg(Y~En+W|W+z)
summary(iv,diagnostics=TRUE)

##Heteroskedastisitas
#menguji adanya ragam residual yang tidak homogen
library(lmtest)
install.packages("skedastic")
library(skedastic)
```