**[MI] mi impute pmm** -- Impute using predictive mean matching

__Syntax__

**mi** __imp__**ute** **pmm** *ivar* [*indepvars*] [*if*] [*weight*] **,** **knn(***#***)** [*impute_options*
*options*]

*options* Description
-------------------------------------------------------------------------
Main
__nocons__**tant** suppress constant term
* **knn(***#***)** specify *#* of closest observations (nearest
neighbors) to draw from
__cond__**itional(***if***)** perform conditional imputation
__boot__**strap** estimate model parameters using sampling with
replacement
-------------------------------------------------------------------------
* **knn(***#***)** is required.
You must **mi set** your data before using **mi** **impute** **pmm**; see **[MI] mi set**.
You must **mi register** *ivar* as imputed before using **mi** **impute** **pmm**; see **[MI]**
**mi set**.
*indepvars* may contain factor variables; see fvvarlist.
**aweight**s, **fweight**s, **iweight**s, and **pweight**s are allowed; see weight.

__Menu__

**Statistics > Multiple imputation**

__Description__

**mi** **impute** **pmm** fills in missing values of a continuous variable by using
the predictive mean matching imputation method. You can perform separate
imputations on different subsets of the data by specifying the **by()**
option. You can also account for analytic, frequency, importance, and
sampling weights.

__Options__

+------+
----+ Main +-------------------------------------------------------------

**noconstant**; see **[R] estimation options**.

**add()**, **replace**, **rseed()**, **double**, **by()**; see **[MI] mi impute**.

**knn(***#***)** specifies the number of closest observations (nearest neighbors)
from which to draw imputed values. This option is required. The
closeness is determined based on the absolute difference between the
linear prediction for the missing value and that for the complete
values. The closest observation is the observation with the smallest
difference. This option regulates the correlation among multiple
imputations that affects the bias and the variability of the
resulting multiple-imputation point estimates; see *Remarks and*
*examples* in **[MI] mi impute pmm** for details.

**conditional(***if***)** specifies that the imputation variable be imputed
conditionally on observations satisfying *exp*. That is, missing
values in a conditional sample, the sample identified by the *exp*
expression, are imputed based only on data in that conditional
sample. Missing values outside the conditional sample are replaced
with a conditional constant, the value of the imputation variable in
observations outside the conditional sample. As such, the imputation
variable is required to be constant outside the conditional sample.
Also, if any conditioning variables (variables involved in the
conditional specification **if** *exp*) contain soft missing values (**.**),
their missing values must be nested within missing values of the
imputation variable. See *Conditional imputation* under *Remarks and*
*examples* in **[MI] mi impute**.

**bootstrap** specifies that posterior estimates of model parameters be
obtained using sampling with replacement; that is, posterior
estimates are estimated from a bootstrap sample. The default is to
sample the estimates from the posterior distribution of model
parameters or from the large-sample normal approximation of the
posterior distribution. This option is useful when asymptotic
normality of parameter estimates is suspect.

+-----------+
----+ Reporting +--------------------------------------------------------

**dots**, **noisily**, **nolegend**; see **[MI] mi impute**. **noisily** specifies that the
output from the linear regression fit to the observed data be
displayed. **nolegend** suppresses all legends that appear before the
imputation table. Such legends include a legend about conditional
imputation that appears when the **conditional()** option is specified
and group legends that may appear when the **by()** option is specified.

+----------+
----+ Advanced +---------------------------------------------------------

**force**; see **[MI] mi impute**.

The following option is available with **mi impute** but is not shown in the
dialog box:

**noupdate**; see **[MI] noupdate option**.

__Examples__

Setup
**. webuse mheart0**

Declare data and register variable **bmi** as imputed
**. mi set mlong**
**. mi register imputed bmi**

Impute **bmi** using predictive mean matching using 5 nearest neighbors
**. mi impute pmm bmi attack smokes age hsgrad female, add(20) knn(5)**

Impute **bmi** using 10 nearest neighbors
**. mi impute pmm bmi attack smokes age hsgrad female, replace knn(10)**

__Video example__

Multiple imputation: Setup, imputation, estimation -- predictive mean
matching

__Stored results__

**mi impute pmm** stores the following in **r()**:

Scalars
**r(M)** total number of imputations
**r(M_add)** number of added imputations
**r(M_update)** number of updated imputations
**r(knn)** number of k nearest neighbors
**r(k_ivars)** number of imputed variables (always **1**)
**r(N_g)** number of imputed groups (**1** if **by()** is not
specified)

Macros
**r(method)** name of imputation method (**pmm**)
**r(ivars)** names of imputation variables
**r(rngstate)** random-number state used
**r(by)** names of variables specified within **by()**

Matrices
**r(N)** number of observations in imputation sample in
each group
**r(N_complete)** number of complete observations in imputation
sample in each group
**r(N_incomplete)** number of incomplete observations in
imputation sample in each group
**r(N_imputed)** number of imputed observations in imputation
sample in each group