Skip to contents

Otabin the number of unique models of a fixest_multi object, depending on the type requested.

Usage

n_models(
  x,
  lhs = FALSE,
  rhs = FALSE,
  sample = FALSE,
  fixef = FALSE,
  iv = FALSE
)

Arguments

x

A fixest_mutli object, obtained e.g. from feols.

lhs

Logical scalar, default is FALSE. If TRUE, the number of different left hand sides is returned.

rhs

Logical scalar, default is FALSE. If TRUE, the number of different right hand sides is returned.

sample

Logical scalar, default is FALSE. If TRUE, the number of different samples is returned.

fixef

Logical scalar, default is FALSE. If TRUE, the number of different types of fixed-effects is returned.

iv

Logical scalar, default is FALSE. If TRUE, the number of different IV stages is returned.

Value

It returns an integer scalar. If no argument is provided, the total number of models is returned.

See also

Multiple estimations in feols, models

Examples


base = setNames(iris, c("y", "x1", "x2", "x3", "species"))
est = feols(y ~ csw(x1, x2, x3), base, fsplit = ~species)

# there are 3 different RHSs and 4 different samples
models(est)
#>    id sample.var      sample          rhs
#> 1   1    species Full sample           x1
#> 2   2    species Full sample      x1 + x2
#> 3   3    species Full sample x1 + x2 + x3
#> 4   4    species      setosa           x1
#> 5   5    species      setosa      x1 + x2
#> 6   6    species      setosa x1 + x2 + x3
#> 7   7    species  versicolor           x1
#> 8   8    species  versicolor      x1 + x2
#> 9   9    species  versicolor x1 + x2 + x3
#> 10 10    species   virginica           x1
#> 11 11    species   virginica      x1 + x2
#> 12 12    species   virginica x1 + x2 + x3

# We can obtain these numbers with n_models
n_models(est, rhs = TRUE)
#> [1] 3
n_models(est, sample = TRUE)
#> [1] 4