Computes various fit statistics for
fitstat(x, type, simplify = FALSE, verbose = TRUE, show_types = FALSE, ...)
Character vector or one sided formula. The type of fit statistic to be computed. The classic ones are: n, rmse, r2, pr2, f, wald, ivf, ivwald. You have the full list in the details section or use
Logical, default is
Logical, default is
Logical, default is
Other elements to be passed to other methods and may be used to compute the statistics (for example you can pass on arguments to compute the VCOV when using
By default an object of class
fixest_fitstat is returned. Using
verbose = FALSE returns a simple a list. Finally, if only one type is selected,
simplify = TRUE leads to the selected type to be returned.
You can register custom fit statistics with the function
The types are case sensitive, please use lower case only. The types available are:
rmse: The number of observations, the log-likelihood, the AIC, the BIC and the root mean squared error, respectively.
my: Mean of the dependent variable.
g: The degrees of freedom used to compute the t-test (it influences the p-values of the coefficients). When the VCOV is clustered, this value is equal to the minimum cluster size, otherwise, it is equal to the sample size minus the number of variables.
awpr2: All r2 that can be obtained with the function
a stands for 'adjusted', the
w for 'within' and the
p for 'pseudo'. Note that the order of the letters
p does not matter. The pseudo R2s are McFadden's R2s (ratios of log-likelihoods).
theta: The over-dispersion parameter in Negative Binomial models. Low values mean high overdispersion.
wf: The F-tests of nullity of the coefficients. The
w stands for 'within'. These types return the following values:
df2. If you want to display only one of these, use their name after a dot: e.g.
f.stat will give the statistic of the F-test, or
wf.p will give the p-values of the F-test on the projected model (i.e. projected onto the fixed-effects).
wald: Wald test of joint nullity of the coefficients. This test always excludes the intercept and the fixed-effects. These type returns the following values:
vcov. The element
vcov reports the way the VCOV matrix was computed since it directly influences this statistic.
ivfall: These statistics are specific to IV estimations. They report either the IV F-test (namely the Cragg-Donald F statistic in the presence of only one endogenous regressor) of the first stage (
ivf1), of the second stage (
ivf2) or of both (
ivfall). The F-test of the first stage is commonly named weak instrument test. The value of
ivfall is only useful in
etable when both the 1st and 2nd stages are displayed (it leads to the 1st stage F-test(s) to be displayed on the 1st stage estimation(s), and the 2nd stage one on the 2nd stage estimation – otherwise,
ivf1 would also be displayed on the 2nd stage estimation). These types return the following values:
ivwaldall: These statistics are specific to IV estimations. They report either the IV Wald-test of the first stage (
ivwald1), of the second stage (
ivwald2) or of both (
ivwaldall). The Wald-test of the first stage is commonly named weak instrument test. Note that if the estimation was done with a robust VCOV and there is only one endogenous regressor, this is equivalent to the Kleibergen-Paap statistic. The value of
ivwaldall is only useful in
etable when both the 1st and 2nd stages are displayed (it leads to the 1st stage Wald-test(s) to be displayed on the 1st stage estimation(s), and the 2nd stage one on the 2nd stage estimation – otherwise,
ivwald1 would also be displayed on the 2nd stage estimation). These types return the following values:
cd: The Cragg-Donald test for weak instruments.
kpr: The Kleibergen-Paap test for weak instruments.
wh: This statistic is specific to IV estimations. Wu-Hausman endogeneity test. H0 is the absence of endogeneity of the instrumented variables. It returns the following values:
sargan: Sargan test of overidentifying restrictions. H0: the instruments are not correlated with the second stage residuals. It returns the following values:
wlr: Likelihood ratio and within likelihood ratio tests. It returns the following elements:
df. Concerning the within-LR test, note that, contrary to estimations with
feNmlm, estimations with
fepois need to estimate the model with fixed-effects only which may prove time-consuming (depending on your model). Bottom line, if you really need the within-LR and estimate a Poisson model, use
femlm instead of
fepois (the former uses direct ML maximization for which the only FEs model is a by product).
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) # Some fit statistics fitstat(gravity, ~ rmse + r2 + wald + wf) # You can use them in etable etable(gravity, fitstat = ~ rmse + r2 + wald + wf) # For wald and wf, you could show the pvalue instead: etable(gravity, fitstat = ~ rmse + r2 + wald.p + wf.p) # 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"), "t-stat (regular)") fitstat_register("thc", function(x) tstat(x, se = "heter"), "t-stat (HC1)") fitstat_register("t1w", function(x) tstat(x, se = "clus"), "t-stat (clustered)") fitstat_register("t2w", function(x) tstat(x, se = "twow"), "t-stat (2-way)") # Now we can use these keywords in fitstat: etable(gravity, fitstat = ~ . + tstand + thc + t1w + t2w) # Note that the custom stats we created are can easily lead # to errors, but that's another story!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.