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

## Description

It allows to merge `gmmModels` classes into system GMM objects.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## S4 method for signature 'linearGmm,linearGmm' merge(x, y, ...) ## S4 method for signature 'nonlinearGmm,nonlinearGmm' merge(x, y, ...) ## S4 method for signature 'slinearGmm,linearGmm' merge(x, y, ...) ## S4 method for signature 'snonlinearGmm,nonlinearGmm' merge(x, y, ...) ```

## Arguments

 `x` An object on which the other objects are merged to. `y` An object to be merged to `x`. `...` Other objects of the same class as `y` to be merged to `x`.

## Methods

`signature(x = "linearGmm", y = "linearGmm")`

Merging linear models into a system of equations.

`signature(x = "nonlinearGmm", y = "nonlinearGmm")`

Merging nonlinear models into a system of equations.

`signature(x = "slinearGmm", y = "linearGmm")`

Adding linear equations to a system of linear equations.

`signature(x = "snonlinearGmm", y = "nonlinearGmm")`

Adding nonlinear equations to a system of nonlinear equations.

## 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 33 34``` ```data(simData) g1 <- y1~x1+x4; h1 <- ~z1+z2+z3+z4+x4 g2 <- y2~x1+x2+x3; h2 <- ~z1+z2+z3+z4+x3 g3 <- y3~x2+x3+x4; h3 <- ~z2+z3+z4+x3+x4 ## Linear models m1 <- gmmModel(g1, h1, data=simData) m2 <- gmmModel(g2, h2, data=simData) m3 <- gmmModel(g3, h3, data=simData) ## (sys1 <- merge(m1, m2)) ## add an equation to the model (sys2 <- merge(sys1, m3)) ## want to get back the first? sys2[1:2] ## Nonlinear (not really, just written as nonlinear) nlg <- list(y1~theta0+theta1*x1+theta2*x4, y2~alpha0+alpha1*x1+alpha2*x2+alpha3*x3, y3~beta0+beta1*x2+beta2*x3+beta3*x4) theta0 <- list(c(theta0=1,theta1=2,theta2=3), c(alpha0=1,alpha1=2,alpha2=3, alpha3=4), c(beta0=1,beta1=2,beta2=3,beta3=4)) nm1 <- gmmModel(nlg[], h1, theta0[], data=simData) nm2 <- gmmModel(nlg[], h2, theta0[], data=simData) nm3 <- gmmModel(nlg[], h3, theta0[], data=simData) merge(nm1, nm2, nm3) ```

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