Skip to contents

Subsets a fixest_multi object using different keys.

Usage

# S3 method for fixest_multi
[(x, i, sample, lhs, rhs, fixef, iv, I, reorder = TRUE, drop = FALSE)

Arguments

x

A fixest_multi object, obtained from a fixest estimation leading to multiple results.

i

An integer vector. Represents the estimations to extract.

sample

An integer vector, a logical scalar, or a character vector. It represents the sample identifiers for which the results should be extracted. Only valid when the fixest estimation was a split sample. You can use .N to refer to the last element. If logical, all elements are selected in both cases, but FALSE leads sample to become the rightmost key (just try it out).

lhs

An integer vector, a logical scalar, or a character vector. It represents the left-hand-sides identifiers for which the results should be extracted. Only valid when the fixest estimation contained multiple left-hand-sides. You can use .N to refer to the last element. If logical, all elements are selected in both cases, but FALSE leads lhs to become the rightmost key (just try it out).

rhs

An integer vector or a logical scalar. It represents the right-hand-sides identifiers for which the results should be extracted. Only valid when the fixest estimation contained multiple right-hand-sides. You can use .N to refer to the last element. If logical, all elements are selected in both cases, but FALSE leads rhs to become the rightmost key (just try it out).

fixef

An integer vector or a logical scalar. It represents the fixed-effects identifiers for which the results should be extracted. Only valid when the fixest estimation contained fixed-effects in a stepwise fashion. You can use .N to refer to the last element. If logical, all elements are selected in both cases, but FALSE leads fixef to become the rightmost key (just try it out).

iv

An integer vector or a logical scalar. It represent the stages of the IV. Note that the length can be greater than 2 when there are multiple endogenous regressors (the first stage corresponding to multiple estimations). Note that the order of the stages depends on the stage argument from summary.fixest. If logical, all elements are selected in both cases, but FALSE leads iv to become the rightmost key (just try it out).

I

An integer vector. Represents the root element to extract.

reorder

Logical, default is TRUE. Indicates whether reordering of the results should be performed depending on the user input.

drop

Logical, default is FALSE. If the result contains only one estimation, then if drop = TRUE it will be transformed into a fixest object (instead of fixest_multi). Its default value can be modified with the function setFixest_multi.

Value

It returns a fixest_multi object. If there is only one estimation left in the object, then the result is simplified into a fixest object only with drop = TRUE.

Details

The order with we we use the keys matter. Every time a key sample, lhs, rhs, fixef or iv is used, a reordering is performed to consider the leftmost-side key to be the new root.

Use logical keys to easily reorder. For example, say the object res contains a multiple estimation with multiple left-hand-sides, right-hand-sides and fixed-effects. By default the results are ordered as follows: lhs, fixef, rhs. If you use res[lhs = FALSE], then the new order is: fixef, rhs, lhs. With res[rhs = TRUE, lhs = FALSE] it becomes: rhs, fixef, lhs. In both cases you keep all estimations.

See also

The main fixest estimation functions: feols, fepois, fenegbin, feglm, feNmlm. Tools for mutliple fixest estimations: summary.fixest_multi, print.fixest_multi, as.list.fixest_multi, sub-sub-.fixest_multi, sub-.fixest_multi.

Examples


# Estimation with multiple samples/LHS/RHS
aq = airquality[airquality$Month %in% 5:6, ]
est_split = feols(c(Ozone, Solar.R) ~ sw(poly(Wind, 2), poly(Temp, 2)),
                  aq, split = ~ Month)

# By default: sample is the root
etable(est_split)
#>                      est_split.1      est_split.2      est_split.3
#> Sample (Month)                 5                5                5
#> Dependent Var.:            Ozone            Ozone          Solar.R
#>                                                                   
#> Constant        26.06*** (4.090) 41.22*** (6.910) 182.7*** (23.38)
#> poly(Wind)1      -89.96* (35.56)                    -142.3 (205.4)
#> poly(Wind)2        66.46 (39.66)                    -177.1 (233.1)
#> poly(Temp)1                       215.9** (67.18)                 
#> poly(Temp)2                         92.23 (63.43)                 
#> _______________ ________________ ________________ ________________
#> S.E. type                    IID              IID              IID
#> Observations                  26               26               27
#> R2                       0.23366          0.36534          0.07374
#> Adj. R2                  0.16702          0.31015         -0.00345
#> 
#>                      est_split.4    est_split.5     est_split.6
#> Sample (Month)                 5              6               6
#> Dependent Var.:          Solar.R          Ozone           Ozone
#>                                                                
#> Constant        191.6*** (37.62) 25.43* (7.310) 30.73** (6.188)
#> poly(Wind)1                       91.24 (82.49)                
#> poly(Wind)2                      -43.18 (65.91)                
#> poly(Temp)1        124.1 (373.5)                 -6.996 (59.32)
#> poly(Temp)2       -484.8 (322.7)                 121.6* (47.13)
#> _______________ ________________ ______________ _______________
#> S.E. type                    IID            IID             IID
#> Observations                  27              9               9
#> R2                       0.27498        0.18587         0.73781
#> Adj. R2                  0.21456       -0.08550         0.65041
#> 
#>                      est_split.7      est_split.8
#> Sample (Month)                 6                6
#> Dependent Var.:          Solar.R          Solar.R
#>                                                  
#> Constant        196.5*** (16.70) 161.7*** (37.25)
#> poly(Wind)1       233.8. (129.0)                 
#> poly(Wind)2       -51.86 (111.4)                 
#> poly(Temp)1                         313.2 (344.5)
#> poly(Temp)2                         78.76 (214.4)
#> _______________ ________________ ________________
#> S.E. type                    IID              IID
#> Observations                  30               30
#> R2                       0.12942          0.16719
#> Adj. R2                  0.06493          0.10550
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# Let's reorder, by considering lhs the root
etable(est_split[lhs = 1:.N])
#>                 est_split[lhs..1 est_split[lhs..2 est_split[l..3
#> Sample (Month)                 5                5              6
#> Dependent Var.:            Ozone            Ozone          Ozone
#>                                                                 
#> Constant        26.06*** (4.090) 41.22*** (6.910) 25.43* (7.310)
#> poly(Wind)1      -89.96* (35.56)                   91.24 (82.49)
#> poly(Wind)2        66.46 (39.66)                  -43.18 (65.91)
#> poly(Temp)1                       215.9** (67.18)               
#> poly(Temp)2                         92.23 (63.43)               
#> _______________ ________________ ________________ ______________
#> S.E. type                    IID              IID            IID
#> Observations                  26               26              9
#> R2                       0.23366          0.36534        0.18587
#> Adj. R2                  0.16702          0.31015       -0.08550
#> 
#>                 est_split[lh..4 est_split[lhs..5 est_split[lhs..6
#> Sample (Month)                6                5                5
#> Dependent Var.:           Ozone          Solar.R          Solar.R
#>                                                                  
#> Constant        30.73** (6.188) 182.7*** (23.38) 191.6*** (37.62)
#> poly(Wind)1                       -142.3 (205.4)                 
#> poly(Wind)2                       -177.1 (233.1)                 
#> poly(Temp)1      -6.996 (59.32)                     124.1 (373.5)
#> poly(Temp)2      121.6* (47.13)                    -484.8 (322.7)
#> _______________ _______________ ________________ ________________
#> S.E. type                   IID              IID              IID
#> Observations                  9               27               27
#> R2                      0.73781          0.07374          0.27498
#> Adj. R2                 0.65041         -0.00345          0.21456
#> 
#>                 est_split[lhs..7 est_split[lhs..8
#> Sample (Month)                 6                6
#> Dependent Var.:          Solar.R          Solar.R
#>                                                  
#> Constant        196.5*** (16.70) 161.7*** (37.25)
#> poly(Wind)1       233.8. (129.0)                 
#> poly(Wind)2       -51.86 (111.4)                 
#> poly(Temp)1                         313.2 (344.5)
#> poly(Temp)2                         78.76 (214.4)
#> _______________ ________________ ________________
#> S.E. type                    IID              IID
#> Observations                  30               30
#> R2                       0.12942          0.16719
#> Adj. R2                  0.06493          0.10550
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# Selecting only one LHS and RHS
etable(est_split[lhs = "Ozone", rhs = 1])
#>                 est_split[lhs..1 est_split[l..2
#> Sample (Month)                 5              6
#> Dependent Var.:            Ozone          Ozone
#>                                                
#> Constant        26.06*** (4.090) 25.43* (7.310)
#> poly(Wind)1      -89.96* (35.56)  91.24 (82.49)
#> poly(Wind)2        66.46 (39.66) -43.18 (65.91)
#> _______________ ________________ ______________
#> S.E. type                    IID            IID
#> Observations                  26              9
#> R2                       0.23366        0.18587
#> Adj. R2                  0.16702       -0.08550
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# Taking the first root (here sample = 5)
etable(est_split[I = 1])
#>                 est_split[I =..1 est_split[I =..2 est_split[I =..3
#> Sample (Month)                 5                5                5
#> Dependent Var.:            Ozone            Ozone          Solar.R
#>                                                                   
#> Constant        26.06*** (4.090) 41.22*** (6.910) 182.7*** (23.38)
#> poly(Wind)1      -89.96* (35.56)                    -142.3 (205.4)
#> poly(Wind)2        66.46 (39.66)                    -177.1 (233.1)
#> poly(Temp)1                       215.9** (67.18)                 
#> poly(Temp)2                         92.23 (63.43)                 
#> _______________ ________________ ________________ ________________
#> S.E. type                    IID              IID              IID
#> Observations                  26               26               27
#> R2                       0.23366          0.36534          0.07374
#> Adj. R2                  0.16702          0.31015         -0.00345
#> 
#>                 est_split[I =..4
#> Sample (Month)                 5
#> Dependent Var.:          Solar.R
#>                                 
#> Constant        191.6*** (37.62)
#> poly(Wind)1                     
#> poly(Wind)2                     
#> poly(Temp)1        124.1 (373.5)
#> poly(Temp)2       -484.8 (322.7)
#> _______________ ________________
#> S.E. type                    IID
#> Observations                  27
#> R2                       0.27498
#> Adj. R2                  0.21456
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# The first and last estimations
etable(est_split[i = c(1, .N)])
#>                 est_split[i =..1 est_split[i =..2
#> Sample (Month)                 5                6
#> Dependent Var.:            Ozone          Solar.R
#>                                                  
#> Constant        26.06*** (4.090) 161.7*** (37.25)
#> poly(Wind)1      -89.96* (35.56)                 
#> poly(Wind)2        66.46 (39.66)                 
#> poly(Temp)1                         313.2 (344.5)
#> poly(Temp)2                         78.76 (214.4)
#> _______________ ________________ ________________
#> S.E. type                    IID              IID
#> Observations                  26               30
#> R2                       0.23366          0.16719
#> Adj. R2                  0.16702          0.10550
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1