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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 14 21:20:08 CEST 2017


Author: chaussep
Date: 2017-06-14 21:20:07 +0200 (Wed, 14 Jun 2017)
New Revision: 109

Modified:
   pkg/gmmExtra/R/bootGmm.R
   pkg/gmmExtra/man/bootGmm.Rd
   pkg/gmmExtra/man/bootGmmMet.Rd
   pkg/gmmExtra/man/bootJ.Rd
   pkg/gmmExtra/man/linearHypothesis.Rd
Log:
fixed compiling failure... at least tried to

Modified: pkg/gmmExtra/R/bootGmm.R
===================================================================
--- pkg/gmmExtra/R/bootGmm.R	2017-06-14 14:59:34 UTC (rev 108)
+++ pkg/gmmExtra/R/bootGmm.R	2017-06-14 19:20:07 UTC (rev 109)
@@ -282,35 +282,34 @@
 	}	
 
 linearHypothesis.bootGmm <- function(model, hypothesis.matrix, rhs = NULL, ...)
-	{
-	obj <- model
+    {
+        obj <- model
 	n <- length(obj)
 	if (n == 0)
-		stop("The bootGmm object is empty")
-	Test0 <- linearHypothesis(attr(obj,"gmm"), hypothesis.matrix, rhs=rhs, ...)[[2]][2]
-
-	# The following is borrowed from the car::linearHypothesis.default
-	if (is.character(hypothesis.matrix)) {
-		L <- makeHypothesis(names(attr(obj,"gmm")$coefficients), hypothesis.matrix, rhs = NULL)
-		if (is.null(dim(L))) L <- t(L)
-		rhs <- L[, NCOL(L)]
-		L <- L[, -NCOL(L), drop = FALSE]
-		rownames(L) <- hypothesis.matrix
-	}
-	else {
+            stop("The bootGmm object is empty")
+	Test0 <- linearHypothesis(attr(obj,"gmm"), hypothesis.matrix, rhs=rhs,
+                                  ...)$Chisq[2]
+# The following is borrowed from the car::linearHypothesis.default
+	if (is.character(hypothesis.matrix))
+            {
+                L <- makeHypothesis(names(attr(obj,"gmm")$coefficients),
+                                    hypothesis.matrix, rhs = NULL)
+                if (is.null(dim(L))) L <- t(L)
+                rhs <- L[, NCOL(L)]
+                L <- L[, -NCOL(L), drop = FALSE]
+                rownames(L) <- hypothesis.matrix
+            } else {
 		L <- if (is.null(dim(hypothesis.matrix))) t(hypothesis.matrix)
-				else hypothesis.matrix
+                     else hypothesis.matrix
 		if (is.null(rhs)) rhs <- rep(0,nrow(L))
-	}
+            }
 	hyp <- printHypothesis(L, rhs, names(attr(obj,"gmm")$coefficients))
-	
-	##############
-	rhsB <- L%*%attr(obj,"gmm")$coefficients
-
-	Test <- sapply(1:n, function(i) linearHypothesis(obj[[i]]$ans, L, rhsB, ...)[[2]][2])
+	rhsB <- L%*%attr(obj,"gmm")$coefficients        
+	Test <- sapply(1:n, function(i) linearHypothesis(obj[[i]]$ans, L, rhsB,
+                                                         ...)$Chisq[2])
 	F <- ecdf(Test)
 	pval <- 1-F(Test0)
 	list(hyp = hyp, test = c(Stats=Test0, BootPVal=pval), TCDF = F)
-	}
+    }
 
 

Modified: pkg/gmmExtra/man/bootGmm.Rd
===================================================================
--- pkg/gmmExtra/man/bootGmm.Rd	2017-06-14 14:59:34 UTC (rev 108)
+++ pkg/gmmExtra/man/bootGmm.Rd	2017-06-14 19:20:07 UTC (rev 109)
@@ -50,6 +50,7 @@
 set.seed(123)
 d <- getdat(500)
 res <- gmm(Y~X-1,~Z-1,vcov="iid", data=d)
-# Just resampling 25 time to save time
-resB <- bootGmm(res, 25, seed = 123, niter = 2, trace=TRUE)
+# Just resampling 25 time to save time and using 1 core
+resB <- bootGmm(res, 25, seed = 123, niter = 1)
+resB
 }

Modified: pkg/gmmExtra/man/bootGmmMet.Rd
===================================================================
--- pkg/gmmExtra/man/bootGmmMet.Rd	2017-06-14 14:59:34 UTC (rev 108)
+++ pkg/gmmExtra/man/bootGmmMet.Rd	2017-06-14 19:20:07 UTC (rev 109)
@@ -55,7 +55,7 @@
 d <- getdat(500)
 res <- gmm(Y~X-1,~Z-1, data=d)
 # Just resampling 25 time to save time
-resB <- bootGmm(res, 25, seed = 123, niter = 2, trace = TRUE)
+resB <- bootGmm(res, 25, seed = 123, niter = 1, trace = TRUE)
 resB
 plot(resB, 2)
 plot(resB, 2, "density")

Modified: pkg/gmmExtra/man/bootJ.Rd
===================================================================
--- pkg/gmmExtra/man/bootJ.Rd	2017-06-14 14:59:34 UTC (rev 108)
+++ pkg/gmmExtra/man/bootJ.Rd	2017-06-14 19:20:07 UTC (rev 109)
@@ -45,7 +45,7 @@
 set.seed(123)
 d <- getdat(500)
 res <- gmm(Y~X-1,~Z-1, data=d)
-resB <- bootGmm(res, 25, seed = 123, niter = 2, trace=TRUE)
+resB <- bootGmm(res, 25, seed = 123, niter = 1)
 J <- bootJ(resB)
 J$test
 }

Modified: pkg/gmmExtra/man/linearHypothesis.Rd
===================================================================
--- pkg/gmmExtra/man/linearHypothesis.Rd	2017-06-14 14:59:34 UTC (rev 108)
+++ pkg/gmmExtra/man/linearHypothesis.Rd	2017-06-14 19:20:07 UTC (rev 109)
@@ -49,7 +49,9 @@
 d <- getdat(500)
 res <- gmm(Y~X-1,~Z-1, data=d)
 # Just resampling 25 time to save time
-resB <- bootGmm(res, 25, seed = 123, niter = 10, trace=TRUE)
-T <- linearHypothesis(resB, "X2 = 1")
+resB <- bootGmm(res, 25, seed = 123, niter = 1)
+T <- linearHypothesis(resB, "X2 = 2")
 T
 }
+
+



More information about the Gmm-commits mailing list