[Gmm-commits] r65 - in pkg/gmmExtra: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 13 20:44:08 CET 2012


Author: chaussep
Date: 2012-11-13 20:44:08 +0100 (Tue, 13 Nov 2012)
New Revision: 65

Modified:
   pkg/gmmExtra/NAMESPACE
   pkg/gmmExtra/R/KConfig.R
   pkg/gmmExtra/R/bootGmm.R
   pkg/gmmExtra/man/bootGmmMet.Rd
Log:
added print method to bootGmm

Modified: pkg/gmmExtra/NAMESPACE
===================================================================
--- pkg/gmmExtra/NAMESPACE	2012-11-05 15:41:48 UTC (rev 64)
+++ pkg/gmmExtra/NAMESPACE	2012-11-13 19:44:08 UTC (rev 65)
@@ -1,9 +1,10 @@
 import(stats)
 importFrom(car, linearHypothesis)
 
-export(KConfid, bootGmm, plot.bootGmm, summary.bootGmm, bootJ, linearHypothesis.bootGmm)
+export(KConfid, bootGmm, plot.bootGmm, summary.bootGmm, bootJ, linearHypothesis.bootGmm, print.bootGmm)
 
 S3method(plot, bootGmm)
+S3method(print, bootGmm)
 S3method(summary, bootGmm)
 S3method(linearHypothesis, bootGmm)
  

Modified: pkg/gmmExtra/R/KConfig.R
===================================================================
--- pkg/gmmExtra/R/KConfig.R	2012-11-05 15:41:48 UTC (rev 64)
+++ pkg/gmmExtra/R/KConfig.R	2012-11-13 19:44:08 UTC (rev 65)
@@ -111,7 +111,6 @@
 	y1 <- xy34[[1]]
 	y2 <- xy34[[2]]
 
-print(c(x1,x2,y1,y2))
 	getAll <- function(lambda, dir=1, x)
 		{
 		yi <- y1*lambda + y0*(1-lambda)

Modified: pkg/gmmExtra/R/bootGmm.R
===================================================================
--- pkg/gmmExtra/R/bootGmm.R	2012-11-05 15:41:48 UTC (rev 64)
+++ pkg/gmmExtra/R/bootGmm.R	2012-11-13 19:44:08 UTC (rev 65)
@@ -227,7 +227,30 @@
 	print(round(attr(object,"gmm")$coefficients,4))
 	}
 
+print.bootGmm <- function(x, ...)
+	{
+	n <- length(x)
+	cat("#################\n")
+	cat("# GMM Bootstrap #\n")
+	cat("#################\n\n")
+	cat("Original Call:\n    ",  paste(deparse(attr(x,"gmm")$call), sep = "\n", collapse = "\n"), "\n")
+	cat("Number of resamplings: ", n,"\n")
+	conv <- sapply(1:n, function(i) x[[i]]$ans$algoInfo$convergence)
+	cat("Number of successful estimations (convergence): ",n-sum(conv),"\n")  
+	coef <- t(sapply(1:n, function(i) x[[i]]$ans$coefficients))
+	ansB <- rbind(colMeans(coef), apply(coef,2,sd))
+	rownames(ansB) <- c("Mean","S-dev")
+	cat("\nBootstrap results:\n") 
+	printCoefmat(ansB)
+	res <- attr(x,"gmm")
+	ans <- res$coefficients
+	ans <- rbind(ans, summary(res)$coefficients[,2])
+	cat("\nOriginal estimation:\n") 
+	rownames(ans) <- c("Estimates","S-dev")
+	printCoefmat(ans)
+	}
 
+
 plot.bootGmm <- function(x, which = 1, type = c("points", "density"), ...)
 	{
 	if (length(x) == 0)

Modified: pkg/gmmExtra/man/bootGmmMet.Rd
===================================================================
--- pkg/gmmExtra/man/bootGmmMet.Rd	2012-11-05 15:41:48 UTC (rev 64)
+++ pkg/gmmExtra/man/bootGmmMet.Rd	2012-11-13 19:44:08 UTC (rev 65)
@@ -1,12 +1,14 @@
 \name{bootGmmMet}
 \alias{plot.bootGmm}
 \alias{summary.bootGmm}
+\alias{print.bootGmm}
 
 \title{Methods for Bootstrap Gmm}
 \description{Some methods to analyze the properties of the bootstrap estimates}
 \usage{
 \method{plot}{bootGmm}(x, which = 1, type = c("points", "density"), ...)
 \method{summary}{bootGmm}(object, ...)
+\method{print}{bootGmm}(x, ...)
 }
 \arguments{
  \item{object}{Object of class "bootGmm" returned by \link{bootGmm}}
@@ -54,6 +56,7 @@
 res <- gmm(d$Y~d$X-1,~d$Z-1)
 # Just resampling 25 time to save time
 resB <- bootGmm(res, 25, seed = 123, niter = 2, trace = TRUE)
+resB
 plot(resB, 2)
 plot(resB, 2, "density")
 summary(resB)



More information about the Gmm-commits mailing list