Probit and Logit Models R Program and Output
Probit and Logit Models R Program and Output
mydata<- read.csv("C:/Econometrics/Data/probit_insurance.csv")
attach(mydata)
# Define variables
Y <- cbind(ins)
X <- cbind(retire, age, hstatusg, hhincome, educyear, married, hisp)
# Descriptive statistics
summary(Y)
summary(X)
table(Y)
table(Y)/sum(table(Y))
# Regression coefficients
olsreg <- lm(Y ~ X)
summary(olsreg)
Call:
lm(formula = Y ~ X)
Residuals:
Min 1Q Median 3Q Max
-1.1233 -0.4065 -0.2291 0.5298 1.0341
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1270857 0.1605628 0.792 0.42871
Xretire 0.0408508 0.0182197 2.242 0.02502 *
Xage -0.0028955 0.0024189 -1.197 0.23138
Xhstatusg 0.0655583 0.0194531 3.370 0.00076 ***
Xhhincome 0.0004921 0.0001375 3.579 0.00035 ***
Xeducyear 0.0233686 0.0028672 8.150 5.15e-16 ***
Xmarried 0.1234699 0.0193618 6.377 2.07e-10 ***
Xhisp -0.1210059 0.0336660 -3.594 0.00033 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> # Logit model coefficients
> logit<- glm(Y ~ X, family=binomial (link = "logit"))
> summary(logit)
Call:
glm(formula = Y ~ X, family = binomial(link = "logit"))
Deviance Residuals:
Min 1Q Median 3Q Max
-2.456 -1.009 -0.703 1.224 2.373
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.715578 0.748622 -2.292 0.021926 *
Xretire 0.196930 0.084207 2.339 0.019354 *
Xage -0.014596 0.011287 -1.293 0.195969
Xhstatusg 0.312265 0.091674 3.406 0.000659 ***
Xhhincome 0.002304 0.000762 3.023 0.002503 **
Xeducyear 0.114263 0.014201 8.046 8.55e-16 ***
Xmarried 0.578636 0.093320 6.201 5.63e-10 ***
Xhisp -0.810306 0.195751 -4.139 3.48e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> # Logit model odds ratios
> exp(logit$coefficients)
(Intercept) Xretire Xage Xhstatusg Xhhincome Xeducyear
0.1798597 1.2176584 0.9855105 1.3665173 1.0023063 1.1210464
Xmarried Xhisp
1.7836040 0.4447220
>
> # Probit model coefficients
> probit<- glm(Y ~ X, family=binomial (link="probit"))
> summary(probit)
Call:
glm(formula = Y ~ X, family = binomial(link = "probit"))
Deviance Residuals:
Min 1Q Median 3Q Max
-2.4220 -1.0136 -0.6981 1.2236 2.4745
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.0693423 0.4553103 -2.349 0.018844 *
Xretire 0.1183526 0.0513402 2.305 0.021152 *
Xage -0.0088694 0.0068630 -1.292 0.196235
Xhstatusg 0.1977411 0.0554905 3.564 0.000366 ***
Xhhincome 0.0012327 0.0004371 2.820 0.004798 **
Xeducyear 0.0707492 0.0084925 8.331 < 2e-16 ***
Xmarried 0.3623376 0.0560521 6.464 1.02e-10 ***
Xhisp -0.4731143 0.1102319 -4.292 1.77e-05 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>
> # Regression marginal effects
> coef(olsreg)
(Intercept) Xretire Xage Xhstatusg Xhhincome
0.1270856958 0.0408508171 -0.0028955466 0.0655583417 0.0004920877
Xeducyear Xmarried Xhisp
0.0233686296 0.1234698801 -0.1210059350
>
> # Logit model average marginal effects
> LogitScalar <- mean(dlogis(predict(logit, type = "link")))
> LogitScalar * coef(logit)
(Intercept) Xretire Xage Xhstatusg Xhhincome
-0.3725232720 0.0427616020 -0.0031692953 0.0678057706 0.0005002078
Xeducyear Xmarried Xhisp
0.0248111432 0.1256458981 -0.1759510453
>
> # Probit model average marginal effects
> ProbitScalar <- mean(dnorm(predict(probit, type = "link")))
> ProbitScalar * coef(probit)
(Intercept) Xretire Xage Xhstatusg Xhhincome
-0.3792718940 0.0419770495 -0.0031457860 0.0701343649 0.0004371967
Xeducyear Xmarried Xhisp
0.0250931581 0.1285130972 -0.1678031247
>
>
> # Regression predicted probabilities
> polsreg<- predict(olsreg)
> summary(polsreg)
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.1557 0.3055 0.4074 0.3871 0.4736 1.1970
>
> # Logit model predicted probabilities
> plogit<- predict(logit, type="response")
> summary(plogit)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.03402 0.28490 0.39940 0.38710 0.47780 0.96500
>
> # Probit model predicted probabilities
> pprobit<- predict(probit, type="response")
> summary(pprobit)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.02064 0.28660 0.40170 0.38610 0.47680 0.96470
>
>
> # Percent correctly predicted values
> table(true = Y, pred = round(fitted(probit)))
pred
true 0 1
0 1660 305
1 906 335
> table(true = Y, pred = round(fitted(logit)))
pred
true 0 1
0 1657 308
1 896 345
>
> # McFadden's Pseudo R-squared
> probit0<-update(probit, formula= Y ~ 1)
> McFadden<- 1-as.vector(logLik(probit)/logLik(probit0))
> McFadden
[1] 0.06830054