Functions to format various objects following model selection and
multimodel inference to LaTeX or HTML tables. These functions extend the
methods from the xtable
package (Dahl 2014).
# S3 method for aictab
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, include.AICc = TRUE,
include.LL = TRUE, include.Cum.Wt = FALSE, ...)# S3 method for anovaOD
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, ...)
# S3 method for bictab
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, include.BIC = TRUE, include.LL = TRUE,
include.Cum.Wt = FALSE, ...)
# S3 method for boot.wt
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, include.AICc = TRUE, include.AICcWt = FALSE, ...)
# S3 method for countDist
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, table.countDist = "distance", ...)
# S3 method for checkParms
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, include.variable = TRUE, include.max.se =
TRUE, include.n.high.se = TRUE, ...)
# S3 method for countHist
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, table.countHist = "count", ...)
# S3 method for detHist
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, table.detHist = "freq", ...)
# S3 method for detTime
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, table.detTime = "freq", ...)
# S3 method for dictab
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, include.DIC = TRUE, include.Cum.Wt = FALSE, ...)
# S3 method for ictab
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE, nice.names = TRUE,
include.IC = TRUE, include.Cum.Wt = FALSE, ...)
# S3 method for mb.chisq
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE, nice.names = TRUE,
include.detection.histories = TRUE, ...)
# S3 method for modavg
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE, nice.names = TRUE,
print.table = FALSE, ...)
# S3 method for modavgCustom
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, print.table = FALSE, ...)
# S3 method for modavgEffect
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, print.table = FALSE, ...)
# S3 method for modavgIC
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE, nice.names = TRUE,
print.table = FALSE, ...)
# S3 method for modavgPred
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, ...)
# S3 method for modavgShrink
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, print.table = FALSE, ...)
# S3 method for multComp
xtable(x, caption = NULL, label = NULL,
align = NULL, digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, print.table = FALSE, ...)
# S3 method for summaryOD
xtable(x, caption = NULL, label = NULL, align = NULL,
digits = NULL, display = NULL, auto = FALSE,
nice.names = TRUE, ...)
an object of class aictab
, anovaOD
, bictab
,
boot.wt
, checkParms
, countDist
,
countHist
, detHist
, detTime
, dictab
,
ictab
, mb.chisq
, modavg
, modavgEffect
,
modavgCustom
, modavgIC
, modavgPred
,
modavgShrink
, multComp
, or summaryOD
.
a character vector of length 1 or 2 storing the caption or title of
the table. If the vector is of length 2, the second item is the
short caption used when LaTeX generates a list of tables. The
default value is NULL
and suppresses the caption.
a character vector storing the LaTeX label or HTML anchor. The default
value is NULL
and suppresses the label.
a character vector of length equal to the number of columns of the table specifying the alignment of the elements. Note that the rownames are considered as an additional column and require an alignment value.
a numeric vector of length one or equal to the number of columns in the table (including the rownames) specifying the number of digits to display in each column.
a character vector of length equal to the number of columns
(including the rownames) specifying the format of each column. For
example, use s
for strings, f
for numbers in the
regular format, or d
for integers. See formatC
for
additional possible values.
Logical, indicating whether to apply automatic format when no value
is passed to align
, digits
, or display
. This
autoformat
(based on xalign
, xdigits
, and xdisplay
)
can be useful to quickly format a typical matrix
or
data.frame
. Default value is FALSE
.
logical. If TRUE
, column labels are modified to improve their
appearance in the table. If FALSE
, simpler labels are used,
or the ones supplied directly by the user in the object storing the
output.
logical. If TRUE
, the column containing
the information criterion (AIC, AICc, QAIC, or QAICc) of each model
is printed in the table. If FALSE
, the column is
suppressed.
logical. If TRUE
, the column containing
the information criterion (BIC or QBIC) of each model is printed in
the table. If FALSE
, the column is suppressed.
logical. If TRUE
, the column containing
the deviance information criterion (DIC) of each model is printed in
the table. If FALSE
, the column is suppressed.
logical. If TRUE
, the column containing
the information criterion of each model is printed in the table. If
FALSE
, the column is suppressed.
logical. If TRUE
, the column containing the
log-likelihood of each model is printed in the table. If
FALSE
, the column is suppressed.
logical. If TRUE
, the column containing
the cumulative Akaike weights is printed in the table. If
FALSE
, the column is suppressed.
logical. If TRUE
, the column containing
the Akaike weight of each model is printed in the table. If
FALSE
, the column is suppressed.
logical. If TRUE
, the
column containing detection histories is printed in the table. If
FALSE
, the column is suppressed.
logical. If TRUE
, the
column containing the variable name is printed in the table. If
FALSE
, the column is suppressed.
logical. If TRUE
, the
column containing the maximum SE in the model is printed in the
table. If FALSE
, the column is suppressed.
logical. If TRUE
, the
column containing the number of SE's greater than the threshold
specified by the user is printed in the table. If FALSE
,
the column is suppressed.
logical. If TRUE
, the model selection table
is printed and other sections of the output are suppressed (e.g.,
model-averaged estimates). If FALSE
, the model selection
table is suppressed and only the other portion of the output is
printed in the table.
character string specifying, either "freq"
,
"prop"
, or "hist"
. If table.type = "freq"
, the
function returns a table of frequencies of sites sampled, of sites with
at least one detection, and for data with multiple primary periods,
the frequencies of sites with observed extinctions and colonizations.
If table.type = "prop"
, the table returns the proportion of
sites with at least one detection, and for data with multiple periods,
the proportion of sites with observed extinctions and colonizations.
If table.type = "hist"
, the function returns the frequencies of
each observed detection history.
character string specifying, either "freq"
,
"prop"
, or "dist"
. If table.type = "freq"
, the
function returns a table of frequencies of sites sampled, of sites with
at least one detection, and for data with multiple primary periods,
the frequencies of sites with observed extinctions and colonizations.
If table.type = "prop"
, the table returns the proportion of
sites with at least one detection, and for data with multiple periods,
the proportion of sites with observed extinctions and colonizations.
If table.type = "dist"
, the function returns the quantiles of
detection times.
character string specifying, either
"distance"
, "count"
, "freq"
, or "prop"
. If
table.type = "distance"
, the function returns a table of counts
summarized for each distance class. If table.type = "count"
,
the function returns the table of frequencies of counts observed
across sites. If table.type = "freq"
, the function returns a
table of frequencies of sites sampled, of sites with at least one
detection, and for data with multiple primary periods, the frequencies
of sites with observed extinctions and colonizations. If
table.type = "prop"
, the table returns the proportion of sites
with at least one detection, and for data with multiple periods, the
proportion of sites with observed extinctions and colonizations.
character string specifying, either
"count"
, "freq"
, "prop"
, or "hist"
. If
table.type = "count"
, the function returns the table of
frequencies of counts observed across sites. If table.type =
"freq"
, the function returns a table of frequencies of sites sampled,
of sites with at least one detection, and for data with multiple
primary periods, the frequencies of sites with observed extinctions
and colonizations. If table.type = "prop"
, the table returns
the proportion of sites with at least one detection, and for data with
multiple periods, the proportion of sites with observed extinctions
and colonizations. If table.type = "hist"
, the function
returns the frequencies of each observed count history.
additional arguments passed to the function.
Marc J. Mazerolle
xtable
creates an object of the xtable
class inheriting
from the data.frame
class. This object can then be used with
print.xtable
for added flexibility such as suppressing row names,
modifying caption placement, and format tables in LaTeX or HTML
format.
Dahl, D. B. (2014) xtable: Export tables to LaTeX or HTML. R package version 1.7-3. https://cran.r-project.org/package=xtable.
aictab
, boot.wt
, dictab
,
formatC
, ictab
, mb.chisq
,
modavg
, modavgCustom
,
modavgIC
, modavgEffect
,
modavgPred
, modavgShrink
,
multComp
, summaryOD
, anovaOD
,
xtable
, print.xtable
if(require(xtable)) {
##model selection example
data(dry.frog)
##setup candidate models
Cand.models <- list( )
Cand.models[[1]] <- lm(log_Mass_lost ~ Shade + Substrate +
cent_Initial_mass + Initial_mass2,
data = dry.frog)
Cand.models[[2]] <- lm(log_Mass_lost ~ Shade + Substrate +
cent_Initial_mass + Initial_mass2 +
Shade:Substrate, data = dry.frog)
Cand.models[[3]] <- lm(log_Mass_lost ~ cent_Initial_mass +
Initial_mass2, data = dry.frog)
Model.names <- c("additive", "interaction", "no shade")
##model selection table - AICc
out <- aictab(cand.set = Cand.models, modnames = Model.names)
xtable(out)
##exclude AICc and LL
xtable(out, include.AICc = FALSE, include.LL = FALSE)
##remove row names and add caption
print(xtable(out, caption = "Model selection based on AICc"),
include.rownames = FALSE, caption.placement = "top")
##model selection table - BIC
out2 <- bictab(cand.set = Cand.models, modnames = Model.names)
xtable(out2)
##exclude AICc and LL
xtable(out2, include.BIC = FALSE, include.LL = FALSE)
##remove row names and add caption
print(xtable(out2, caption = "Model selection based on BIC"),
include.rownames = FALSE, caption.placement = "top")
##model-averaged estimate of Initial_mass2
mavg.mass <- modavg(cand.set = Cand.models, parm = "Initial_mass2",
modnames = Model.names)
#model-averaged estimate
xtable(mavg.mass, print.table = FALSE)
#table with contribution of each model
xtable(mavg.mass, print.table = TRUE)
##model-averaged predictions for first 10 observations
preds <- modavgPred(cand.set = Cand.models, modnames = Model.names,
newdata = dry.frog[1:10, ])
xtable(preds)
}
##example of diagnostics
if (FALSE) {
if(require(unmarked)){
##distance sampling example from ?distsamp
data(linetran)
ltUMF <- with(linetran, {
unmarkedFrameDS(y = cbind(dc1, dc2, dc3, dc4),
siteCovs = data.frame(Length, area, habitat),
dist.breaks = c(0, 5, 10, 15, 20),
tlength = linetran$Length * 1000, survey = "line",
unitsIn = "m")
})
##summarize counts across distance classes
xtable(countDist(ltUMF), table.countDist = "distance")
##summarize counts across all sites
xtable(countDist(ltUMF), table.countDist = "count")
##Half-normal detection function
fm1 <- distsamp(~ 1 ~ 1, ltUMF)
##determine parameters with highest SE's
xtable(checkParms(fm1))
}
}
Run the code above in your browser using DataLab