# getRestrict-methods: ~~ Methods for Function 'getRestrict' in Package 'gmm4' ~~ In gmm4: S4 Generalized Method of Moments

## Description

It computes the matrices related to linear and nonlinear contraints. Those matrices are used to perform hypothesis tests.

## Usage

 ``` 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``` ```## S4 method for signature 'rlinearGmm' getRestrict(object, theta) ## S4 method for signature 'rslinearGmm' getRestrict(object, theta) ## S4 method for signature 'rnonlinearGmm' getRestrict(object, theta) ## S4 method for signature 'rformulaGmm' getRestrict(object, theta) ## S4 method for signature 'gmmModels' getRestrict(object, theta, R, rhs=NULL) ## S4 method for signature 'gelModels' getRestrict(object, theta, R, rhs=NULL) ## S4 method for signature 'sysGmmModels' getRestrict(object, theta, R, rhs=NULL) ## S4 method for signature 'rfunctionGmm' getRestrict(object, theta) ## S4 method for signature 'rgelModels' getRestrict(object, theta) ```

## Arguments

 `object` Object of class included in `gmmModels`, `rGmmModels`, and `rsysGmmModels`. `theta` A vector of coefficients for the unrestricted model (see examples). `R` A matrix, character or list of formulas that specifies the contraints to impose on the coefficients. See `restModel` for more details. `rhs` The right hand side for the restriction on the coefficients. See `restModel` for more details. It is ignored for objects of class `"nonlinearGmm"`.

## Methods

`signature(object = "gmmModels")`

A restricted model is created from the constraints, and the restriction matrices are returned. The methods is applied to linear and nonlinear models in a regression form.

`signature(object = "gelModels")`

A restricted model is created from the constraints, and the restriction matrices are returned. The methods is applied to linear and nonlinear models in a regression form.

`signature(object = "rgelModels")`

The restriction matrices are evaluated at the coefficient vector `theta` of the unrestricted representation.

`signature(object = "sysGmmModels")`

A restricted model is created from the constraints, and the restriction matrices are returned. The methods is applied to systems of linear and nonlinear models.

`signature(object = "rlinearGmm")`

The restriction matrices are evaluated at the coefficient vector `theta` of the unrestricted representation.

`signature(object = "rslinearGmm")`

The restriction matrices are evaluated at the coefficient vector `theta` of the unrestricted representation.

`signature(object = "rnonlinearGmm")`

The restriction matrices are evaluated at the coefficient vector `theta` of the unrestricted representation.

`signature(object = "rfunctionGmm")`

The restriction matrices are evaluated at the coefficient vector `theta` of the unrestricted representation.

## Examples

 ``` 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``` ```data(simData) theta <- c(beta0=1,beta1=2) ## Unrestricted model model1 <- gmmModel(y~x1+x2+x3+z1, ~x1+x2+z1+z2+z3+z4, data=simData) ## The restricted model R1 <- c("x1","2*x2+z1=2", "4+x3*5=3") res <- modelFit(model1) rest <- getRestrict(model1, coef(res), R1) ## it allows to test the restriction g <- rest\$R-rest\$q v <- rest\$dR%*%vcov(res)%*%t(rest\$dR) (test <- crossprod(g, solve(v, g))) (pv <- 1-pchisq(test, length(rest\$R))) ## Delta Method: ## To impose nonlinear restrictions, we need to convert ## the linear model into a nonlinear one NLmodel <- as(model1, "nonlinearGmm") R1 <- c("theta2=2", "theta3=theta4^2") res <- modelFit(NLmodel) rest <- getRestrict(NLmodel, coef(res), R1) g <- rest\$R-rest\$q v <- rest\$dR%*%vcov(res)%*%t(rest\$dR) (test <- crossprod(g, solve(v, g))) (pv <- 1-pchisq(test, length(rest\$R))) ## See hypothesisTest method for an easier approach. ```

gmm4 documentation built on Dec. 6, 2019, 3:01 a.m.