ycroissant / plm

Panel Data Econometrics with R
GNU General Public License v2.0
49 stars 13 forks source link

fd model does not report F-Statistic #47

Closed luisvalenzuelar closed 1 year ago

luisvalenzuelar commented 1 year ago

Other models do report the F-Statistic at the end. Apparently, it was reported before (here is a post from 2020). The news file does not seem to show a change on this regard. A MRE below

data("Wages", package = "plm")
df <- pdata.frame(Wages, index=595)
fd <- plm(data=df,lwage ~ ed + exp,model = "fd",effect = "individual")
summary(fd)
tappek commented 1 year ago

I am afraid, I cannot quite follow. The post you link has an example of a panel FD model estimated by plm which gives the F-statistic for the joint significance of non-intercept regressors (Wald test) at the end of the printed summary's output:

"## F-statistic: 10.6018 on 2 and 698 DF, p-value: 2.9123e-05"

The minimum reproducible example you give estimates an intercept-only model (ed is constant within observerational units and exp gets differenced to all zeros, thus leaving only the intercept). This is why there is no such thing as a Wald test is printed. You can also check via pwaldtest(fd) for your example which gives the error message "Error in pwaldtest.plm(fd) : No non-intercept regressors in input model 'x', cannot perform Wald joint significance test".

When you estimate a model with more than just an intercept, the F test is given, see my example below.

I am not sure if I missed anything - could you kindly elaborate?

Your example's printed summery output is:

> summary(fd)
Oneway (individual) effect First-Difference Model

Call:
plm(formula = lwage ~ ed + exp, data = df, effect = "individual", 
    model = "fd")

Balanced Panel: n = 595, T = 7, N = 4165
Observations used in estimation: 3570

Residuals:
     Min.   1st Qu.    Median   3rd Qu.      Max. 
-2.098409 -0.065159 -0.010259  0.049239  2.345911 

Coefficients:
            Estimate Std. Error t-value              Pr(>|t|)    
(Intercept) 0.095928   0.003044  31.514 < 0.00000000000000022 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Total Sum of Squares:    118.06
Residual Sum of Squares: 118.06
R-Squared:      -0.27826
Adj. R-Squared: -0.27826

Example of a panel FD model with intercept and coefficients:

library(plm)
data("Produc", package = "plm")
zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
          data = Produc, index = c("state","year"), model = "fd")
summary(zz)
#> Oneway (individual) effect First-Difference Model
#> 
#> Call:
#> plm(formula = log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, 
#>     data = Produc, model = "fd", index = c("state", "year"))
#> 
#> Balanced Panel: n = 48, T = 17, N = 816
#> Observations used in estimation: 768
#> 
#> Residuals:
#>       Min.    1st Qu.     Median    3rd Qu.       Max. 
#> -0.0852334 -0.0108348  0.0016016  0.0126813  0.1024759 
#> 
#> Coefficients:
#>                Estimate  Std. Error t-value  Pr(>|t|)    
#> (Intercept)  0.01068526  0.00137639  7.7633 2.663e-14 ***
#> log(pcap)   -0.00660507  0.04593751 -0.1438    0.8857    
#> log(pc)     -0.03243575  0.02305050 -1.4072    0.1598    
#> log(emp)     0.83147269  0.03696857 22.4913 < 2.2e-16 ***
#> unemp       -0.00598593  0.00076141 -7.8616 1.293e-14 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Total Sum of Squares:    1.0802
#> Residual Sum of Squares: 0.33308
#> R-Squared:      0.69166
#> Adj. R-Squared: 0.69004
#> F-statistic: 427.885 on 4 and 763 DF, p-value: < 2.22e-16
luisvalenzuelar commented 1 year ago

You are right. Problem was data structure. My apologies.