--- /dev/null
+\name{xtableMatharray}\r
+\alias{xtableMatharray}\r
+\r
+\title{\r
+ Create LaTeX Mathematical Array\r
+}\r
+\description{\r
+ Convert an array of numbers or mathematical expressions into an\r
+ \code{xtableMatharray} object so it can be printed. A convenience\r
+ function to enable the printing of arrays in mathematical expressions\r
+ in LaTeX\r
+}\r
+\usage{\r
+xtableMatharray(x, caption = NULL, label = NULL, align = NULL,\r
+ digits = NULL, display = NULL, auto = FALSE, ...)\r
+}\r
+\arguments{\r
+ \item{x}{A numeric or character matrix.}\r
+ \item{caption}{Character vector of length 1 or 2 containing the\r
+ table's caption or title. If length is 2, the second item is the\r
+ "short caption" used when LaTeX generates a "List of Tables". Set to\r
+ \code{NULL} to suppress the caption. Default value is \code{NULL}.\r
+ Included here only for consistency with \code{xtable} methods. Not\r
+ expected to be of use.}\r
+ \item{label}{Character vector of length 1 containing the LaTeX\r
+ label. Set to \code{NULL} to suppress the label.\r
+ Default value is \code{NULL}. }\r
+ \item{align}{Character vector of length equal to the number of columns\r
+ of the resulting table, indicating the alignment of the corresponding\r
+ columns. Also, \code{"|"} may be used to produce vertical lines\r
+ between columns in LaTeX tables, but these are effectively ignored\r
+ when considering the required length of the supplied vector. If a\r
+ character vector of length one is supplied, it is split as\r
+ \code{strsplit(align, "")[[1]]} before processing. Since the row\r
+ names are printed in the first column, the length of \code{align} is\r
+ one greater than \code{ncol(x)} if \code{x} is a\r
+ \code{data.frame}. Use \code{"l"}, \code{"r"}, and \code{"c"} to\r
+ denote left, right, and center alignment, respectively. Use\r
+ \code{"p{3cm}"} etc. for a LaTeX column of the specified width. For\r
+ HTML output the \code{"p"} alignment is interpreted as \code{"l"},\r
+ ignoring the width request. Default depends on the class of\r
+ \code{x}. }\r
+ \item{digits}{Numeric vector of length equal to one (in which case it\r
+ will be replicated as necessary) or to the number of columns of the\r
+ resulting table \bold{or} matrix of the same size as the resulting\r
+ table, indicating the number of digits to display in the\r
+ corresponding columns. Since the row names are printed in the first\r
+ column, the length of the vector \code{digits} or the number of\r
+ columns of the matrix \code{digits} is one greater than\r
+ \code{ncol(x)} if \code{x} is a \code{data.frame}. Default depends\r
+ on the class of \code{x}. If values of \code{digits} are negative,\r
+ the corresponding values of \code{x} are displayed in scientific\r
+ format with \code{abs(digits)} digits.}\r
+ \item{display}{\r
+ Character vector of length equal to the number of columns of the\r
+ resulting table, indicating the format for the corresponding columns.\r
+ Since the row names are printed in the first column, the length of\r
+ \code{display} is one greater than \code{ncol(x)} if \code{x} is a\r
+ \code{data.frame}. These values are passed to the \code{formatC}\r
+ function. Use \code{"d"} (for integers), \code{"f"}, \code{"e"},\r
+ \code{"E"}, \code{"g"}, \code{"G"}, \code{"fg"} (for reals), or\r
+ \code{"s"} (for strings). \code{"f"} gives numbers in the usual\r
+ \code{xxx.xxx} format; \code{"e"} and \code{"E"} give\r
+ \code{n.ddde+nn} or \code{n.dddE+nn} (scientific format); \code{"g"}\r
+ and \code{"G"} put \code{x[i]} into scientific format only if it\r
+ saves space to do so. \code{"fg"} uses fixed format as \code{"f"},\r
+ but \code{digits} as number of \emph{significant} digits. Note that\r
+ this can lead to quite long result strings. Default depends on the\r
+ class of \code{x}.}\r
+ \item{auto}{\r
+ Logical, indicating whether to apply automatic format when no value\r
+ is passed to \code{align}, \code{digits}, or \code{display}. This\r
+ \sQuote{autoformat} (based on \code{xalign}, \code{xdigits}, and\r
+ \code{xdisplay}) can be useful to quickly format a typical\r
+ \code{matrix} or \code{data.frame}. Default value is \code{FALSE}.}\r
+ \item{...}{Additional arguments. (Currently ignored.)}\r
+}\r
+\details{\r
+ This function is only usable for production of LaTeX documents, not\r
+ HTML.\r
+\r
+ Creates an object of class\r
+ \code{c("xtableMatharray","xtable","data.frame")}, to ensure that it is\r
+ printed by the print method \code{print.xtableMatharray}.\r
+}\r
+\value{\r
+ An object of class \code{c("xtableMatharray","xtable","data.frame")}.\r
+}\r
+\r
+\author{\r
+ David Scott <d.scott@auckland.ac.nz>\r
+}\r
+\seealso{\r
+\code{\link{print.xtableMatharray}}\r
+}\r
+\examples{\r
+V <- matrix(c(1.140380e-03, 3.010497e-05, 7.334879e-05,\r
+ 3.010497e-05, 3.320683e-04, -5.284854e-05,\r
+ 7.334879e-05, -5.284854e-05, 3.520928e-04), nrow = 3)\r
+mth <- xtableMatharray(V)\r
+class(mth)\r
+str(mth)\r
+unclass(mth)\r
+}\r
+\keyword{ print }\r
First load the package and create some objects.\r
<<dataspdep>>=\r
library(spdep)\r
-data(oldcol)\r
-COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD[], \r
+data("oldcol", package = "spdep")\r
+COL.lag.eig <- lagsarlm(CRIME ~ INC + HOVAL, data = COL.OLD[],\r
nb2listw(COL.nb))\r
class(COL.lag.eig)\r
COL.errW.GM <- GMerrorsar(CRIME ~ INC + HOVAL, data = COL.OLD,\r
- nb2listw(COL.nb, style = "W"), \r
+ nb2listw(COL.nb, style = "W"),\r
returnHcov = TRUE)\r
class(COL.errW.GM)\r
-COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD, \r
+COL.lag.stsls <- stsls(CRIME ~ INC + HOVAL, data = COL.OLD,\r
nb2listw(COL.nb))\r
class(COL.lag.stsls)\r
\r
-p1 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,], \r
+p1 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,],\r
listw = nb2listw(COL.nb))\r
class(p1)\r
-p2 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,], \r
+p2 <- predict(COL.lag.eig, newdata = COL.OLD[45:49,],\r
pred.type = "trend", type = "trend")\r
#type option for retrocompatibility with spdep 0.5-92\r
class(p2)\r
There is an \code{xtable} method for objects of this type.\r
<<xtablesarlm, results = 'asis'>>=\r
xtable(COL.lag.eig)\r
-@ %def \r
+@ %def\r
\r
The method for \code{xtable} actually uses the summary of the object,\r
and an identical result is obtained when using the summary of the\r
\r
<<xtablegmsar, results = 'asis'>>=\r
xtable(COL.errW.GM)\r
-@ %def \r
+@ %def\r
\r
\subsubsection{\code{stsls} objects}\r
\label{sec:codestsls-objects}\r
\r
<<xtablestsls, results = 'asis'>>=\r
xtable(COL.lag.stsls)\r
-@ %def \r
+@ %def\r
\r
\subsubsection{\code{sarlm.pred} objects}\r
\label{sec:codesarlmpred-objects}\r
\r
<<xtablesarlmpred, results = 'asis'>>=\r
xtable(p1)\r
-@ %def \r
+@ %def\r
\r
This method transforms the \code{sarlm.pred} objects into data frames, allowing any number of attributes vectors which may vary according to predictor types.\r
\r
\r
<<xtablelagimpactexact, results = 'asis'>>=\r
xtable(imp.exact)\r
-@ %def \r
+@ %def\r
\r
\p\r
<<xtablelagimpactmcmc, results = 'asis'>>=\r
xtable(imp.sim)\r
-@ %def \r
+@ %def\r
\r
\r
\subsubsection{\code{spautolm} objects}\r
\p\r
<<spautolmclass>>=\r
class(spautolmOBJECT)\r
-@ %def \r
+@ %def\r
\r
\r
<<xtablespautolm, results = 'asis'>>=\r
xtable(spautolmOBJECT,\r
display = c("s",rep("f", 3), "e"), digits = 4)\r
-@ %def \r
+@ %def\r
\r
\r
\r
First load the package and create some objects.\r
<<datasplm>>=\r
library(splm)\r
-data(Produc, package = "plm")\r
-data(usaww)\r
+data("Produc", package = "plm")\r
+data("usaww", package = "splm")\r
fm <- log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp\r
respatlag <- spml(fm, data = Produc, listw = mat2listw(usaww),\r
model="random", spatial.error="none", lag=TRUE)\r
\r
<<xtablesplm, results = 'asis'>>=\r
xtable(respatlag)\r
-@ %def \r
+@ %def\r
\r
\r
\p\r
<<xtablesplm1, results = 'asis'>>=\r
xtable(GM)\r
-@ %def \r
+@ %def\r
\r
The \code{xtable} method works the same on impacts of \code{splm} models.\r
\r
<<xtablesplmimpacts, results = 'asis'>>=\r
xtable(imp.spml)\r
-@ %def \r
+@ %def\r
\r
\subsection{The package \pkg{sphet}}\r
\label{sec:package-pkgsphet}\r
First load the package and create some objects.\r
<<datasphet>>=\r
library(sphet)\r
-data(columbus)\r
+data("columbus", package = "spdep")\r
listw <- nb2listw(col.gal.nb)\r
-data(coldis)\r
-res.stsls <- stslshac(CRIME ~ HOVAL + INC, data = columbus, listw = listw, \r
+data("coldis", package = "sphet")\r
+res.stsls <- stslshac(CRIME ~ HOVAL + INC, data = columbus, listw = listw,\r
distance = coldis, type = 'Triangular')\r
class(res.stsls)\r
\r
\r
<<xtablesphet, results = 'asis'>>=\r
xtable(res.stsls)\r
-@ %def \r
+@ %def\r
\r
\p\r
<<xtablesphet1, results = 'asis'>>=\r
xtable(res.gstsls)\r
-@ %def \r
+@ %def\r
\r
\code{sphet} also provides a method for computing impacts.\r
\r
<<xtablesphetimpacts, results = 'asis'>>=\r
xtable(imp.gstsls)\r
-@ %def \r
+@ %def\r
\r
\end{document}\r