Skip to contents

Updates and re-estimates a fixest model (estimated with femlm, feols or feglm). This function updates the formulas and use previous starting values to estimate a new fixest model. The data is obtained from the original call.

Usage

# S3 method for class 'fixest'
update(
  object,
  fml.update = NULL,
  fml = NULL,
  nframes = 1,
  use_calling_env = TRUE,
  evaluate = TRUE,
  ...
)

# S3 method for class 'fixest_multi'
update(
  object,
  fml.update = NULL,
  fml = NULL,
  nframes = 1,
  use_calling_env = TRUE,
  evaluate = TRUE,
  ...
)

Arguments

object

A fixest or fixest_multi object. These are obtained from feols, or feglm estimations, for example.

fml.update

A formula representing the changes to be made to the original formula. By default it is NULL. Use a dot to refer to the previous variables in the current part. For example: . ~ . + xnew will add the variable xnew as an explanatory variable. Note that the previous fixed-effects (FEs) and IVs are implicitly forwarded. To rerun without the FEs or the IVs, you need to set them to 0 in their respective slot. Ex, assume the original formula is: y ~ x | fe | endo ~ inst, passing . ~ . + xnew to fml.update leads to y ~ x + xnew | fe | endo ~ inst (FEs and IVs are forwarded). To add xnew and remove the IV part: use . ~ . + xnew | . | 0 which leads to y ~ x + xnew | fe.

fml

A formula, default is NULL. If provided, it will completely override the value in fml.update, which will be ignored. Note that this formula will be used for the new estimation, without any modification.

nframes

(Advanced users.) Defaults to 1. Only used if the argument use_calling_env is FALSE. Number of frames up the stack where to perform the evaluation of the updated call. By default, this is the parent frame.

use_calling_env

Logical scalar, default is TRUE. If TRUE then the evaluation of the call will be done within the environment that called the initial estimation. This is mostly useful when the fixest object has been created through a custom function, so that the new evaluation can use the variables within the enclosure of the function.

evaluate

Logical, default is TRUE. If FALSE, only the updated call is returned.

...

Other arguments to be passed to the functions femlm, feols or feglm.

Value

It returns a fixest object (see details in femlm, feols or feglm).

See also

See also the main estimation functions femlm, feols or feglm. predict.fixest, summary.fixest, vcov.fixest, fixef.fixest.

Author

Laurent Berge

Examples


# Example using trade data
data(trade)

# main estimation
est_pois = fepois(Euros ~ log(dist_km) | Origin + Destination, trade)

# we add the variable log(Year)
est_2 = update(est_pois, . ~ . + log(Year))

# we add another fixed-effect: "Product"
est_3 = update(est_2, . ~ . | . + Product)

# we remove the fixed-effect "Origin" and the variable log(dist_km)
est_4 = update(est_3, . ~ . - log(dist_km) | . - Origin)

# Quick look at the 4 estimations
etable(est_pois, est_2, est_3, est_4)
#>                           est_pois              est_2              est_3
#> Dependent Var.:              Euros              Euros              Euros
#>                                                                         
#> log(dist_km)    -1.517*** (0.1131) -1.518*** (0.1132) -1.528*** (0.1157)
#> log(Year)                            72.37*** (6.900)   72.62*** (6.983)
#> Fixed-Effects:  ------------------ ------------------ ------------------
#> Origin                         Yes                Yes                Yes
#> Destination                    Yes                Yes                Yes
#> Product                         No                 No                Yes
#> _______________ __________________ __________________ __________________
#> S.E.: Clustered         by: Origin         by: Origin         by: Origin
#> Observations                38,325             38,325             38,325
#> Squared Cor.               0.37832            0.38444            0.61155
#> Pseudo R2                  0.58950            0.59290            0.76381
#> BIC                       2.44e+12           2.42e+12           1.41e+12
#> 
#>                            est_4
#> Dependent Var.:            Euros
#>                                 
#> log(dist_km)                    
#> log(Year)       70.82*** (5.989)
#> Fixed-Effects:  ----------------
#> Origin                        No
#> Destination                  Yes
#> Product                      Yes
#> _______________ ________________
#> S.E.: Clustered  by: Destination
#> Observations              38,325
#> Squared Cor.             0.17893
#> Pseudo R2                0.35377
#> BIC                     3.85e+12
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1