*! version 1.0 4 Oct 2021

Title

boxcoxsim -- Simulating Box Cox transformed data, possibly left
truncated and possibly with some degree of extreme values.

Syntax

boxcoxsim
[,
options]

Optional
n(#) Number of observations. The default value is 200.

mean(#) Mean for the underlying normal distribution. Mean is reset if not 4 times the standard deviation to exactly that. The default value is 4.

sd(#) Standard deviation for the underlying normal distribution. The default value is 1.

theta(#) Box Cox transformation on the underlying normal distribution. The default value is 1.

nd(#) Percentage degree of left non-detects ie of left censoring. The default value is 0.

fmt(string) Format for the censored and underlying normal distribution. The default is "%6.2f".

outlierpct(#) Proportion of the upper outliers. The default value is 0.

omean(#) mean for the upper outliers.

osd(#) standard deviation for upper the outliers.

otheta(#) Box Cox transformation for the upper outliers.

percentiles(numlist) Percentiles to report for comparison. The default is "50 75 90 95 99".

clear Clear the data editor.

Description

boxcoxsim simulates data from a Box Cox (normal) distributed data with
a possible percentage degree of left truncation and in a mixture of
possible percentage degrees of extreme values.
It is a simulation tool for ros.

Examples

Simulated data example 1

To simulate 2000 values from a normal distribution (theta = 1 and nd = 0
by default) with a normal mean of 10 and a normal standard deviation of 2

`"boxcoxsim, n(2000) mean(10) sd(2) outlierpct(0) clear"'

A histogram of the simulated data:

`"hist yc, norm ylabel(none) xtitle(normal values)"'

Simulated data example 2

To simulate 2000 values from a squared normal distribution
(theta = 2) with a normal mean of 2 and a normal standard deviation of 0.5.
There are no non-detects (nd = 0 by default) and no outliers (outlierpct = 0)

`"boxcoxsim, n(2000) nd(0) theta(2) mean(2) sd(0.5) outlierpct(0) clear"'

A histogram of the simulated data:

`"hist yc, norm ylabel(none) xtitle(normal values)"'

Simulated data example 3

To simulate 2000 values from a log-normal distribution (theta = 0)
having a normal mean of 1.5 and a normal standard deviation of 0.3 and where
55% of data are non-detectable (nd = 55).
Further, there are 30% outliers (outlierpct = 30) with a normal mean of 2 and
a standard deviation of 0.5.

`"boxcoxsim, n(2000) nd(55) theta(0) mean(1.5) sd(0.3) outlierpct(0.3) omean(2) osd(0.5) clear"'

Returned values:

`"return list"'

A histogram of the simulated data:

`"hist yc, norm ylabel(none) xtitle(normal values)"'

Stored results

Scalars

r(y_percentileXXX) Empirical XXX percentile

r(n) Number of generated data

r(mean) The chosen mean of the underlying normal distribution

r(sd) The chosen standard deviation of the underlying normal distribution

r(theta) The chosen Box-Cox transformation

r(non_detects_pct) Chosen percentage of non-detects

r(outlierpct) The chosen percentage of outliers

Matrices

r(percentiles) Empirical percentiles

Variables

y The Box-Cox transformed data

censored The marker for data being censored

yc The censored Box-Cox transformed data

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com