### Setup and Model Definitions in Julia Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code block sets up the necessary environment by loading required Julia packages, creating a DataFrame from the 'iris' dataset, and defining several regression models using different formulas and estimation methods (OLS, Fixed Effects, IV, GLM). These models serve as inputs for the regression table generation. ```julia using RegressionTables, DataFrames, RDatasets, FixedEffectModels, GLM; df = dataset("datasets", "iris"); df[!,:isSmall] = df[!,:SepalWidth] .< 2.9; rr1 = reg(df, @formula(SepalLength ~ SepalWidth)); rr2 = reg(df, @formula(SepalLength ~ SepalWidth + PetalLength + fe(Species))); rr3 = reg(df, @formula(SepalLength ~ SepalWidth + PetalLength * PetalWidth + fe(Species) + fe(isSmall))); rr4 = reg(df, @formula(SepalWidth ~ SepalLength + PetalLength + PetalWidth + fe(Species))); rr5 = reg(df, @formula(SepalWidth ~ SepalLength + (PetalLength ~ PetalWidth) + fe(Species))); rr6 = glm(@formula(isSmall ~ PetalLength + PetalWidth + Species), df, Binomial()); rr7 = glm(@formula(isSmall ~ SepalLength + PetalLength + PetalWidth), df, Binomial()); lm1 = lm(@formula(SepalLength ~ SepalWidth), df); lm2 = lm(@formula(SepalLength ~ SepalWidth + PetalLength + Species), df); ``` -------------------------------- ### Setup Regression Models and DataFrames Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/keep_drop_order.md This code block sets up the necessary packages (RegressionTables, DataFrames, FixedEffectModels, RDatasets), loads the 'iris' dataset, creates a dummy variable, and defines several regression models (rr1 to rr6) using the `reg` function. These models serve as the basis for the examples in the documentation. ```julia using RegressionTables, DataFrames, FixedEffectModels, RDatasets df = dataset("datasets", "iris") df[!,:SpeciesDummy] = df[!,:Species] rr1 = reg(df, @formula(SepalLength ~ SepalWidth + fe(SpeciesDummy))) rr2 = reg(df, @formula(SepalLength ~ SepalWidth + PetalLength + fe(SpeciesDummy))) rr3 = reg(df, @formula(SepalLength ~ SepalWidth * PetalLength + PetalWidth + fe(SpeciesDummy))) rr4 = reg(df, @formula(SepalWidth ~ SepalLength + PetalLength + PetalWidth + fe(SpeciesDummy))) rr5 = reg(df, @formula(SepalLength ~ SepalWidth * PetalLength + fe(SpeciesDummy))) rr6 = reg(df, @formula(SepalLength ~ SepalWidth + PetalLength + SpeciesDummy)) ``` -------------------------------- ### Install RegressionTables.jl Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/index.md Installs the RegressionTables package using the Julia package manager. ```julia ] add RegressionTables ``` -------------------------------- ### Rendering Regression Tables to LaTeX Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example shows how to render regression tables into LaTeX format using the LatexTable() option with the regtable function. It also illustrates the use of DataRow for customizing table content and appearance within the LaTeX output. ```julia regtable(rr1,rr2,rr3,rr4; render=LatexTable(), extralines=[ ["Specification:", "Option 1", "Option 2", "Option 3", "Option 4"], DataRow(["Difference in coefficients", 1.503 => 2:3, 3.515 => 4:5]; align = "lcc", print_underlines=[false, true, true]) ]) # use DataRow to customize alignment ``` -------------------------------- ### Generate Regression Table with Customization (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example illustrates how to generate a regression table and customize its output by disabling the display of the estimator section, using the `print_estimator_section = false` argument. ```jldoctest regtable(rr1,rr2,rr3,rr7; print_estimator_section = false) ``` -------------------------------- ### Generate Regression Table with Standardized Coefficients and Confidence Intervals Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example demonstrates how to generate a regression table using multiple regression models (lm1, lm2, rr6, rr7). It specifically shows how to set 'below_statistic' to 'ConfInt' to display confidence intervals and 'standardize_coef' to 'true' to show standardized coefficients. ```julia regtable(lm1,lm2,rr6,rr7; below_statistic = ConfInt, standardize_coef=true) ``` -------------------------------- ### Generate Default Regression Table in Julia Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example demonstrates the default usage of the `regtable` function from RegressionTables.jl to create a comprehensive regression table from multiple pre-defined regression model outputs. The table includes estimates, standard errors, fixed effects indicators, and model statistics. ```julia regtable(rr1,rr2,rr3,rr4,rr5,rr6) # output ------------------------------------------------------------------------------------------ SepalLength SepalWidth isSmall ------------------------------ ------------------ --------- (1) (2) (3) (4) (5) (6) ------------------------------------------------------------------------------------------ (Intercept) 6.526*** -1.917 (0.479) (1.242) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** 0.723*** -0.188* 1.048** -0.773 (0.064) (0.129) (0.083) (0.362) (0.554) PetalWidth -0.625 0.626*** -3.782** (0.354) (0.123) (1.256) PetalLength & PetalWidth 0.066 (0.067) SepalLength 0.378*** -0.313 (0.066) (0.239) Species: versicolor 10.441*** (1.957) Species: virginica 13.230*** (2.636) ------------------------------------------------------------------------------------------ Species Fixed Effects Yes Yes Yes Yes isSmall Fixed Effects Yes ------------------------------------------------------------------------------------------ Estimator OLS OLS OLS OLS IV Binomial ------------------------------------------------------------------------------------------ N 150 150 150 150 150 150 R2 0.014 0.863 0.868 0.635 0.080 Within-R2 0.642 0.598 0.391 -0.535 First-stage F statistic 19.962 Pseudo R2 0.006 0.811 0.826 0.862 0.072 0.347 ------------------------------------------------------------------------------------------ ``` -------------------------------- ### Basic Regression Table Output (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Displays a standard regression table with coefficients and significance stars. Assumes regression results `rr1`, `rr2`, `rr3`, `rr4` are pre-defined. ```julia regtable(rr1,rr2,rr3,rr4) ``` -------------------------------- ### Generate Regression Table (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates the basic usage of the `regtable` function to display multiple regression models. It shows how to format the output, including suppressing regression numbers. ```julia regtable(rr1,rr2,rr3,rr7; number_regressions = false) ``` -------------------------------- ### Alternative Typst Table Rendering Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Shows another instance of calling `regtable` with `TypstTable()` but with a different set of regression results (rr1, rr6, rr7), indicating flexibility in handling various regression outputs. ```jldoctest regtable(rr1, rr6, rr7; render = TypstTable()) ``` -------------------------------- ### Specifying a Leading Group Label Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example shows how to add a label for the very first column group when the number of group labels is one more than the number of regressions. This prepends a custom title to the grouping structure. ```julia regtable(rr1,rr2,rr4,rr3; groups = ["My Group:", "grp1", "grp1", "grp2", "grp2"]) ``` -------------------------------- ### Basic Regression Table Output Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet shows the default output format of a regression table generated by the `regtable` function. It displays coefficients, standard errors, and model fit statistics. ```julia regtable(rr1,rr2,rr4,rr3) # output ----------------------------------------------------------- Sepal Length ------------------------------ (1) (2) (3) ----------------------------------------------------------- (Intercept) 6.526*** (0.479) Sepal Width -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) Petal Length 0.776*** 0.723*** (0.064) (0.129) Petal Width -0.625 (0.354) Petal Length & Petal Width 0.066 (0.067) ----------------------------------------------------------- Species Fixed Effects Yes Yes isSmall Fixed Effects Yes ----------------------------------------------------------- N 150 150 150 R2 0.014 0.863 0.868 Within-R2 0.642 0.598 ----------------------------------------------------------- ``` -------------------------------- ### Generating Descriptive Statistics Tables Source: https://github.com/jmboehm/regressiontables.jl/blob/master/README.md Provides an example of using RegressionTables for descriptive statistics. It shows how to describe a DataFrame, create a RegressionTable from the description, and render it as a LatexTable or HtmlTable, writing to a file. ```julia df_described = describe(df) tab = RegressionTable(names(df_described), Matrix(df_described)) write("descriptive_stats.tex", LatexTable(tab)) write("descriptive_stats.html", HtmlTable(tab)) ``` -------------------------------- ### Generate Regression Table with LaTeX Rendering Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates how to generate a regression table using the `regtable` function with LaTeX rendering. It also shows the use of `extra_space` for better table formatting. The output is a LaTeX table string. ```jldoctest regtable(rr1,rr2,rr3,rr4; render = LatexTable(), extra_space=true) ``` -------------------------------- ### Create Regression Table in Julia Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Generates a regression table with specified columns, alignment, and content using the `regressiontables` package in Julia. It includes formatting for statistical significance and different regression types. ```Julia table( columns: (auto, auto, auto, auto), align: (left, right, right, right), column-gutter: 1fr, stroke: none, table.hline(), [], , table.cell(colspan: 1, align: center)[SepalLength], table.cell(colspan: 2, align: center)[isSmall], table.hline(start: 1, end: 2, stroke: 0.5pt), table.hline(start: 2, end: 4, stroke: 0.5pt), [], , [(1)], [(2)], [(3)], table.hline(stroke: 0.7pt), [(Intercept)] , [6.526""^(***)"], [-1.917], [10.189""^(***)"], [], , [(0.479)], [(1.242)], [(2.607)], [SepalWidth] , [-0.223], [], [], [], , [(0.155)], [], [], [PetalLength] , [], [-0.773], [3.580""^(***)"], [], , [], [(0.554)], [(0.708)], [PetalWidth] , [], [-3.782""^(**)"], [-3.637""^(**)"], [], , [], [(1.256)], [(1.127)], [Species: versicolor], [], [10.441""^(***)"], [], [], , [], [(1.957)], [], [Species: virginica] , [], [13.230""^(***)"], [], [], , [], [(2.636)], [], [SepalLength] , [], [], [-3.519""^(***)"], [], , [], [], [(0.697)], table.hline(stroke: 0.7pt), [Estimator] , [OLS], [Binomial], [Binomial], table.hline(stroke: 0.7pt), [_N_] , [150], [150], [150], [_R_^2] , [0.014], [], [], [Pseudo _R_^2] , [0.006], [0.347], [0.297], table.hline(), ) ``` -------------------------------- ### Labeling Interaction Terms in Regression Tables Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Shows how to label interaction terms by providing labels for individual components. The package automatically handles the combined labeling for interaction effects. ```jldoctest regtable(rr3;labels=Dict( "SepalWidth" => "Sepal Width", "PetalLength" => "Petal Length", "PetalWidth" => "Petal Width" )) # it is not necessary to specify a "PetalLength & PetalWidth" label ``` ```jldoctest # output ---------------------------------------- SepalLength ---------------------------------------- Sepal Width 0.516*** (0.104) Petal Length 0.723*** (0.129) Petal Width -0.625 (0.354) Petal Length & Petal Width 0.066 (0.067) ---------------------------------------- Species Fixed Effects Yes isSmall Fixed Effects Yes ---------------------------------------- N 150 R2 0.868 Within-R2 0.598 ---------------------------------------- ``` -------------------------------- ### Grouping Regression Tables with Integer Ranges Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example demonstrates how to group columns in a regression table using integer ranges for the columns. It assigns labels to specific column indices, allowing for custom table structuring. ```jldoctest regtable(rr1,rr2,rr4,rr3; groups = ["My Group:", "grp1" => 2:3, "grp2" => 4:5]) # output ------------------------------------------------------------------------- My Group: grp1 grp2 ------------------- ------------------------ SepalLength SepalWidth SepalLength ------------------- ---------- ----------- (1) (2) (3) (4) ------------------------------------------------------------------------- (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** -0.188* 0.723*** (0.064) (0.083) (0.129) SepalLength 0.378*** (0.066) PetalWidth 0.626*** -0.625 (0.123) (0.354) PetalLength & PetalWidth 0.066 (0.067) ------------------------------------------------------------------------- Species Fixed Effects Yes Yes Yes isSmall Fixed Effects Yes ------------------------------------------------------------------------- N 150 150 150 150 R2 0.014 0.863 0.635 0.868 Within-R2 0.642 0.391 0.598 ------------------------------------------------------------------------- ``` -------------------------------- ### Generate LaTeX Regression Table with regressiontables.jl Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates how to use the `regtable` function with the `LatexTable()` renderer to create LaTeX-formatted regression tables. This function is used to combine and display multiple regression results in a structured table suitable for academic papers. ```julia regtable(rr1,rr2,rr3,rr4; render = LatexTable()) ``` -------------------------------- ### Usage Example: Fitting Model and Generating Table (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/custom_regression_model.md Demonstrates how to set up optimization parameters and restricted parameters, fit a custom model using the `StatsAPI.fit` function, and generate a regression table with confidence intervals displayed using custom formatting. This shows the practical application of the previously defined functions. ```julia # Set up optimization parameters s_v = NamedArray(Array{Float64}(undef, 2)) setnames!(s_v, ["Beta 2", "Sigma"], 1) s_v["Beta 2"] = 1.0 s_v["Sigma"] = 0.05 # Set up restricted parameters s_v_r = NamedArray(Array{Float64}(undef, 1)) setnames!(s_v_r, ["Beta 1"], 1) s_v_r["Beta 1"] = 3.0 # Fit model and generate table with confidence intervals rr1 = StatsAPI.fit(CustomModel, x, y, s_v, s_v_r) regtable(rr1, below_statistic = ConfInt) ``` -------------------------------- ### Label Coefficients in Regression Tables Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates how to use the `labels` argument in `regtable` to rename coefficients and dependent variables in the output table. This improves readability and clarity of the results. ```jldoctest regtable(rr1,rr2; labels = Dict( "SepalLength" => "My dependent variable: SepalLength", "PetalLength" => "Length of Petal", "PetalWidth" => "Width of Petal", "(Intercept)" => "Const." , "isSmall" => "isSmall Dummies", "SpeciesDummy" => "Species Dummies" )) ``` ```jldoctest # output ----------------------------------------------------------- My dependent variable: SepalLength ----------------------------------- (1) (2) ----------------------------------------------------------- Const. 6.526*** (0.479) SepalWidth -0.223 0.432*** (0.155) (0.081) Length of Petal 0.776*** (0.064) ----------------------------------------------------------- Species Fixed Effects Yes ----------------------------------------------------------- N 150 150 R2 0.014 0.863 Within-R2 0.642 ----------------------------------------------------------- ``` -------------------------------- ### Render Regression Table using Typst Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates how to utilize the `TypstTable()` renderer with the `regtable` function to generate a regression table compatible with Typst. This function takes multiple regression results (e.g., rr1, rr2, rr3, rr4) as input. ```jldoctest regtable(rr1,rr2,rr3,rr4; render = TypstTable()) ``` -------------------------------- ### Control Digit Precision in Regression Tables Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Shows how to set the number of digits for displaying statistics in regression tables using the `digits_stats` argument in the regtable function. ```jldoctest regtable(rr1,rr2,rr3,rr4; digits_stats = 4) ``` -------------------------------- ### Regression Table with T-Statistics (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Formats the regression table to display T-statistics below the coefficients. This is achieved by setting `below_statistic = TStat`. ```julia regtable(rr1,rr2,rr3,rr4; below_statistic = TStat) ``` -------------------------------- ### Generate Regression Table Output Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Displays a sample regression table output with various statistical measures like coefficients, standard errors, N, and R2. This is a common output format for statistical models. ```jldoctest # output ---------------------------------------------------------------------- SepalLength SepalWidth ------------------------------ ---------- (1) (2) (3) (4) ---------------------------------------------------------------------- (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** 0.723*** -0.188* (0.064) (0.129) (0.083) PetalWidth -0.625 0.626*** (0.354) (0.123) PetalLength & PetalWidth 0.066 (0.067) SepalLength 0.378*** (0.066) ---------------------------------------------------------------------- Species Fixed Effects Yes Yes Yes isSmall Fixed Effects Yes ---------------------------------------------------------------------- N 150 150 150 150 R2 0.0138 0.8633 0.8682 0.6352 Within-R2 0.6415 0.5978 0.3911 ---------------------------------------------------------------------- ``` -------------------------------- ### Display Regression Tables Without Statistics Below Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example shows how to modify the `regtable` function's output by setting `stat_below=false`. This suppresses the display of standard errors or other statistics below the coefficient estimates, presenting a cleaner table. ```jldoctest regtable(rr1,rr2,rr3,rr4; stat_below=false, extra_space=true) ``` -------------------------------- ### Format Regression Table Statistics in Julia Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates how to use the regtable function to display regression results with custom statistic formatting. The `statisticformat` argument controls the output format of the statistical values. ```jldoctest regtable(rr1,rr2,rr3,rr4; statisticformat = "%02.5f") ``` -------------------------------- ### Re-order Fixed Effects (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Illustrates how to reorder fixed effects in a regression table by providing a list of fixed effect names to the `fixedeffects` argument. This allows for customized presentation of model results. ```julia regtable(rr1,rr2,rr3,rr4; fixedeffects = [r"isSmall", "SpeciesDummy"]) ``` -------------------------------- ### Typst Table Structure Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md An example of the Typst markup generated for a regression table. It defines table properties like columns, alignment, and strokes, and populates the table with data including coefficients, standard errors, and model statistics. Note the use of `table.cell(colspan: ...)` for spanning cells and `table.hline()` for horizontal rules. ```typst #table( columns: (auto, auto, auto, auto, auto), align: (left, right, right, right, right), column-gutter: 1fr, stroke: none, table.hline(), [] , table.cell(colspan: 3, align: center)[SepalLength] , table.cell(colspan: 1, align: center)[SepalWidth], table.hline(start: 1, end: 4, stroke: 0.5pt), table.hline(start: 4, end: 5, stroke: 0.5pt), [] , [(1)], [(2)], [(3)], [(4)], table.hline(stroke: 0.7pt), [(Intercept)] , [6.526$""^(***)$"], [], [], [], [] , [(0.479)], [], [], [], [SepalWidth] , [-0.223], [0.432$""^(***)$"], [0.516$""^(***)$"], [], [] , [(0.155)], [(0.081)], [(0.104)], [], [PetalLength] , [], [0.776$""^(***)$"], [0.723$""^(***)$"], [-0.188$""^(*)$"], [] , [], [(0.064)], [(0.129)], [(0.083)], [PetalWidth] , [], [], [-0.625], [0.626$""^(***)$"], [] , [], [], [(0.354)], [(0.123)], [PetalLength $times$ PetalWidth], [], [], [0.066], [], [] , [], [], [(0.067)], [], [SepalLength] , [], [], [], [0.378$""^(***)$"], [] , [], [], [], [(0.066)], table.hline(stroke: 0.7pt), [Species Fixed Effects] , [], [Yes], [Yes], [Yes], [isSmall Fixed Effects] , [], [], [Yes], [], table.hline(stroke: 0.7pt), [_N_] , [150], [150], [150], [150], [_R_$""^2$] , [0.014], [0.863], [0.868], [0.635], [Within-_R_$""^2$] , [], [0.642], [0.598], [0.391], table.hline(), ) ``` -------------------------------- ### Julia: Mixed Model Regression Table Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Generates a regression table for three mixed-effects models. It utilizes Julia's formula syntax, contrast coding, and grouping for random effects, and custom labels for enhanced readability. ```Julia form1 = @formula(rt_trunc ~ 1 + spkr + prec + load + (1 + load | item) + (1 + spkr + prec + load | subj)) contr = Dict(:spkr => EffectsCoding(), :prec => EffectsCoding(), :load => EffectsCoding(), :item => Grouping(), :subj => Grouping()) # to make sure the results are always the same, these values help fix the model into one result fmreθ = [ 0.8648075226444749, 0.43344406279292136, 0.532698219245229, 0.03139575786126669, 0.269825335511795, 0.5307313041693793, 0.23438217856147925, 0.0349964462168697, 0.948766814931185, 0.40866263683286375, 0.6055999220729944, 0.9928229644500718, 0.05342261972167761, ] kbm1 = updateL!(setθ!(LinearMixedModel(form1, MixedModels.dataset(:kb07); contrasts=contr), fmreθ)) form2 = @formula(rt_trunc ~ 1 + spkr + prec + load + (1 + spkr + prec + load | subj)) fmreθ = [ 0.27115451643185495, 0.02114691520013967, 0.8794734878503344, 0.7343424423913391, 0.6603201740011742, 0.8497808579576883, 0.6355311618411573, 0.7807843933484198, 0.9669197738773895, 0.03814101806846881, ] kbm2 = updateL!(setθ!(LinearMixedModel(form2, MixedModels.dataset(:kb07); contrasts=contr), fmreθ)) form3 = @formula(rt_trunc ~ 1 + spkr + prec + load + (1 + load | item) + (1 + spkr + prec * load | subj)) fmreθ = [ 0.7221403658923715, 0.3078425012729602, 0.2917886795704724, 0.5000142926713435, 0.7426865162047754, 0.1731367021580622, 0.020327890985133656, 0.7595447732279332, 0.48724482279872006, 0.6205745741154292, 0.3954285463498247, 0.09594315730251379, 0.13946651488431383, 0.6672989094861689, 0.2341117878022333, 0.053650218835408436, 0.143772505670828, 0.027822254707002392, ] kbm3 = updateL!(setθ!(LinearMixedModel(form3, MixedModels.dataset(:kb07); contrasts=contr), fmreθ)) regtable(kbm1, kbm2, kbm3; labels=Dict( "subj" => "Subject", "item" => "Item", "load: yes" => "Load", "prec: maintain" => "Prec", "spkr: old" => "Old Speaker" ) ) ``` -------------------------------- ### Display Various Regression Statistics Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Illustrates how to display a comprehensive set of regression statistics using the `regtable` function. It includes common statistics like Nobs, R2, AIC, BIC, and F-statistic, as well as less common ones like PseudoR2 and R2CoxSnell. ```jldoctest regtable(rr1,rr2,rr3,rr5; regression_statistics = [ Nobs, R2, PseudoR2, R2CoxSnell, R2Nagelkerke, R2Deviance, AdjR2, AdjPseudoR2, AdjR2Deviance, DOF, LogLikelihood, AIC, AICC, BIC, FStat, FStatPValue, FStatIV, FStatIVPValue, R2Within ]) ``` -------------------------------- ### Transforming Coefficient Labels in Regression Tables Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Illustrates the use of `transform_labels` to modify coefficient names using a substitution dictionary. This allows for flexible and consistent renaming of multiple coefficients. ```jldoctest regtable(rr1, rr2, rr3; transform_labels = Dict("Width" => " Width", "Length" => " Length")) ``` -------------------------------- ### Regression Table Without Statistics (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Generates a regression table excluding all statistical information like p-values or standard errors. Uses the `below_statistic = nothing` argument. ```julia regtable(rr1,rr2,rr3,rr4; below_statistic = nothing) ``` -------------------------------- ### Display Regression Tables with Statistics Below Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet demonstrates the default behavior of the `regtable` function, showing how regression results are displayed with statistical significance indicators and standard errors below the coefficients. It uses `below_statistic = nothing` and `extra_space = true` for enhanced readability. ```jldoctest regtable(rr1,rr2,rr3,rr4; below_statistic = nothing, extra_space=true) ``` -------------------------------- ### Example Usage: Creating Regression Tables with Fitted Models in Julia Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/custom_regression_model.md Demonstrates how to use the implemented `StatsAPI.fit` function with different formulas and a sample dataset ('Cigar' from plm). It then uses `regtable` to display the results of the fitted models side-by-side, showcasing the generated regression table output. ```julia # Example usage df = dataset("plm", "Cigar") rr1 = StatsAPI.fit(MyStatsModel, @formula(Sales ~ 1 + Price + NDI), df) r2 = StatsAPI.fit(MyStatsModel, @formula(Sales ~ 1 + Price), df) r3 = StatsAPI.fit(MyStatsModel, @formula(Sales ~ 1 + NDI), df) regtable(rr1, rr2, rr3) ``` -------------------------------- ### Basic Regression Table Output Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code snippet shows the default output of the `regtable` function when processing multiple regression results. It displays coefficients, standard errors, and various model statistics. ```jldoctest regtable(rr1,rr2,rr4,rr3) # output ------------------------------------------------------------------------- My Group: grp1 grp2 ------------------- ------------------------ SepalLength SepalWidth SepalLength ------------------- ---------- ----------- (1) (2) (3) (4) ------------------------------------------------------------------------- (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** -0.188* 0.723*** (0.064) (0.083) (0.129) SepalLength 0.378*** (0.066) PetalWidth 0.626*** -0.625 (0.123) (0.354) PetalLength & PetalWidth 0.066 (0.067) ------------------------------------------------------------------------- Species Fixed Effects Yes Yes Yes isSmall Fixed Effects Yes ------------------------------------------------------------------------- N 150 150 150 150 R2 0.014 0.863 0.635 0.868 Within-R2 0.642 0.391 0.598 ------------------------------------------------------------------------- ``` -------------------------------- ### Regression Table with Confidence Intervals (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Generates a regression table showing confidence intervals below the coefficients. The default confidence level is 95%, specified by `below_statistic = ConfInt`. ```julia regtable(rr1,rr2,rr3,rr4,lm1,rr7; below_statistic = ConfInt) ``` -------------------------------- ### Multi-Level Grouping in Regression Tables Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet illustrates how to implement multi-level grouping for columns in a regression table. It uses a matrix or a vector of vectors to define hierarchical group labels. ```jldoctest regtable(rr1,rr2,rr4,rr3; groups = [ "grp parent" "grp parent" "grp parent" "other group"; "grp1" "grp1" "grp2" "grp2" ]) ``` -------------------------------- ### Grouping Regressions in a Table Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet demonstrates how to group multiple regression outputs into distinct columns within a single table using the `groups` argument in the `regtable` function. Each group is assigned a label. ```julia regtable(rr1,rr2,rr4,rr3; groups = ["grp1", "grp1", "grp2", "grp2"]) # output ------------------------------------------------------------------------- grp1 grp2 ------------------- ------------------------ SepalLength SepalWidth SepalLength ------------------- ---------- ----------- (1) (2) (3) (4) ------------------------------------------------------------------------- (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** -0.188* 0.723*** (0.064) (0.083) (0.129) SepalLength 0.378*** (0.066) PetalWidth 0.626*** -0.625 (0.123) (0.354) PetalLength & PetalWidth 0.066 (0.067) ------------------------------------------------------------------------- Species Fixed Effects Yes Yes Yes isSmall Fixed Effects Yes ------------------------------------------------------------------------- N 150 150 150 150 R2 0.014 0.863 0.635 0.868 Within-R2 0.642 0.391 0.598 ------------------------------------------------------------------------- ``` -------------------------------- ### Basic Regression Table Output Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet shows the default output of the regtable function, displaying regression results in a formatted table. It includes coefficients, standard errors, and significance stars. The table structure visualizes multiple regression models side-by-side. ```julia regtable(rr1,rr2,rr3,rr4; extralines=[ DataRow(["Difference in coefficients", 1.5032 => 2:3, 3.5152 => 4:5]; align = "lcc", print_underlines=[false, true, true]), ["Specification:", "Option 1", "Option 2", "Option 3", "Option 4"], ]) # output ------------------------------------------------------------------------ SepalLength SepalWidth ------------------------------ ---------- (1) (2) (3) (4) ------------------------------------------------------------------------ (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** 0.723*** -0.188* (0.064) (0.129) (0.083) PetalWidth -0.625 0.626*** (0.354) (0.123) PetalLength & PetalWidth 0.066 (0.067) SepalLength 0.378*** (0.066) ------------------------------------------------------------------------ Species Fixed Effects Yes Yes Yes isSmall Fixed Effects Yes ------------------------------------------------------------------------ N 150 150 150 150 R2 0.014 0.863 0.868 0.635 Within-R2 0.642 0.598 0.391 Difference in coefficients 1.503 3.515 ------------------- --------------------- Specification: Option 1 Option 2 Option 3 Option 4 ------------------------------------------------------------------------ ``` -------------------------------- ### Format Regression Tables with Column Grouping (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code snippet demonstrates how to use the `regtable` function to format regression output, specifically by grouping columns under parent headers. It takes multiple regression results (rr1, rr2, rr4, rr3) and defines custom group labels and column ranges for a more organized presentation. ```jldoctest regtable(rr1,rr2,rr4,rr3; groups = [ ["Parent Group:", "grp parent" => 2:4, "other group"], ["grp1", "grp1", "grp2", "grp2"] ]) ``` -------------------------------- ### Format Regression Output with Custom Estimates Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code snippet demonstrates how to format regression output using the `regtable` function from the regressiontables.jl package. The `estimformat` argument allows for custom formatting of the estimates, such as specifying the number of decimal places and significance stars. ```julia regtable(rr1,rr2,rr3,rr4; estimformat = "%02.5f") ``` -------------------------------- ### Customizing Regression Tables with DataRow Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet demonstrates using the DataRow function to add custom lines to a regression table. It shows how to specify values, their column spans, alignment, and underline behavior, offering fine-grained control over table presentation. ```julia regtable(rr1,rr2,rr3,rr4; extralines=[ DataRow(["Difference in coefficients", 1.5032 => 2:3, 3.5152 => 4:5]; align = "lcc", print_underlines=[false, true, true]), ["Specification:", "Option 1", "Option 2", "Option 3", "Option 4"], ]) ``` -------------------------------- ### Generate Regression Table with Extralines Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md Demonstrates how to add custom lines of text at the end of a regression table using the `extralines` argument in the `regtable` function. This is useful for adding model specifications or other relevant notes. ```julia regtable(rr1,rr2,rr3,rr4; extralines=["Specification:", "Option 1", "Option 2", "Option 3", "Option 4"] ) # output ---------------------------------------------------------------------- SepalLength SepalWidth ------------------------------ ---------- (1) (2) (3) (4) ---------------------------------------------------------------------- (Intercept) 6.526*** (0.479) SepalWidth -0.223 0.432*** 0.516*** (0.155) (0.081) (0.104) PetalLength 0.776*** 0.723*** -0.188* (0.064) (0.129) (0.083) PetalWidth -0.625 0.626*** (0.354) (0.123) PetalLength & PetalWidth 0.066 (0.067) SepalLength 0.378*** (0.066) ---------------------------------------------------------------------- Species Fixed Effects Yes Yes Yes isSmall Fixed Effects Yes ---------------------------------------------------------------------- N 150 150 150 150 R2 0.014 0.863 0.868 0.635 Within-R2 0.642 0.598 0.391 Specification: Option 1 Option 2 Option 3 Option 4 ---------------------------------------------------------------------- ``` -------------------------------- ### Format Regression Output with Specified Digits Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code snippet shows how to control the number of decimal places displayed for estimates and statistics in the regression output using the `digits` argument in the `regtable` function. This is useful for presenting results with a consistent level of precision. ```julia regtable(rr1,rr2,rr3,rr4; digits = 4) ``` -------------------------------- ### Generate Regression Table (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet demonstrates the basic usage of the `regtable` function to generate a regression table from multiple regression results (rr1, rr2, rr3, rr7). It also shows how to suppress the display of the dependent variable column. ```jldoctest regtable(rr1,rr2,rr3,rr7; print_depvar = false) ``` -------------------------------- ### Display Regression Table with Custom Confidence Interval Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code demonstrates how to generate a regression table using specific regression models (rr1, rr2, rr3, rr4). It also shows how to set the confidence interval level to 0.9 and align the table content to the center using the `confint_level` and `align` keyword arguments, respectively. The `below_statistic` argument is used to display the confidence intervals below the main statistics. ```jldoctest regtable(rr1,rr2,rr3,rr4; below_statistic = ConfInt, confint_level=0.9, align=:c) ``` -------------------------------- ### Change Labels for Regression Statistics Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This snippet shows how to customize the display labels for various regression statistics (like Number of Observations and Adjusted R-squared) in the generated regression table. It takes multiple regression results as input. ```julia regtable(rr1,rr2,rr3,rr4; regression_statistics=[ Nobs => "Number of Observations", R2, AdjR2 => "Adj. R2" ]) ``` -------------------------------- ### Add Extra Row Between Coefficients Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This code snippet demonstrates how to use the `extra_space` option to add an extra row between coefficients in the regression table, mimicking the Stargazer R package's output style. This improves readability by visually separating coefficients. ```julia regtable(rr1,rr2,rr3,rr4; extra_space = true) ``` -------------------------------- ### Control Fixed Effects Section Display in Regression Tables (Julia) Source: https://github.com/jmboehm/regressiontables.jl/blob/master/docs/src/examples.md This example illustrates how to use the `regtable` function to control the display of the fixed effects section in the output table. By setting `print_fe_section` to `false`, the fixed effects are omitted from the final formatted table. ```jldoctest regtable(rr1,rr2,rr3,rr7; print_fe_section = false) ```