/
print.summary.slmfit.R
90 lines (78 loc) · 3 KB
/
print.summary.slmfit.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#' Prints the summary of a fitted spatial linear model.
#'
#' This function uses the object that is output from
#' \code{\link{summary.slmfit}()}.
#'
#' @param x is an summary object generated from
#' \code{\link{summary.slmfit}()}
#' @param digits is the number of digits to be displayed in the
#' model output
#' @param signif.stars is an option to show which predictors
#' are significant.
#' @param ... further arguments passed to or from other methods.
#' @return a list with \itemize{
#' \item model formula
#' \item summary statistics for the residuals.
#' \item a table of fixed effects estimates and associated standard errors.
#' \item estimated spatial covariance parameter estimates.
#' \item generalized r-squared value.
#' }
#' @examples
#' data(exampledataset) ## load a toy data set
#' slmobj <- slmfit(formula = counts ~ pred1 + pred2, data = exampledataset,
#' xcoordcol = 'xcoords', ycoordcol = 'ycoords', areacol = 'areavar')
#' print(summary(slmobj))
#' @export
print.summary.slmfit <- function(x,
digits = max(3L, getOption("digits") - 3L),
signif.stars = getOption("show.signif.stars"), ...) {
cat("\nCall:\n", paste(deparse(x$catCall),
sep = "\n", collapse = "\n"),
"\n", sep = "")
cat("\nResiduals:\n")
resQ <- c(min(x$Residuals), stats::quantile(x$Residuals,
p = c(0.25, 0.5, 0.75),
na.rm = TRUE), max(x$Residuals))
names(resQ) <- c("Min", "1Q", "Median", "3Q", "Max")
print(resQ, digits = digits)
cat("\nCoefficients:\n")
coefs <- x$FixedEffects
colnames(coefs) <- c("Estimate", "Std. Error", "t value", "Pr(>|t|)")
stats::printCoefmat(coefs, digits = digits, signif.stars = signif.stars,
na.print = "NA", ...)
cat("\nCovariance Parameters:\n")
print(x$CovarianceParms)
cat("\nGeneralized R-squared:", x$GeneralizedR2,"\n")
}
#' Prints the fitted coefficient table of a fitted spatial linear model.
#'
#' This function uses the object that is output from
#' \code{\link{slmfit}()} of class \code{slmfit}.
#'
#' @param x is an object generated from \code{\link{slmfit}()}
#' @param digits is the number of digits to be displayed in the
#' model output
#' @param ... further arguments passed to or from other methods.
#' @return a list with \itemize{
#' \item model formula
#' \item summary statistics for the residuals.
#' \item a table of fixed effects estimates and associated standard errors.
#' \item estimated spatial covariance parameter estimates.
#' \item generalized r-squared value.
#' }
#' @examples
#' data(exampledataset) ## load a toy data set
#' slmobj <- slmfit(formula = counts ~ pred1 + pred2, data = exampledataset,
#' xcoordcol = 'xcoords', ycoordcol = 'ycoords', areacol = 'areavar')
#' print(slmobj)
#' @export
print.slmfit <- function(x,
digits = max(3L, getOption("digits") - 3L),
...) {
cat("\nCoefficients:\n")
coefs <- x$CoefficientEsts
names(coefs) <- x$PredictorNames
print(coefs, digits = digits)
cat("\nCovariance Parameters:\n")
print(x$SpatialParmEsts, digits = digits)
}