Etable In R

0 views
Skip to first unread message

Alexandrie Gallup

unread,
Aug 4, 2024, 6:17:52 PM8/4/24
to seoviemisdist
Hii'm new to markdown, so this is difficult to me. I'm working with feols function from the package "fixest" to estimate a fixed effects model. My code runs fine in R scrip and rmd, but when I try etable to export my results I only get Latex code. My code looks something like this (here I use airquality as an example):

When I did this I got an error that the midrule command could not be found.

Google search told me that midrule belongs to the booktabs package

Therefore I added extra_dependencies: ["booktabs"] in the YAML to generate \usepackagebooktabs ,

but there are other ways to add to the preamble. See e.g.

-cookbook/latex-preamble.html


Aggregates the results of multiple estimations and displays them in the form of either a Latextable or a data.frame. Note that you will need the booktabs package for the Latex table torender properly. See setFixest_etable to set the default values, and style.tex to customize Latex output.


Can be equal to 2 (default), 1, 1:2 or 2:1. Only used if the objectis an IV estimation: defines the stage to which summary should be applied. If stage = 1and there are multiple endogenous regressors or if stage is of length 2, then anobject of class fixest_multi is returned.


A character scalar describing the variable names to be aggregated,it is pattern-based. For sunab estimations, the following keywords work: "att","period", "cohort" and FALSE (to have full disaggregation). All variables thatmatch the pattern will be aggregated. It must be of the form "(root)", the parenthesesmust be there and the resulting variable name will be "root". You can add anotherroot with parentheses: "(root1)regex(root2)", in which case the resultingname is "root1::root2". To name the resulting variable differently you can passa named vector: c("name" = "pattern") or c("name" = "pattern(root2)"). It's abit intricate sorry, please see the examples.


An object of class ssc.type obtained with the function ssc. Representshow the degree of freedom correction should be done.You must use the function sscfor this argument. The arguments and defaults of the function ssc are:adj = TRUE, fixef.K="nested", cluster.adj = TRUE, cluster.df = "min",t.df = "min", fixef.force_exact=FALSE). See the help of the function ssc for details.


Integer or character scalar. Default is 4 and represents the number of significantdigits to be displayed for the coefficients and standard-errors. To apply rounding instead ofsignificance use, e.g., digits = "r3" which will round at the first 3 decimals. If character,it must be of the form "rd" or "sd" with d a digit (r is for round and s is forsignificance). For the number of digits for the fit statistics, use digits.stats. Note thatwhen significance is used it does not exactly display the number of significant digits: seedetails for its exact meaning.


Integer or character scalar. Default is 5 and represents the number ofsignificant digits to be displayed for the fit statistics. To apply rounding instead ofsignificance use, e.g., digits = "r3" which will round at the first 3 decimals. If character,it must be of the form "rd" or "sd" with d a digit (r is for round and s is forsignificance). Note that when significance is used it does not exactly display the number ofsignificant digits: see details for its exact meaning.


One of "se" (default), "tstat" or "confint". The statistic to report foreach coefficient: the standard-error, the t-statistics or the confidence interval. You canadjust the confidence interval with the argument ci.


Logical scalar, default is NULL. Whether should be displayed the row with thetype of standard-error for each model. When tex = FALSE, the default is TRUE.When tex = FALSE, the row is showed only when there is a table-footer and the types ofstandard-errors differ across models.


A character scalar. If provided, the Latex (or data frame) table will be saved in afile whose path is file. If you provide this argument, then a Latex table will be exported, toexport a regular data.frame, use argument tex = FALSE.


Logical, default is TRUE. Only used if fixef_sizes = TRUE. IfTRUE, the fixed-effects sizes will be displayed in parentheses instead of in a separate lineif there is no ambiguity (i.e. if the size is constant across models).


(Tex only.) Integer, default is -5. A coefficient whose value is below10**(powerBelow+1) is written with a power in Latex. For example 0.0000456 would be written4.56$\\times 10^-5$ by default. Setting powerBelow = -6 would lead to 0.00004 in Latex.


Character scalar, defaults to " $=$ " when tex = TRUE and " = " otherwise.Only affects factor variables created with the function i, tells how the variable should belinked to its value. For example if you have the Species factor from the iris data set, bydefault the display of the variable is Species = Setosa, etc. If i.equal = ": " the displaybecomes Species: Setosa.


A list. The list elements should be vectors of regular expressions. For eachelements of this list: A new line in the table is created, all variables that are matched by theregular expressions are discarded (same effect as the argument drop) and TRUE or FALSEwill appear in the model cell, depending on whether some of the previous variables were found inthe model.Example: group=list("Controls: personal traits"=c("gender", "height", "weight"))will create an new line with "Controls: personal traits" in the leftmost cell, all threevariables gender, height and weight are discarded, TRUE appearing in each model containing atleast one of the three variables (the style of TRUE/FALSE is governed by the argumentyesNo). You can control the placement of the new row by using 1 or 2 special characters at thestart of the row name.The meaning of these special characters are: 1) "^": coef., "-": fixed-effect,"_": stats, section; 2) "^": 1st, "_": last, row.For example: group=list("_^Controls"=stuff) will place the line at the top of the 'stats'section, and using group=list("^_Controls"=stuff) will make the row appear at the bottom ofthe coefficients section. For details, see the dedicated section.


A vector, a list or a one sided formula. The list elements should be either avector representing the value of each cell, a list of the formlist("item1" = #item1, "item2" = #item2, etc), or a function.This argument can be many things, please have a look at the dedicated help section;a simplified description follows. For each elements of this list: A new line in the table iscreated, the list name being the row name and the vector being the content of the cells.Example: extralines=list("Sub-sample"=c("50 yo")) will create an new linewith "Sub-sample" in the leftmost cell, the vector filling the content of the cells for thethree models. You can control the placement of the new row by using 1 or 2 special characters atthe start of the row name. The meaning of these special characters are:


"^": 1st, "_": last, row.For example: extralines=list("__Controls"=stuff) will place the line at the bottom of thestats section, and using extralines=list("^^Controls"=stuff) will make the row appear at thetop of the 'coefficients' section. For details, see the dedicated section. You can use .()instead of list().


Logical scalar or list (default is NULL). If equal to TRUE, then allfixed-effects always appearing jointly in models will be grouped in one row. If a list, itselements must be character vectors of regular expressions and the list names will be the rownames. For ex. fixef.group=list("Dates fixed-effects"="MonthDay") will remove the "Month"and "Day" fixed effects from the display and replace them with a single row named"Dates fixed-effects". You can monitor the placement of the new row with two special characterstelling where to place the row within a section: first in which section it should appear:"^" (coef.), "-" (fixed-effects), or "_" (stat.) section;then whether the row should be "^" (first), or "_" (last). These two special characters mustappear first in the row names. Please see the dedicated section


Character vector which can be of length 0 (i.e. equal to NULL). Cancontain the values "coef", "fixef", "slopes" or "stats". It would drop, respectively, thecoefficients section, fixed-effects section, the variables with varying slopes section or thefit statistics section.


Character vector, default is c("", " square", " cube"). When raw polynomials(x^2, etc) are used, the variables are automatically renamed and poly_dict rules the displayof the power. For powers greater than the number of elements of the vector, the value displayedis $^pow$ in Latex and ^ pow in the R console.


A function that will postprocess.tex the resulting data.frame. Only whentex = FALSE. By default it is equal to NULL, meaning that there is no postprocessing. Whentex = TRUE, see the argument postprocess.tex.


Character scalar giving the path to a PNG file to be created, default is NULL.If provided, the Latex table will be converted to PNG and copied to the export location. Notethat for this option to work you need a working distribution of pdflatex, imagemagick andghostscript, or the R packages tinytex and pdftools.


(Tex only.) Character vector. If provided, a "notes" section will be added at theend right after the end of the table, containing the text of this argument. If it is a vector,it will be collapsed with new lines. If tpt = TRUE, the behavior is different: each element ofthe vector is an item. If the first element of the vector starts with "@", then it will beincluded verbatim, and in case of tpt = TRUE, right before the first item. If that element isprovided, it will replace the value defined in style.tex(notes.intro) orstyle.tex(notes.tpt.intro).


A function that will postprocess the character vector defining the latextable. Only when tex = TRUE. By default it is equal to NULL, meaning that there is nopostprocessing. When tex = FALSE, see the argument postprocess.df. See details.


(Tex only.) A numeric scalar, default is NULL. If provided,the command \\renewcommand*\\arraystretchx is inserted, replacing x by the value ofarraystretch. The changes are specific to the current table and do not affect the rest of thedocument.

3a8082e126
Reply all
Reply to author
Forward
0 new messages