Also available in Stata and Python versions
Load libraries
library(wooldridge)
library(AER)
library(systemfit)
library(plm)
library(plyr)
SUR System for Wages and Fringe Benefits
system <- list(
Wage = hrearn ~ educ + exper + expersq + tenure + tenuresq + union + south + nrtheast + nrthcen + married + white + male,
Benefit = hrbens ~ educ + exper + expersq + tenure + tenuresq + union + south + nrtheast + nrthcen + married + white + male
)
ols <- systemfit(system, method = "OLS", data=fringe)
summary(ols)
##
## systemfit results
## method: OLS
##
## N DF SSR detRCov OLS-R2 McElroy-R2
## system 1232 1206 11600.6 4.63027 0.208685 0.292642
##
## N DF SSR MSE RMSE R2 Adj R2
## Wage 616 603 11437.037 18.966893 4.355100 0.205093 0.189274
## Benefit 616 603 163.544 0.271217 0.520785 0.398674 0.386708
##
## The covariance matrix of the residuals
## Wage Benefit
## Wage 18.966893 0.716847
## Benefit 0.716847 0.271217
##
## The correlations of the residuals
## Wage Benefit
## Wage 1.00000 0.31606
## Benefit 0.31606 1.00000
##
##
## OLS estimates for 'Wage' (equation 1)
## Model Formula: hrearn ~ educ + exper + expersq + tenure + tenuresq + union +
## south + nrtheast + nrthcen + married + white + male
##
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.63212671 1.22832151 -2.14286 0.0325236 *
## educ 0.45881395 0.06912628 6.63733 7.1256e-11 ***
## exper -0.07584282 0.05734542 -1.32256 0.1864828
## expersq 0.00399449 0.00117795 3.39104 0.0007418 ***
## tenure 0.11008462 0.08380979 1.31351 0.1895122
## tenuresq -0.00507064 0.00327692 -1.54738 0.1222965
## union 0.80799328 0.40780495 1.98132 0.0480089 *
## south -0.45662223 0.55170344 -0.82766 0.4081912
## nrtheast -1.15075861 0.60575425 -1.89971 0.0579478 .
## nrthcen -0.63626628 0.55604484 -1.14427 0.2529651
## married 0.64238821 0.41779850 1.53756 0.1246820
## white 1.14089121 0.61193899 1.86439 0.0627530 .
## male 1.78470236 0.39800745 4.48409 8.7674e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.3551 on 603 degrees of freedom
## Number of observations: 616 Degrees of Freedom: 603
## SSR: 11437.036645 MSE: 18.966893 Root MSE: 4.3551
## Multiple R-Squared: 0.205093 Adjusted R-Squared: 0.189274
##
##
## OLS estimates for 'Benefit' (equation 2)
## Model Formula: hrbens ~ educ + exper + expersq + tenure + tenuresq + union +
## south + nrtheast + nrthcen + married + white + male
##
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.889747099 0.146883282 -6.05751 2.4342e-09 ***
## educ 0.076792360 0.008266154 9.28997 < 2.22e-16 ***
## exper 0.022564931 0.006857393 3.29060 0.0010581 **
## expersq -0.000473359 0.000140860 -3.36049 0.0008272 ***
## tenure 0.053555571 0.010022015 5.34379 1.2924e-07 ***
## tenuresq -0.001163631 0.000391856 -2.96954 0.0031010 **
## union 0.365908540 0.048765513 7.50343 2.2404e-13 ***
## south -0.022686547 0.065972964 -0.34388 0.7310591
## nrtheast -0.056746823 0.072436387 -0.78340 0.4336986
## nrthcen -0.037998394 0.066492111 -0.57147 0.5678925
## married 0.057862604 0.049960547 1.15817 0.2472548
## white 0.090158182 0.073175962 1.23207 0.2184017
## male 0.268338264 0.047593923 5.63808 2.6438e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.520785 on 603 degrees of freedom
## Number of observations: 616 Degrees of Freedom: 603
## SSR: 163.543819 MSE: 0.271217 Root MSE: 0.520785
## Multiple R-Squared: 0.398674 Adjusted R-Squared: 0.386708
Effects of Job Training Grants on Firm Scrap Rates
summary(lm(lscrap ~ d88 + d89 + grant + grant_1, data=jtrain))
##
## Call:
## lm(formula = lscrap ~ d88 + d89 + grant + grant_1, data = jtrain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.2026 -0.8960 -0.0846 1.0242 3.3003
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.59743 0.20306 2.942 0.00375 **
## d88 -0.23937 0.31086 -0.770 0.44245
## d89 -0.49652 0.33793 -1.469 0.14375
## grant 0.20002 0.33828 0.591 0.55519
## grant_1 0.04894 0.43607 0.112 0.91079
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.492 on 157 degrees of freedom
## (309 observations deleted due to missingness)
## Multiple R-squared: 0.01731, Adjusted R-squared: -0.007726
## F-statistic: 0.6914 on 4 and 157 DF, p-value: 0.5989
Effect of Being in Season on Grade Point Average
summary(lm(trmgpa ~ spring + cumgpa + crsgpa + frstsem + season + sat + verbmath + hsperc + hssize + black + female, data=gpa3))
##
## Call:
## lm(formula = trmgpa ~ spring + cumgpa + crsgpa + frstsem + season +
## sat + verbmath + hsperc + hssize + black + female, data = gpa3)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.90608 -0.28531 -0.00412 0.35062 1.56491
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.068e+00 3.381e-01 -6.115 1.58e-09 ***
## spring -1.216e-02 4.648e-02 -0.262 0.794
## cumgpa 3.146e-01 4.049e-02 7.770 2.71e-14 ***
## crsgpa 9.840e-01 9.603e-02 10.247 < 2e-16 ***
## frstsem 7.691e-01 1.204e-01 6.387 3.03e-10 ***
## season -4.626e-02 4.710e-02 -0.982 0.326
## sat 1.410e-03 1.464e-04 9.628 < 2e-16 ***
## verbmath -1.126e-01 1.306e-01 -0.862 0.389
## hsperc -6.601e-03 1.020e-03 -6.475 1.75e-10 ***
## hssize -5.761e-05 9.937e-05 -0.580 0.562
## black -2.313e-01 5.433e-02 -4.257 2.35e-05 ***
## female 2.856e-01 5.096e-02 5.603 3.00e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5299 on 720 degrees of freedom
## Multiple R-squared: 0.5191, Adjusted R-squared: 0.5117
## F-statistic: 70.64 on 11 and 720 DF, p-value: < 2.2e-16
gpa3p <- pdata.frame(gpa3, index = c("id", "term"))
summary(pggls(trmgpa ~ spring + cumgpa + crsgpa + frstsem + season + sat + verbmath + hsperc + hssize + black + female, data=gpa3p, model = "pooling"))
## Oneway (individual) effect General FGLS model
##
## Call:
## pggls(formula = trmgpa ~ spring + cumgpa + crsgpa + frstsem +
## season + sat + verbmath + hsperc + hssize + black + female,
## data = gpa3p, model = "pooling")
##
## Balanced Panel: n = 366, T = 2, N = 732
##
## Residuals:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -1.874434 -0.306303 -0.005001 0.000000 0.348366 1.545998
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) -2.0339e+00 3.4208e-01 -5.9457 2.753e-09 ***
## spring -2.9597e-02 4.1460e-02 -0.7139 0.4753
## cumgpa 2.3011e-01 4.0154e-02 5.7308 9.995e-09 ***
## crsgpa 1.0282e+00 9.3076e-02 11.0465 < 2.2e-16 ***
## frstsem 5.5750e-01 1.1799e-01 4.7250 2.302e-06 ***
## season -5.0952e-02 4.2074e-02 -1.2110 0.2259
## sat 1.5020e-03 1.5893e-04 9.4505 < 2.2e-16 ***
## verbmath -1.2838e-01 1.4278e-01 -0.8991 0.3686
## hsperc -6.9640e-03 1.1140e-03 -6.2515 4.065e-10 ***
## hssize -6.6763e-05 1.0880e-04 -0.6136 0.5395
## black -2.3395e-01 5.9432e-02 -3.9365 8.268e-05 ***
## female 3.1014e-01 5.5123e-02 5.6264 1.840e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Total Sum of Squares: 420.3
## Residual Sum of Squares: 203.41
## Multiple R-squared: 0.51603
Athletes’ Grade Point Averages, continued
#library(plyr)
gpa3['uhat'] <- resid(lm(trmgpa ~ spring + cumgpa + crsgpa + frstsem + season + sat + verbmath + hsperc + hssize + black + female, data=gpa3))
gpa3b <- ddply(
gpa3, .(id), transform,
uhat_1 = c(NA, uhat[-length(uhat)])
)
summary(lm(trmgpa ~ cumgpa + crsgpa + season + sat + verbmath + hsperc + hssize + black + female + uhat_1, data=gpa3b))
##
## Call:
## lm(formula = trmgpa ~ cumgpa + crsgpa + season + sat + verbmath +
## hsperc + hssize + black + female + uhat_1, data = gpa3b)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.14097 -0.25914 0.01412 0.31478 1.19124
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.266e+00 4.247e-01 -5.337 1.69e-07 ***
## cumgpa 3.489e-01 7.203e-02 4.843 1.91e-06 ***
## crsgpa 1.001e+00 1.177e-01 8.503 5.21e-16 ***
## season -2.710e-02 5.795e-02 -0.468 0.640291
## sat 1.413e-03 1.991e-04 7.094 7.10e-12 ***
## verbmath -1.137e-01 1.703e-01 -0.668 0.504854
## hsperc -4.954e-03 1.417e-03 -3.495 0.000535 ***
## hssize -8.435e-05 1.289e-04 -0.655 0.513191
## black -2.407e-01 7.068e-02 -3.406 0.000734 ***
## female 2.919e-01 7.326e-02 3.985 8.20e-05 ***
## uhat_1 1.942e-01 6.121e-02 3.173 0.001642 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4854 on 355 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.6155, Adjusted R-squared: 0.6047
## F-statistic: 56.83 on 10 and 355 DF, p-value: < 2.2e-16
summary(lm(uhat ~ uhat_1, data=gpa3b))
##
## Call:
## lm(formula = uhat ~ uhat_1, data = gpa3b)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.09519 -0.26626 0.01715 0.30685 1.15824
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.913e-17 2.512e-02 0.000 1
## uhat_1 2.122e-01 4.520e-02 4.695 3.79e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4805 on 364 degrees of freedom
## (366 observations deleted due to missingness)
## Multiple R-squared: 0.05709, Adjusted R-squared: 0.0545
## F-statistic: 22.04 on 1 and 364 DF, p-value: 3.788e-06