[Gmm-commits] r145 - in pkg: gmm4 gmmExtra gmmExtra/R gmmExtra/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 18 19:38:00 CEST 2019
Author: chaussep
Date: 2019-10-18 19:38:00 +0200 (Fri, 18 Oct 2019)
New Revision: 145
Modified:
pkg/gmm4/DESCRIPTION
pkg/gmmExtra/DESCRIPTION
pkg/gmmExtra/NAMESPACE
pkg/gmmExtra/R/bootGmm.R
pkg/gmmExtra/man/linearHypothesis.Rd
Log:
fixed gmmExtra so that it can compile
Modified: pkg/gmm4/DESCRIPTION
===================================================================
--- pkg/gmm4/DESCRIPTION 2019-10-18 14:50:34 UTC (rev 144)
+++ pkg/gmm4/DESCRIPTION 2019-10-18 17:38:00 UTC (rev 145)
@@ -4,7 +4,7 @@
Title: S4 Generalized Method of Moments
Author: Pierre Chausse <pchausse at uwaterloo.ca>
Maintainer: Pierre Chausse <pchausse at uwaterloo.ca>
-Description: This is a complete restructured version of the `gmm' package (Chausse 2010; <doi:10.18637/jss.v034.i11>) using S4 only type of classes and methods. It provides tools for estimating single equations and system of equations using the Generalized Method of Moments (Hansen 1982; <doi:10.2307/1912775>). It is in a very early stage and suggestions are welcome. See the vignette for more details.
+Description: This is a complete restructured version of the 'gmm' package (Chausse 2010; <doi:10.18637/jss.v034.i11>) using S4 only type of classes and methods. It provides tools for estimating single equations and system of equations using the Generalized Method of Moments (Hansen 1982; <doi:10.2307/1912775>). It is in a very early stage and suggestions are welcome. See the vignette for more details.
Depends: R (>= 3.0.0), sandwich
Imports: stats, methods
Suggests: lmtest, knitr, texreg
Modified: pkg/gmmExtra/DESCRIPTION
===================================================================
--- pkg/gmmExtra/DESCRIPTION 2019-10-18 14:50:34 UTC (rev 144)
+++ pkg/gmmExtra/DESCRIPTION 2019-10-18 17:38:00 UTC (rev 145)
@@ -1,11 +1,11 @@
Package: gmmExtra
Version: 0.0-3
-Date: 2017-06-13
+Date: 2019-10-17
Title: Methods for Generalize Method of Moments Estimation
Author: Pierre Chausse <pchausse at uwaterloo.ca>
Maintainer: Pierre Chausse <pchausse at uwaterloo.ca>
-Description: Tools for GMM such as additional tests or robust confidence regions. They only apply to gmm class object for the gmm package.
-Depends: R (>= 2.10.0), gmm (>= 1.6-2), car, parallel
-Imports: stats
+Description: Tools for Generalize Method of Moments estimation methods MM such as additional tests or robust confidence regions. They only apply to 'gmm' class object for the 'gmm' package.
+Depends: R (>= 3.0.0), gmm (>= 1.6-2), parallel
+Imports: stats, car
License: GPL (>= 2)
Modified: pkg/gmmExtra/NAMESPACE
===================================================================
--- pkg/gmmExtra/NAMESPACE 2019-10-18 14:50:34 UTC (rev 144)
+++ pkg/gmmExtra/NAMESPACE 2019-10-18 17:38:00 UTC (rev 145)
@@ -4,11 +4,11 @@
importFrom(gmm, gmm, specTest, gmmWithConst, KTest)
importFrom(graphics, plot)
-export(KConfid, bootGmm, plot.bootGmm, summary.bootGmm, bootJ, linearHypothesis.bootGmm, print.bootGmm)
+export(KConfid, bootGmm, plot.bootGmm, summary.bootGmm, bootJ, hypothesisTest, print.bootGmm)
S3method(plot, bootGmm)
S3method(print, bootGmm)
S3method(summary, bootGmm)
-S3method(linearHypothesis, bootGmm)
+
Modified: pkg/gmmExtra/R/bootGmm.R
===================================================================
--- pkg/gmmExtra/R/bootGmm.R 2019-10-18 14:50:34 UTC (rev 144)
+++ pkg/gmmExtra/R/bootGmm.R 2019-10-18 17:38:00 UTC (rev 145)
@@ -10,7 +10,6 @@
# comment (optional) : Some comments to be add in string format. Useful if running several processes and want to know which one is running
# num_proc( optional) : If simulation is made on more than one processes, num_proc[1] is the process being done and
# proc_num[2] is the total number of processes
-
if(iter==start)
{
@@ -281,35 +280,35 @@
list(test = c(Stats=J0, BootPVal=pval), JCDF = F)
}
-linearHypothesis.bootGmm <- function(model, hypothesis.matrix, rhs = NULL, ...)
+hypothesisTest <- function(model, hypothesis.matrix, rhs = NULL, ...)
+{
+ obj <- model
+ n <- length(obj)
+ if (n == 0)
+ stop("The bootGmm object is empty")
+ Test0 <- car::linearHypothesis(attr(obj,"gmm"), hypothesis.matrix, rhs=rhs,
+ ...)$Chisq[2]
+# The following is borrowed from the car::linearHypothesis.default
+ if (is.character(hypothesis.matrix))
{
- obj <- model
- n <- length(obj)
- if (n == 0)
- 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
- 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,
- ...)$Chisq[2])
- F <- ecdf(Test)
- pval <- 1-F(Test0)
- list(hyp = hyp, test = c(Stats=Test0, BootPVal=pval), TCDF = F)
+ L <- car::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
+ if (is.null(rhs)) rhs <- rep(0,nrow(L))
}
+ hyp <- car::printHypothesis(L, rhs, names(attr(obj,"gmm")$coefficients))
+ rhsB <- L%*%attr(obj,"gmm")$coefficients
+ Test <- sapply(1:n, function(i) car::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/linearHypothesis.Rd
===================================================================
--- pkg/gmmExtra/man/linearHypothesis.Rd 2019-10-18 14:50:34 UTC (rev 144)
+++ pkg/gmmExtra/man/linearHypothesis.Rd 2019-10-18 17:38:00 UTC (rev 145)
@@ -1,15 +1,15 @@
-\name{linearHypothesis}
-\alias{linearHypothesis.bootGmm}
+\name{hypothesisTest}
+\alias{hypothesisTest}
\title{Bootstrap linear hypothesis testing}
\description{Compute the Bootstrap ECDF of the Chi-square test and the P-value}
\usage{
-\method{linearHypothesis}{bootGmm}(model, hypothesis.matrix, rhs = NULL, ...)
+hypothesisTest(model, hypothesis.matrix, rhs = NULL, ...)
}
\arguments{
\item{model}{Object of class "bootGmm" returned by \link{bootGmm}}
-\item{hypothesis.matrix}{Either the R matrix in the hypothesis \eqn{R\theta=c} or a vector of characters (see /link{linearHypothesis})}
-\item{rhs}{The right hand side of the linear test (see /link{linearHypothesis})}
-\item{...}{Arguments to pass to \link{linearHypothesis}}
+\item{hypothesis.matrix}{Either the R matrix in the hypothesis \eqn{R\theta=c} or a vector of characters.}
+\item{rhs}{The right hand side of the linear test.}
+\item{...}{Arguments to pass to linearHypothesis}
}
\value{
@@ -50,7 +50,7 @@
res <- gmm(Y~X-1,~Z-1, data=d)
# Just resampling 25 time to save time
resB <- bootGmm(res, 25, seed = 123, niter = 1)
-T <- linearHypothesis(resB, "X2 = 2")
+T <- hypothesisTest(resB, "X2 = 2")
T
}
More information about the Gmm-commits
mailing list