Skip to contents

Sets/gets the default dictionary used in the function etable, did_means and coefplot. The dictionaries are used to relabel variables (usually towards a fancier, more explicit formatting) when exporting them into a Latex table or displaying in graphs. By setting the dictionary with setFixest_dict, you can avoid providing the argument dict.

Usage

setFixest_dict(dict = NULL, ..., reset = FALSE)

getFixest_dict()

Arguments

dict

A named character vector or a character scalar. E.g. to change my variable named "a" and "b" to (resp.) "$log(a)$" and "$bonus^3$", then use dict = c(a="$log(a)$", b3="$bonus^3$"). Alternatively you can feed a character scalar containing the dictionary in the form "variable 1: definition \n variable 2: definition". In that case the function as.dict will be applied to get a proper dictionary. This dictionary is used in Latex tables or in graphs by the function coefplot. If you want to separate Latex rendering from rendering in graphs, use an ampersand first to make the variable specific to coefplot.

...

You can add arguments of the form: variable_name = "Definition". This is an alternative to using a named vector in the argument dict.

reset

Logical, default is FALSE. If TRUE, then the dictionary is reset. Note that the default dictionary always relabels the variable "(Intercept)" in to "Constant". To overwrite it, you need to add "(Intercept)" explicitly in your dictionary.

Details

By default the dictionary only grows. This means that successive calls with not erase the previous definitions unless the argument reset has been set to TRUE.

The default dictionary is equivalent to having setFixest_dict("(Intercept)" = "Constant"). To change this default, you need to provide a new definition to "(Intercept)" explicitly.

Author

Laurent Berge

Examples


data(trade)
est = feols(log(Euros) ~ log(dist_km)|Origin+Destination+Product, trade)
# we export the result & rename some variables
etable(est, dict = c("log(Euros)"="Euros (ln)", Origin="Country of Origin"))
#>                                  est
#> Dependent Var.:           Euros (ln)
#>                                     
#> log(dist_km)      -2.169*** (0.1542)
#> Fixed-Effects:    ------------------
#> Country of Origin                Yes
#> Destination                      Yes
#> Product                          Yes
#> _________________ __________________
#> S.E.: Clustered   by: Country of O..
#> Observations                  38,325
#> R2                           0.70402
#> Within R2                    0.21827
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# If you export many tables, it can be more convenient to use setFixest_dict:
setFixest_dict(c("log(Euros)"="Euros (ln)", Origin="Country of Origin"))
etable(est) # variables are properly relabeled
#>                                  est
#> Dependent Var.:           Euros (ln)
#>                                     
#> log(dist_km)      -2.169*** (0.1542)
#> Fixed-Effects:    ------------------
#> Country of Origin                Yes
#> Destination                      Yes
#> Product                          Yes
#> _________________ __________________
#> S.E.: Clustered   by: Country of O..
#> Observations                  38,325
#> R2                           0.70402
#> Within R2                    0.21827
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# The dictionary only 'grows'
# Here you get the previous two variables + the new one that are relabeled
# Btw you set the dictionary directly using the argument names:
setFixest_dict(Destination = "Country of Destination")
etable(est)
#>                                       est
#> Dependent Var.:                Euros (ln)
#>                                          
#> log(dist_km)           -2.169*** (0.1542)
#> Fixed-Effects:         ------------------
#> Country of Origin                     Yes
#> Country of Destination                Yes
#> Product                               Yes
#> ______________________ __________________
#> S.E.: Clustered        by: Country of O..
#> Observations                       38,325
#> R2                                0.70402
#> Within R2                         0.21827
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# Another way to set a dictionary: with a character string:
# See the help page of as.dict
dict = "log(dist_km): Distance (ln); Product: Type of Good"
setFixest_dict(dict)
etable(est)
#>                                       est
#> Dependent Var.:                Euros (ln)
#>                                          
#> Distance (ln)          -2.169*** (0.1542)
#> Fixed-Effects:         ------------------
#> Country of Origin                     Yes
#> Country of Destination                Yes
#> Type of Good                          Yes
#> ______________________ __________________
#> S.E.: Clustered        by: Country of O..
#> Observations                       38,325
#> R2                                0.70402
#> Within R2                         0.21827
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

# And now we reset:
setFixest_dict(reset = TRUE)
etable(est)
#>                                est
#> Dependent Var.:         log(Euros)
#>                                   
#> log(dist_km)    -2.169*** (0.1542)
#> Fixed-Effects:  ------------------
#> Origin                         Yes
#> Destination                    Yes
#> Product                        Yes
#> _______________ __________________
#> S.E.: Clustered         by: Origin
#> Observations                38,325
#> R2                         0.70402
#> Within R2                  0.21827
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1