# User-defined functions

## Summary

If a certain feature (e.g. distribution, significance test, descriptive statistic or multiplicity adjustment procedure) is not implemented in the Mediana package, the user can defined a custom function and use it within the package. The user must follow the guidelines presented below to create valid custom functions.

## User-defined functions for a data model

If a certain distribution is not implemented in the Mediana package, the user can defined a custom distribution function. The user must follow the guidelines presented below to create valid custom functions.

### Custom functions for defining distributions

The following template must be used by the user to define a custom distribution function that can be used to specify an outcome, enrollment or dropout distribution in a data model. The distribution-specific components that should be modified if a different distribution needs to be implemented are identified in the comments.

As an example, the following function is used to generate observations following the `Template`

distribution that has two parameters, `parameter1`

and `parameter2`

.

Click on the icon to download this template:

## User-defined functions for an analysis model

If a significance test, descriptive statistic or multiplicity adjustment procedure is not included in the Mediana package, the user can easily define a custom function that implements a test, computes a descriptive statistic or performs a multiplicity adjustment. The user must follow the guidelines presented below to create valid custom functions.

### Custom functions for implementing a significance test

The following template must be used by the user to define a function that implements a significance test in an analysis model. The test-specific components that need to be modified if the user wishes to implement a different test are identified in the comments.

As an example, the function defined below carries out a test named `TemplateTest`

with a single required parameter labeled `parameter1`

.

Click on the icon to download this template:

### Custom functions for implementing a descriptive statistic

The following template must be used by the user to define a function that implements a descriptive statistic in an analysis model. The statistic-specific components that need to be modified if the user wishes to implement a different statistic are identified in the comments.

As an example, the function defined below carries out a descriptive statistic named `TemplateStatistic`

with a single required parameter labeled `parameter1`

and two samples.

Click on the icon to download this template:

## User-defined functions for an evaluation model

If the user wishes to apply a custom success criterion that is not included in the Mediana package, the guidelines presented below must be followed to create a valid custom function that implements this criterion.

### Custom functions for implementing a success criterion

The following template must be used by the user to define a function that implements a success criterion in an evaluation model. The components that need to be modified if the user wishes to implement a different criterion are identified in the comments.

As an illustration, the function defined below implements a criterion named `TemplateCriterion`

based on two significance tests and one descriptive statistic with two required parameters. The first parameter, labeled `parameter1`

, is applied to the significance tests and the second parameter, labeled `parameter2`

, is applied to the statistic. Success is achieved if at least one of the two tests is less than `parameter1`

and the statistic is greater than `parameter2`

.

Click on the icon to download this template: