# mm: Method of Moments, Including Possible Regression Terms In matloff/regtools: Regression and Classification Tools

 mm R Documentation

## Method of Moments, Including Possible Regression Terms

### Description

Method of Moments computation for almost any statistical problem that has derivatives with respect to theta. Capable of handling models that include parametric regression terms, but not need be a regression problem. (This is not Generalized Method of Moments; see the package gmm for the latter.)

### Usage

```mm(m,g,x,init=rep(0.5,length(m)),eps=0.0001,maxiters=1000)
```

### Arguments

 `m` Vector of sample moments, "left-hand sides" of moment equations. `g` Function of parameter estimates, forming the "right-hand sides." This is a multivariate-valued function, of dimensionality equal to that of `m`

.

 `init` Vector of initial guesses for parameter estimates. If components are named, these will be used as labels in the output. `eps` Convergence criterion. `maxiters` Maximum number of iterations. `x` Input data.

### Details

Standard Newton-Raphson methods are used to solve for the parameter estimates, with `numericDeriv` being used to find the approximate derivatives.

### Value

R list consisting of components `tht`, the vector of parameter estimates, and `numiters`, the number of iterations performed.

Norm Matloff

### Examples

```x <- rgamma(1000,2)
m <- c(mean(x),var(x))
g <- function(x,theta) {  # from theoretical properties of gamma distr.
g1 <-  theta / theta
g2 <-  theta / theta^2
c(g1,g2)
}
# should output about 2 and 1
mm(m,g,x)

## Not run:
library(mfp)
data(bodyfat)
# model as a beta distribution
g <- function(x,theta) {
t1 <- theta
t2 <- theta
t12 <- t1 + t2
meanb <- t1 / t12
m1 <- meanb
m2 <- t1*t2 / (t12^2 * (t12+1))
c(m1,m2)
}
x <- bodyfat\$brozek/100
m <- c(mean(x),var(x))