update.fixest: Updates a 'fixest' estimation

View source: R/methods.R

update.fixestR Documentation

Updates a fixest estimation

Description

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 = NULL,
  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 NULL (which means context-dependent). If TRUE then the evaluation of the call will be done within the environment that called the initial estimation. If FALSE, it will use the current environment. By default, i.e. when NULL, it is equal to FALSE if the argument data is provided and TRUE otherwise. 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 that 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).

Author(s)

Laurent Berge

See Also

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

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)


fixest documentation built on March 18, 2026, 9:06 a.m.