İleri Panel Veri Yöntemleri

library(wooldridge)
## Warning: package 'wooldridge' was built under R version 4.1.3
library(plm)
## Warning: package 'plm' was built under R version 4.1.3
data("Males")
head(Males, 10)
##    nr year school exper union  ethn married health       wage
## 1  13 1980     14     1    no other      no     no  1.1975402
## 2  13 1981     14     2   yes other      no     no  1.8530600
## 3  13 1982     14     3    no other      no     no  1.3444617
## 4  13 1983     14     4    no other      no     no  1.4332133
## 5  13 1984     14     5    no other      no     no  1.5681251
## 6  13 1985     14     6    no other      no     no  1.6998909
## 7  13 1986     14     7    no other      no     no -0.7202626
## 8  13 1987     14     8    no other      no     no  1.6691879
## 9  17 1980     13     4    no other      no     no  1.6759624
## 10 17 1981     13     5    no other      no     no  1.5183982
##                       industry                          occupation  residence
## 1  Business_and_Repair_Service                     Service_Workers north_east
## 2             Personal_Service                     Service_Workers north_east
## 3  Business_and_Repair_Service                     Service_Workers north_east
## 4  Business_and_Repair_Service                     Service_Workers north_east
## 5             Personal_Service      Craftsmen, Foremen_and_kindred north_east
## 6  Business_and_Repair_Service Managers, Officials_and_Proprietors north_east
## 7  Business_and_Repair_Service Managers, Officials_and_Proprietors north_east
## 8  Business_and_Repair_Service Managers, Officials_and_Proprietors north_east
## 9                        Trade Managers, Officials_and_Proprietors north_east
## 10                       Trade Managers, Officials_and_Proprietors north_east
tail(Males,10)
##         nr year school exper union  ethn married health      wage
## 4351 12534 1986     11     8    no other     yes     no 2.3818830
## 4352 12534 1987     11     9    no other     yes     no 2.3429170
## 4353 12548 1980      9     5    no other      no     no 1.1305453
## 4354 12548 1981      9     6    no other      no     no 1.3116035
## 4355 12548 1982      9     7    no other      no     no 0.8324815
## 4356 12548 1983      9     8    no other     yes     no 1.5918787
## 4357 12548 1984      9     9   yes other     yes     no 1.2125428
## 4358 12548 1985      9    10    no other     yes     no 1.7659618
## 4359 12548 1986      9    11   yes other     yes     no 1.7458942
## 4360 12548 1987      9    12   yes other     yes     no 1.4665429
##                              industry                     occupation residence
## 4351                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4352                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4353                     Construction           Laborers_and_farmers      <NA>
## 4354                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4355                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4356                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4357                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4358                     Construction Craftsmen, Foremen_and_kindred      <NA>
## 4359 Professional_and_Related Service Craftsmen, Foremen_and_kindred      <NA>
## 4360            Public_Administration Craftsmen, Foremen_and_kindred      <NA>
benimmodel <- pdata.frame(Males, index = c("nr", "year"))
pdim(benimmodel)
## Balanced Panel: n = 545, T = 8, N = 4360

Plm Modeli

yenimodel <- plm(wage ~ union + married + health + factor(year), data= benimmodel, model = "within")
summary(yenimodel)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = wage ~ union + married + health + factor(year), 
##     data = benimmodel, model = "within")
## 
## Balanced Panel: n = 545, T = 8, N = 4360
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -4.15342 -0.12631  0.01106  0.16249  1.48268 
## 
## Coefficients:
##                   Estimate Std. Error t-value  Pr(>|t|)    
## unionyes          0.083194   0.019446  4.2781 1.931e-05 ***
## marriedyes        0.058135   0.018378  3.1633  0.001572 ** 
## healthyes        -0.019011   0.047515 -0.4001  0.689111    
## factor(year)1981  0.113534   0.021496  5.2817 1.352e-07 ***
## factor(year)1982  0.167635   0.021646  7.7444 1.223e-14 ***
## factor(year)1983  0.210851   0.021951  9.6057 < 2.2e-16 ***
## factor(year)1984  0.278506   0.022185 12.5537 < 2.2e-16 ***
## factor(year)1985  0.327320   0.022403 14.6107 < 2.2e-16 ***
## factor(year)1986  0.386705   0.022607 17.1058 < 2.2e-16 ***
## factor(year)1987  0.446951   0.022819 19.5866 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    572.05
## Residual Sum of Squares: 475.41
## R-Squared:      0.16894
## Adj. R-Squared: 0.047943
## F-statistic: 77.3507 on 10 and 3805 DF, p-value: < 2.22e-16
pvar(benimmodel)
## no time variation:       nr school ethn 
## no individual variation: year
reg_ols <- plm(wage ~ union + married + health + exper + I(exper^2)+ factor(year), data= benimmodel, model = "pooling")
reg_random <- plm(wage ~ union + married + health + exper + I(exper^2)+ factor(year), data= benimmodel, model = "random")
reg_fe <- plm(wage ~ union + married + health + exper + I(exper^2)+ factor(year), data= benimmodel, model = "within")
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
stargazer(reg_ols, reg_random, reg_fe, type = "text", column.labels = c("pooling, random, within"))
## 
## ===============================================================================
##                                       Dependent variable:                      
##                  --------------------------------------------------------------
##                                               wage                             
##                   pooling, random, within                                      
##                             (1)               (2)                (3)           
## -------------------------------------------------------------------------------
## unionyes                 0.173***           0.101***          0.080***         
##                           (0.018)           (0.018)            (0.019)         
##                                                                                
## marriedyes               0.149***           0.072***           0.047**         
##                           (0.016)           (0.017)            (0.018)         
##                                                                                
## healthyes                 -0.064             -0.023            -0.017          
##                           (0.059)           (0.047)            (0.047)         
##                                                                                
## exper                     0.030**           0.052***          0.132***         
##                           (0.014)           (0.015)            (0.010)         
##                                                                                
## I(exper2)                -0.004***         -0.005***          -0.005***        
##                           (0.001)           (0.001)            (0.001)         
##                                                                                
## factor(year)1981         0.101***           0.095***            0.019          
##                           (0.031)           (0.024)            (0.020)         
##                                                                                
## factor(year)1982         0.152***           0.142***           -0.011          
##                           (0.034)           (0.031)            (0.020)         
##                                                                                
## factor(year)1983         0.200***           0.187***          -0.042**         
##                           (0.037)           (0.039)            (0.020)         
##                                                                                
## factor(year)1984         0.282***           0.267***           -0.038*         
##                           (0.040)           (0.047)            (0.020)         
##                                                                                
## factor(year)1985         0.356***           0.339***          -0.043**         
##                           (0.043)           (0.055)            (0.020)         
##                                                                                
## factor(year)1986         0.448***           0.431***           -0.027          
##                           (0.045)           (0.064)            (0.020)         
##                                                                                
## factor(year)1987         0.542***           0.532***                           
##                           (0.047)           (0.072)                            
##                                                                                
## Constant                 1.279***           1.258***                           
##                           (0.039)           (0.044)                            
##                                                                                
## -------------------------------------------------------------------------------
## Observations               4,360             4,360              4,360          
## R2                         0.126             0.167              0.181          
## Adjusted R2                0.123             0.164              0.061          
## F Statistic      52.104*** (df = 12; 4347) 868.961*** 76.223*** (df = 11; 3804)
## ===============================================================================
## Note:                                               *p<0.1; **p<0.05; ***p<0.01
phtest(reg_fe, reg_random)
## 
##  Hausman Test
## 
## data:  wage ~ union + married + health + exper + I(exper^2) + factor(year)
## chisq = 36.093, df = 11, p-value = 0.0001633
## alternative hypothesis: one model is inconsistent

p değeri 0.0001633 olduğu için anlamlı, reddedilir.

lmmodel <- lm(wage ~ union + married + health + year, data= benimmodel)
summary(lmmodel)
## 
## Call:
## lm(formula = wage ~ union + married + health + year, data = benimmodel)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.1556 -0.2772  0.0240  0.3105  2.4280 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.32452    0.02218  59.708  < 2e-16 ***
## unionyes     0.17541    0.01775   9.884  < 2e-16 ***
## marriedyes   0.14226    0.01599   8.895  < 2e-16 ***
## healthyes   -0.06803    0.05894  -1.154 0.248485    
## year1981     0.10497    0.03046   3.447 0.000573 ***
## year1982     0.15244    0.03054   4.992 6.21e-07 ***
## year1983     0.18893    0.03070   6.153 8.28e-10 ***
## year1984     0.25205    0.03083   8.176 3.82e-16 ***
## year1985     0.29937    0.03095   9.671  < 2e-16 ***
## year1986     0.35710    0.03107  11.495  < 2e-16 ***
## year1987     0.40937    0.03118  13.129  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.502 on 4349 degrees of freedom
## Multiple R-squared:  0.1136, Adjusted R-squared:  0.1115 
## F-statistic: 55.71 on 10 and 4349 DF,  p-value: < 2.2e-16