Displays a brief summary of selected fit statistics from the function fitstat.
Usage
# S3 method for class 'fixest_fitstat'
print(x, na.rm = FALSE, ...)Arguments
- x
An object resulting from the
fitstatfunction.- na.rm
Logical, default is
FALSE. IfTRUE, the statistics that are missing are not displayed.- ...
Not currently used.
Examples
data(trade)
gravity = feols(log(Euros) ~ log(dist_km) | Destination + Origin, trade)
# Extracting the 'working' number of observations used to compute the pvalues
fitstat(gravity, "g", simplify = TRUE)
#> [1] 38295
# Some fit statistics
fitstat(gravity, ~ rmse + r2 + wald + wf)
#> RMSE: 2.26215
#> R2: 0.50428
#> Wald (joint nullity): stat = 5,832.8, p < 2.2e-16, on 1 and 38,295 DoF, VCOV: IID.
#> F-test (projected): stat = 5,832.8, p < 2.2e-16, on 1 and 38,295 DoF.
# This is a simple list:
names(fitstat(gravity, ~ rmse + r2 + wald + wf))
#> [1] "rmse" "r2" "wald" "wf"
# You can use them in etable
etable(gravity, fitstat = ~ rmse + r2 + wald + wf)
#> gravity
#> Dependent Var.: log(Euros)
#>
#> log(dist_km) -2.072*** (0.0271)
#> Fixed-Effects: ------------------
#> Destination Yes
#> Origin Yes
#> ____________________ __________________
#> S.E. type IID
#> RMSE 2.2622
#> R2 0.50428
#> Wald (joint nullity) 5,832.8
#> F-test (projected) 5,832.8
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# For wald and wf, you could show the pvalue instead:
etable(gravity, fitstat = ~ rmse + r2 + wald.p + wf.p)
#> gravity
#> Dependent Var.: log(Euros)
#>
#> log(dist_km) -2.072*** (0.0271)
#> Fixed-Effects: ------------------
#> Destination Yes
#> Origin Yes
#> _____________________________ __________________
#> S.E. type IID
#> RMSE 2.2622
#> R2 0.50428
#> Wald (joint nullity), p-value 0e-16
#> F-test (projected), p-value 0e-16
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# You can display the tests with the htest format with htest=TRUE
fitstat(gravity, ~ rmse + r2 + wald + wf, htest = TRUE)
#> $rmse
#> [1] 2.26215
#>
#> $r2
#> r2
#> 0.5042796
#>
#> $wald
#>
#> Wald (joint nullity)
#>
#> data: feols(fml = log(Euros) ~ log(dist_km) | Destination + Origin, data = trade)
#> statistic = 5832.8, df1 = 1, df2 = 38295, vcov = IID, p-value < 2.2e-16
#> alternative hypothesis: At least one non fixed-effect coefficient is different from 0
#>
#>
#> $wf
#>
#> F-test (projected)
#>
#> data: feols(fml = log(Euros) ~ log(dist_km) | Destination + Origin, data = trade)
#> statistic = 5832.8, df1 = 1, df2 = 38295, p-value < 2.2e-16
#> alternative hypothesis: At least one non fixed-effect coefficient is different from 0
#>
#>
# Now let's display some statistics that are not built-in
# => we use fitstat_register to create them
# We need: a) type name, b) the function to be applied
# c) (optional) an alias
fitstat_register("tstand", function(x) tstat(x, se = "stand")[1], "t-stat (regular)")
fitstat_register("thc", function(x) tstat(x, se = "heter")[1], "t-stat (HC1)")
fitstat_register("t1w", function(x) tstat(x, se = "clus")[1], "t-stat (clustered)")
fitstat_register("t2w", function(x) tstat(x, se = "twow")[1], "t-stat (2-way)")
# Now we can use these keywords in fitstat:
etable(gravity, fitstat = ~ . + tstand + thc + t1w + t2w)
#> gravity
#> Dependent Var.: log(Euros)
#>
#> log(dist_km) -2.072*** (0.0271)
#> Fixed-Effects: ------------------
#> Destination Yes
#> Origin Yes
#> __________________ __________________
#> S.E. type IID
#> Observations 38,325
#> R2 0.50428
#> Within R2 0.13218
#> t-stat (regular) -76.373
#> t-stat (HC1) -80.129
#> t-stat (clustered) -16.520
#> t-stat (2-way) -13.268
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1