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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# A copy of the GNU General Public License is available at
# http://www.r-project.org/Licenses/
summary.sysGmm <- function(object, ...)
{
z <- object
se <- sqrt(diag(z$vcov))
k <- attr(z$dat, "k")
if (attr(z$dat, "sysInfo")$commonCoef)
{
seList <- rep(list(se), length(z$dat))
} else {
seList <- list()
for (i in 1:length(z$dat))
{
seList[[i]] <- se[1:k[[i]]]
se <- se[-(1:k[[i]])]
}
}
par <- z$coefficients
tval <- lapply(1:length(z$dat), function(i) par[[i]]/seList[[i]])
ans <- list(met=z$met,kernel=z$kernel,algo=z$algo,call=z$call)
names(ans$met) <- "GMM method"
names(ans$kernel) <- "kernel for cov matrix"
ans$coefficients <- lapply(1:length(z$dat), function(i) cbind(par[[i]],seList[[i]], tval[[i]], 2 * pnorm(abs(tval[[i]]), lower.tail = FALSE)))
ans$stest <- specTest(z)
ans$algoInfo <- z$algoInfo
ans$initTheta <- object$initTheta
for (i in 1:length(z$dat))
{
dimnames(ans$coefficients[[i]]) <- list(names(z$coefficients[[i]]),
c("Estimate", "Std. Error", "t value", "Pr(>|t|)"))
names(ans$initTheta[[i]]) <- names(z$coefficients[[i]])
}
ans$specMod <- object$specMod
ans$bw <- attr(object$w0,"Spec")$bw
ans$weights <- attr(object$w0,"Spec")$weights
ans$Sysnames <- names(z$dat)
ans$met <- attr(object$dat, "sysInfo")$typeDesc
if(object$infVcov != "HAC")
ans$kernel <- NULL
class(ans) <- "summary.sysGmm"
ans
}
print.summary.sysGmm <- function(x, digits = 5, ...)
{
cat("\nCall:\n")
cat(paste(deparse(x$call), sep="\n", collapse = "\n"), "\n\n", sep="")
cat("Method\n", x$met,"\n\n")
cat("\n")
if( !is.null(x$kernel))
{
cat("Kernel: ", x$kernel)
if (!is.null(x$bw))
cat("(with bw = ", round(x$bw,5),")\n\n")
else
cat("\n\n")
}
cat("Coefficients:\n")
m <- length(x$coefficients)
for (i in 1:m)
{
cat(x$Sysnames[i], "\n")
cat("#########\n")
#print.default(format(x$coefficients[[i]], digits=digits),
# print.gap = 2, quote = FALSE)
printCoefmat(x$coefficients[[i]], digits=digits, ...)
cat("\n")
}
cat(x$stest$ntest,"\n")
print.default(format(x$stest$test, digits=digits),
print.gap = 2, quote = FALSE)
cat("\n")
if(!is.null(x$initTheta))
{
cat("Initial values of the coefficients\n")
for (i in 1:m)
{
cat(x$Sysnames[i], "\n")
print(x$initTheta[[i]])
}
cat("\n")
}
cat(x$specMod)
if(!is.null(x$algoInfo))
{
cat("#############\n")
cat("Information related to the numerical optimization\n")
}
if(!is.null(x$algoInfo$convergence))
cat("Convergence code = ", x$algoInfo$convergence,"\n")
if(!is.null(x$algoInfo$counts))
{
cat("Function eval. = ",x$algoInfo$counts[1],"\n")
cat("Gradian eval. = ",x$algoInfo$counts[2],"\n")
}
if(!is.null(x$algoInfo$message))
cat("Message: ",x$algoInfo$message,"\n")
invisible(x)
}
print.sysGmm <- function(x, digits=5, ...)
{
cat("Method\n", attr(x$dat, "sysInfo")$typeDesc,"\n\n")
cat("Objective function value: ",x$objective,"\n\n")
for (i in 1:length(x$coefficients))
{
cat(names(x$dat)[[i]], ": \n")
print.default(format(coef(x)[[i]], digits=digits),
print.gap = 2, quote = FALSE)
}
cat("\n")
if(!is.null(x$algoInfo$convergence))
cat("Convergence code = ", x$algoInfo$convergence,"\n")
cat(x$specMod)
invisible(x)
}
|