1 %\VignetteIndexEntry{xtable List of Tables Gallery}
\r
2 %\VignetteDepends{xtable, spdep, splm, sphet}
\r
3 %\VignetteKeywords{LaTeX, HTML, table}
\r
4 %\VignettePackage{xtable}
\r
6 % \VignetteEngine{knitr::knitr}
\r
7 %**************************************************************************
\r
8 \documentclass{article}
\r
9 \usepackage[a4paper, height=24cm]{geometry} % geometry first
\r
11 \usepackage{booktabs}
\r
12 \usepackage{longtable}
\r
13 \usepackage{parskip}
\r
14 \usepackage{rotating}
\r
15 \usepackage{tabularx}
\r
16 \usepackage{titlesec}
\r
17 \usepackage{hyperref} % hyperref last
\r
18 \titleformat\subsubsection{\bfseries\itshape}{}{0pt}{}
\r
19 \newcommand\p{\vspace{2ex}}
\r
20 \newcommand\code[1]{\texttt{#1}}
\r
21 \newcommand\pkg[1]{\textbf{#1}}
\r
22 \setcounter{tocdepth}{2}
\r
25 \title{\bfseries\Large The Other Packages Gallery}
\r
26 \author{\bfseries David J. Scott}
\r
33 \section{Introduction}
\r
34 This document represents a test of the functions in \pkg{xtable} which
\r
35 deal with other packages
\r
37 <<set, include=FALSE>>=
\r
39 opts_chunk$set(fig.path = 'Figures/other', debug = TRUE, echo = TRUE)
\r
40 opts_chunk$set(out.width = '0.9\\textwidth')
\r
43 The first step is to load the package and set some options for this document.
\r
44 <<package, results='asis'>>=
\r
46 options(xtable.floating = FALSE)
\r
47 options(xtable.timestamp = "")
\r
51 \section{The packages \pkg{spdep}, \pkg{splm}, and \pkg{sphet}}
\r
53 Code for supporting these packages and most of the examples used in
\r
54 this section was originally provided by Martin Gubri
\r
55 (\url{martin.gubri@framasoft.org}).
\r
57 \subsection{The package \pkg{spdep}}
\r
58 \label{sec:package-pkgspdep}
\r
60 First load the package and create some objects.
\r
64 COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD,
\r
67 COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = COL.OLD,
\r
68 nb2listw(COL.nb, style = "W"),
\r
71 COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD,
\r
73 class(COL.lag.stsls)
\r
77 \subsubsection{\code{sarlm} objects}
\r
78 \label{sec:codesarlm-objects}
\r
80 There is an \code{xtable} method for objects of this type.
\r
81 <<xtablesarlm, results = 'asis'>>=
\r
85 The method for \code{xtable} actually uses the summary of the object,
\r
86 and an identical result is obtained when using the summary of the
\r
87 object, even if the summary contains more additional information.
\r
89 <<xtablesarlmsumm, results = 'asis'>>=
\r
90 xtable(summary(COL.lag.eig, correlation = TRUE))
\r
93 This same pattern applies to the other objects from this group of packages.
\r
95 Note that additional prettying of the resulting table is possible, as
\r
96 for any table produced using \code{xtable}. For example using the
\r
97 \pkg{booktabs} package we get:
\r
99 <<xtablesarlmbooktabs, results = 'asis'>>=
\r
100 print(xtable(COL.lag.eig), booktabs = TRUE)
\r
103 \subsubsection{\code{gmsar} objects}
\r
104 \label{sec:codegmsar-objects}
\r
107 <<xtablegmsar, results = 'asis'>>=
\r
108 xtable(COL.errW.GM)
\r
111 \subsubsection{\code{stsls} objects}
\r
112 \label{sec:codestsls-objects}
\r
115 <<xtablestsls, results = 'asis'>>=
\r
116 xtable(COL.lag.stsls)
\r
121 \subsubsection{\code{spautolm} objects}
\r
122 \label{sec:codespautolm-objects}
\r
124 The need for an \code{xtable} method for \code{spautolm} was expressed
\r
125 by Guido Schulz (\url{schulzgu@student.hu-berlin.de}), who also
\r
126 provided an example of an object of this type. The required code was
\r
127 implemented by David Scott (\url{d.scott@auckland.ac.nz}).
\r
129 First create an object of the required type
\r
131 <<minimalexample, results = 'hide'>>=
\r
134 spautolmOBJECT <- spautolm(Z ~ PEXPOSURE + PCTAGE65P,data = nydata,
\r
135 listw = listw_NY, family = "SAR",
\r
136 method = "eigen", verbose = TRUE)
\r
137 summary(spautolmOBJECT, Nagelkerke = TRUE)
\r
142 class(spautolmOBJECT)
\r
146 <<xtablespautolm, results = 'asis'>>=
\r
147 xtable(spautolmOBJECT,
\r
148 display = c("s",rep("f", 3), "e"), digits = 4)
\r
153 \subsection{The package \pkg{splm}}
\r
154 \label{sec:package-pkgsplm}
\r
156 First load the package and create some objects.
\r
159 data(Produc, package = "plm")
\r
161 fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp
\r
162 fespaterr <- spml(fm, data = Produc, listw = mat2listw(usaww),
\r
163 model = "within", spatial.error = "b", Hess = FALSE)
\r
165 GM <- spgm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc,
\r
166 listw = usaww, moments = "fullweights", spatial.error = TRUE)
\r
171 \subsubsection{\code{splm} objects}
\r
172 \label{sec:codesplm-objects}
\r
174 <<xtablesplm, results = 'asis'>>=
\r
180 <<xtablesplm1, results = 'asis'>>=
\r
185 \subsection{The package \pkg{sphet}}
\r
186 \label{sec:package-pkgsphet}
\r
188 First load the package and create some objects.
\r
192 listw <- nb2listw(col.gal.nb)
\r
194 res.stsls <- stslshac(CRIME ~ HOVAL + INC, data = columbus, listw = listw,
\r
195 distance = coldis, type = 'Triangular')
\r
198 res.gstsls <- gstslshet(CRIME ~ HOVAL + INC, data = columbus, listw = listw)
\r
203 \subsubsection{\code{sphet} objects}
\r
204 \label{sec:codesphet-objects}
\r
206 <<xtablesphet, results = 'asis'>>=
\r
211 <<xtablesphet1, results = 'asis'>>=
\r