Question

I wonder how to use stargazer for systemfit objects. My working example is below which gives two different tables rather than one.

library("systemfit")
data("Kmenta")
eqDemand <- consump ~ price + income
eqSupply <- consump ~ price + farmPrice + trend
eqSystem <- list(demand = eqDemand, supply = eqSupply)
fitols   <- systemfit(eqSystem, data=Kmenta)
fitsur <- systemfit(eqSystem, method = "SUR", data=Kmenta)

library(stargazer)

stargazer(
      coef(fitols)
    , coef(fitsur)
    , title="Regression Results"
    , align=TRUE
  )
Was it helpful?

Solution

It can be done using texreg function from texreg package:

texreg(list(fitols, fitsur))

\begin{table}
\begin{center}
\begin{tabular}{l c c c c }
\hline
            & Model 1 & Model 2 & NA & NA \\
\hline
(Intercept) & $99.90^{***}$ & $58.28^{***}$ & $99.33^{***}$ & $61.97^{***}$ \\
            & $(7.52)$      & $(11.46)$     & $(7.51)$      & $(11.08)$     \\
price       & $-0.32^{**}$  & $0.16$        & $-0.28^{**}$  & $0.15$        \\
            & $(0.09)$      & $(0.09)$      & $(0.09)$      & $(0.09)$      \\
income      & $0.33^{***}$  &               & $0.30^{***}$  &               \\
            & $(0.05)$      &               & $(0.04)$      &               \\
farmPrice   &               & $0.25^{***}$  &               & $0.21^{***}$  \\
            &               & $(0.05)$      &               & $(0.04)$      \\
trend       &               & $0.25^{*}$    &               & $0.34^{***}$  \\
            &               & $(0.10)$      &               & $(0.07)$      \\
\hline
R$^2$       & 0.76          & 0.65          & 0.76          & 0.61          \\
Adj. R$^2$  & 0.74          & 0.59          & 0.73          & 0.54          \\
Num. obs.   & 40            & 40            & 40            & 40            \\
\hline
\multicolumn{5}{l}{\scriptsize{$^{***}p<0.001$, $^{**}p<0.01$, $^*p<0.05$}}
\end{tabular}
\caption{Statistical models}
\label{table:coefficients}
\end{center}
\end{table}

OTHER TIPS

Not supported yet, but planned for a future release. If you have any suggestion regarding what the final table should look like (and/or what is important in systemfit regression table output), please e-mail stargazer's author.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top