*! version 1.0.0 23jan2026

Title

kmtest_sim -- Simulate integrated processes for testing

Syntax

kmtest_sim
newvar
,
[options]

Parameters
n(#) number of observations; default is n(100)

y0(#) initial value; default is y0(1)

mu(#) drift parameter; default is mu(0.01)

sigma(#) innovation standard deviation; default is sigma(0.01)

ar1(#) AR(1) coefficient; default is ar1(0)

Model
log generate logarithmic I(1) process instead of linear

Other
seed(#) set random number seed

replace replace variable if it exists

Description

kmtest_sim generates simulated integrated processes for use in testing
the kmtest command or for Monte Carlo experiments.

By default, the command generates a linear I(1) process:

y_t = y_ + e_t + μ

With the log option, it generates a logarithmic I(1) process:

log(y_t) = log(y_) + u_t + η

Options

Parameters

n(#) specifies the number of observations to generate. Default is 100.

y0(#) specifies the initial value of the series. Must be positive.
Default is 1.

mu(#) specifies the drift parameter. For linear model, this is the
mean of the first differences. For log model, this is the mean of log returns.
Default is 0.01.

sigma(#) specifies the standard deviation of the white noise innovations.
Default is 0.01.

ar1(#) specifies the first-order autoregressive coefficient for the
innovations. Must be less than 1 in absolute value. Default is 0 (white noise).

Model

log specifies that a logarithmic I(1) process should be generated
instead of a linear I(1) process.

Other

seed(#) sets the random number seed for reproducibility.

replace allows the variable to be replaced if it already exists.

Examples

Generate a linear I(1) process with 200 observations

. kmtest_sim y_linear, n(200) y0(100) mu(0.5) sigma(2)

Generate a logarithmic I(1) process

. kmtest_sim y_log, n(200) y0(100) mu(0.01) sigma(0.02) log

Generate with AR(1) innovations

. kmtest_sim y_ar, n(200) ar1(0.7) seed(12345)

Test the simulated data

. kmtest y_linear

. kmtest y_log

Author

Dr. Merwan Roudane

Also see

Help: [TS] kmtest