Skip to contents

This function extracts the observations used in fixest estimation.

Usage

obs(x)

Arguments

x

A fixest object.

Value

It returns a simple vector of integers.

Examples


base = iris
names(base) = c("y", "x1", "x2", "x3", "species")
base$y[1:5] = NA

# Split sample estimations
est_split = feols(y ~ x1, base, split = ~species)
#> NOTE: 5 observations removed because of NA values (LHS: 5).
(obs_setosa = obs(est_split[[1]]))
#>  [1]  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#> [26] 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
(obs_versi = obs(est_split[sample = "versi", drop = TRUE]))
#>  [1]  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69
#> [20]  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88
#> [39]  89  90  91  92  93  94  95  96  97  98  99 100

est_versi = feols(y ~ x1, base, subset = obs_versi)

etable(est_split, est_versi)
#>                         est_split.1        est_split.2        est_split.3
#> Sample (species)             setosa         versicolor          virginica
#> Dependent Var.:                   y                  y                  y
#>                                                                          
#> Constant          2.642*** (0.3319)  3.540*** (0.5629)  3.907*** (0.7571)
#> x1               0.6909*** (0.0958) 0.8651*** (0.2019) 0.9015*** (0.2531)
#> ________________ __________________ __________________ __________________
#> S.E. type                       IID                IID                IID
#> Observations                     45                 50                 50
#> R2                          0.54767            0.27658            0.20906
#> Adj. R2                     0.53715            0.26151            0.19258
#> 
#>                           est_versi
#> Sample (species)                   
#> Dependent Var.:                   y
#>                                    
#> Constant          3.540*** (0.5629)
#> x1               0.8651*** (0.2019)
#> ________________ __________________
#> S.E. type                       IID
#> Observations                     50
#> R2                          0.27658
#> Adj. R2                     0.26151
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1