Plotting coefficients in r - r

I have this LaTex table formatted from an output of OxMetrics:
\begin{document}
\begin{tabularx}{\textwidth}{#{} L*{7}{c} #{}}
\toprule
& \multicolumn{6}{c}{Dependent variables} \\
\cmidrule(l){2-7}
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} \\
\midrule
Disabilities &-8.016{$^{***}$} &9.221{$^{***}$} &5.625{$^{**}$} &-2.589 &0.739 &4.281\\
&(2.121) & (3.090) & (2.588) &(3.105) & (3.917) & (2.730)\\
Disabled x Unemployed
&5.068\\
&(3.224)\\
\midrule
Visual
&-7.146{$^{**}$}&-2.684&10.615{$^{**}$}&4.429&13.730{$^{*}$}&0.270\\
&(3.316)&(5.870)&(4.689)&(5.907)&(7.514)&(5.250)\\
Hearing
&-6.515&8.604&12.039{$^{**}$}&7.222&7.964&1.007\\
&(3.735)&(6.628)&(5.877)&(6.878)&(8.704)&(5.969)\\
Motor
&-11.283{$^{***}$}&7.511{$^{*}$}&7.856&2.546&5.034&-2.770\\
&(2.544)&(5.168)&(4.455)&(5.443)&(6.434)&(4.499)\\
Episodic
&-0.183&5.794&1.384&2.780&7.353&2.667\\
&(2.391)&(4.516)&(3.751)&(4.578)&(5.718)&(3.981)\\
\midrule
L
&-4868& -2251& -1954& -2227& -2411& -2361\\
N
&1159& 640& 624& 628& 645& 639\\
\bottomrule
\end{tabularx}
\caption*{\tiny{{***}$p<0.01$.
{**}$p<0.05$.
{*}$p<0.1$. Standard errors in parentheses -- Intercept and other socio-demographic variables (age, sex, marital status, etc.) included but not reported}}
\end{document}
Which gives:
I want to plot these coefficients but I have no clue how to proceed. If the model was estimated with R, it'd be easier. But it's done with another software (OxMetrics). Any suggestions? Thanks.

Related

Equation in a table in R

I want a table like this and make it as a kable so I can make footnote:
but I didn't manage so I made a table latex like this :
$$
\begin{array}{lccccc}
\hline
{Copula} & {Distribution} & {Parameter range} & {Complete dependence} & {Independence} \\
\hline
{Normal} & {C_{Normal} (u_1,u_2,\rho)=\Phi_{\rho}(\Phi^{-1}(u_1),\Phi^{-1}(u_2))} & {\rho\in(-1,1)} & {\rho=1,or -1} & {\rho=0} \\
\hline
{Student-t} & {C_t (u_1,u_2;\rho,d)=t_{\rho,d}(t^{-1}_d(u_1),t^{-1}_d(u_2))} & {\rho\in(-1,1)} & {\rho=1,or -1} & {\rho=0} \\
\hline
{Gumbel} & {C_{Gumbel} (u_1,u_2,\beta)=exp\{-[(-ln(u_1))^{\frac{1}{\beta}}+(-ln(u_2))^{\frac{1}{\beta}}]^{\beta}\}} & {\beta\in(0,1)} & {\beta=0} & {\beta=1} \\
\hline
{RG} & {C_{RG} (u_1,u_2,\alpha)=u_1+u_2-1+C_{Gumbel} (1-u_1,1-u_2,\alpha)} & {\alpha\in[1,\infty)} & {\alpha\rightarrow\infty} & {\alpha=1} \\
\hline
{Clayton} & {C_{Clayton} (u_1,u_2,\theta)=max((u_1^{-\theta}+u_2^{-\theta}-1)^{-\frac{1}{\theta}},0)} & {\theta\in[-1,\infty)\{0\}} & {\theta\rightarrow\infty} & {\theta \rightarrow 0} \\
\hline
{RC} & {C_{RC} (u_1,u_2,\alpha)=u_1+u_2-1+C_{Clayton} (1-u_1,1-u_2,\theta)} & {\theta\in[-1,\infty)\{0\}} & {\theta\rightarrow\infty} & {\theta \rightarrow 0} \\
\hline
\end{array}
$$
and it looks like this:
It's not bad until I found it's not easy to add footnotes since I used to make kable.
Is there any way I can add a footnote for it? or how can I convert it into a table so I can use kable to display it?

Latex - table not showing

I have seen several discussions on this board treating the topic but none of the solutions seem to work. I use R stargazer and have downloaded a table under Latex format, but when I copy paste the TeX code in my Latexfile, it does not show up in the PDF. I have also tried to use \input{myfile} with the table but the results is the same. Please find below a shorter version of the table. Does anybody have a solution ?
\documentclass[12pt]{article}
\begin{document}
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{#{\extracolsep{5pt}}lcccccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
Statistic & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Pctl(25)} & \multicolumn{1}{c}{Median} & \multicolumn{1}{c}{Pctl(75)} & \multicolumn{1}{c}{Max} \\
\hline \\[-1.8ex]
total\_asset & 10 & 30 & 40 & 50 & 60 & 50.000 & 5,556.000 \\
EBITDA\_margin & 6 & $-$5 & 12 & $-$1,250.000 & $-$0.085 & 0.1 & 0.033 & 42,500.000 \\
\hline \\[-1.8ex]
\end{tabular}
\end{table}
\end{document}
Kind regards,

Stargazer not publishing regression table

The packages I currently have downloaded are: tinytex, stargazer, and rmarkdown.
I have used this function to create a publishable table:
stargazer(EB734_May_2010_model_u)
But got this instead:
% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Sep 02, 2020 - 09:30:46
\begin{table}[!htbp] \centering
\caption{}
\label{}
\begin{tabular}{#{\extracolsep{5pt}}lc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& \multicolumn{1}{c}{\textit{Dependent variable:}} \\
\cline{2-2}
\\[-1.8ex] & trust \\
\hline \\[-1.8ex]
D\_economy2 & $-$0.220$^{*}$ \\
& (0.119) \\
& \\
D\_economy0 & 0.243$^{**}$ \\
& (0.118) \\
& \\
E\_economy2 & $-$0.166 \\
& (0.112) \\
& \\
E\_economy0 & $-$0.168 \\
& (0.112) \\
& \\
Support\_EMU0 & 0.655$^{***}$ \\
& (0.027) \\
& \\
Constant & $-$2.038$^{***}$ \\
& (0.148) \\
& \\
\hline \\[-1.8ex]
Observations & 18,282 \\
Log Likelihood & $-$22,543.580 \\
Akaike Inf. Crit. & 45,141.170 \\
\hline
\hline \\[-1.8ex]
\textit{Note:} & \multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\
\end{tabular}
\end{table}
I need to publish the summary for my logistic regression model into word from R.
Any idea on how to fix this? Thanks. :)
The easiest way would be:
stargazer(EB734_May_2010_model_u, type = "text")
which will give you output in text form that you can use immediately.
Alternatively, if you want a good-looking HTML table that you can then paste into Word:
stargazer(EB734_May_2010_model_u, out = "output.html")
Don't worry if your Rmd shows a lot of code below as output, just go into your working directory after you run it, and look for a file called "output.html". You should be able to open that with Word, and then copy and paste into your document.

Knitr chunk plots within a latex table - size issues

I am writing a report within R studio using the knitr package. I am trying to succinctly describe a list of variables and there inclusion in an analysis. In order to do this I am using the long table package within latex. I have inserted a chunk into one of the table columns in order to display a histogram of some of the data. The issue is that this disrupts the width of the table column. I have tried setting the table width within the latex code but something is happening within the chunk that is over riding this.
\documentclass{article}
\usepackage{float}
\usepackage{longtable}
\begin{document}
<<ch-req, echo=FALSE,results='hide',include=FALSE>>=
require(datasets)
#
\begin{center}
\begin{longtable}{|c|p{.45\textwidth}|c|}
\caption{Summary table for variables in 'cars' data set} \label{tab:csumTab} \\
\hline \multicolumn{1}{|c|}{\textbf{Variable Original Name}} & \multicolumn{1}{c|}{\textbf{Variable Summary}} & \multicolumn{1}{c|}{\textbf{Renamed Variable}} \\ \hline\hline
\endfirsthead
\multicolumn{3}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Variable Original Name}} &
\multicolumn{1}{c|}{\textbf{Variable Summary}} &
\multicolumn{1}{c|}{\textbf{Renamed Variable}} \\ \hline
\endhead
\hline \multicolumn{3}{r}{{Continued on next page}} \\
\endfoot
\hline \hline
\endlastfoot
`speed' & numeric Speed (mph) of the car & \\
&
\begin{figure}[H]
<<histspeed1,echo=FALSE, fig=TRUE,out.width='2in', fig.align = 'left'>>=
hist(cars$speed)
#
\end{figure}
& \\
\hline
`dist' & This is the numeric stopping distance of the car (ft)& `Distance'\\
& \begin{tabular}{|c|c|c|}
\hline
min & median & max \\
\hline
2 & 36 & 120 \\
\hline
\end{tabular}& \\
\end{longtable}
\end{center}
\begin{center}
\begin{longtable}{|c|p{.45\textwidth}|c|}
\caption{Summary table for variables in `cars' data set} \label{tab:csumTab} \\
\hline \multicolumn{1}{|c|}{\textbf{Variable Original Name}} & \multicolumn{1}{c|}{\textbf{Variable Summary}} & \multicolumn{1}{c|}{\textbf{Renamed Variable}} \\ \hline\hline
\endfirsthead
\multicolumn{3}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Variable Original Name}} &
\multicolumn{1}{c|}{\textbf{Variable Summary}} &
\multicolumn{1}{c|}{\textbf{Renamed Variable}} \\ \hline
\endhead
\hline \multicolumn{3}{r}{{Continued on next page}} \\
\endfoot
\hline \hline
\endlastfoot
`speed' & numeric Speed (mph) of the car & \\
&
\begin{figure}[H]
%<<histspeed2,echo=FALSE, fig=TRUE,out.width='2in', fig.align = 'left'>>=
%hist(cars$speed)
%#
\end{figure}
& \\
\hline
`dist' & This is the numeric stopping distance of the car (ft)& `Distance'\\
& \begin{tabular}{|c|c|c|}
\hline
min & median & max \\
\hline
2 & 36 & 120 \\
\hline
\end{tabular}& \\
\end{longtable}
\end{center}
\end{document}
There are two tables just to show that the table size does work when the plot is not incorporated in the code. I have used out.width='2in' to change the size of the histogram in the table, but there is still a large area reserved for the plot by default(?). You can see this more clearly if you change fig.align = 'left' to fig.align = 'center'. I want the table to look how it does in the second example but with the plot incorporated.
Any help greatly appreciated.

Remove additional footnote from R's xtable() table output in LaTeX

I am using the following R code to call xtable and generate a LaTeX table for a Sweave document.
ifelse(LaTeX==1, print(xtable(rule1.results.noTC, caption="Rule 1 Results 0 Transaction Costs",
digits=c(1,2,4,4,4), display=c("d","d","f","f","f"))),
print(rule1.results))
This produces the following LaTeX
% latex table generated in R 3.0.1 by xtable 1.7-1 package
% Sun Jul 28 16:54:42 2013
\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
\hline
& L & profits & annCumulExReturn & sharpe \\
\hline
1 & 5 & -888.8215 & -0.1501 & -4.3939 \\
2 & 10 & -909.8941 & -0.1533 & -6.8882 \\
3 & 20 & -893.6245 & -0.1509 & -6.9081 \\
4 & 40 & -865.6764 & -0.1466 & -9.8462 \\
5 & 80 & -832.4700 & -0.1417 & -11.7260 \\
6 & 160 & -757.0690 & -0.1305 & -16.3088 \\
7 & 320 & -626.9162 & -0.1118 & -31.6134 \\
8 & 640 & -340.8740 & -0.0730 & -44.2321 \\
\hline
\end{tabular}
\caption{Rule 1 Results with Transaction Costs}
\end{table}
When I convert this to pdf, I get a nice table. However, it is followed by a weird note:
[1] "
And I get several of these if I plot multiple tables in a row. How can I eliminate this either via R's xtable or by editing the LaTeX code.
Thanks
I can't say for sure without your data and an example of the .tex file, but I'm pretty confident this is due to your use of ifelse. I imagine the following will not give you the weird print out:
if(LaTeX==1) {
print(xtable(rule1.results.noTC,caption="Rule 1 Results 0 Transaction Costs",
digits=c(1,2,4,4,4), display=c("d","d","f","f","f")))
} else {
print(rule1.results))
}
This is because ifelse returns its result, which you're also printing. See, for example:
> ifelse(TRUE,print("true"),print("false"))
[1] "true"
[1] "true"

Resources