# Source code for naginterfaces.​library.​examples.​correg.​coeffs_kspearman_miss_case_ex

```#!/usr/bin/env python
"``naginterface.library.correg.coeffs_kspearman_miss_case`` Python Example."

# NAG Copyright 2017-2019.

# pylint: disable=invalid-name

import numpy as np

from naginterfaces.library import correg

[docs]def main():
"""
Example for
:func:`naginterfaces.library.correg.coeffs_kspearman_miss_case`.

Kendall and Spearman rank correlation coefficients.

>>> main()
naginterfaces.library.correg.coeffs_kspearman_miss_case Python Example
Results.
Kendall and Spearman rank correlation coefficients.
Observations:
[
1.70,  1.00,  0.50
2.80,  4.00,  3.00
0.60,  6.00,  2.50
1.80,  9.00,  6.00
0.99,  4.00,  2.50
1.40,  2.00,  5.50
1.80,  9.00,  7.50
2.50,  7.00,  0.00
0.99,  5.00,  3.00
]
Correlation coefficients:
[
1.0000,     0.2941,     0.4058
0.1429,     1.0000,     0.7537
0.2760,     0.5521,     1.0000
]
"""

print(
'naginterfaces.library.correg.coeffs_kspearman_miss_case '
'Python Example'
)
print('  Results.')
print('Kendall and Spearman rank correlation coefficients.')

# The observations:
x = np.array([
[1.7, 1., 0.5],
[2.8, 4., 3.],
[0.6, 6., 2.5],
[1.8, 9., 6.],
[0.99, 4., 2.5],
[1.4, 2., 5.5],
[1.8, 9., 7.5],
[2.5, 7., 0.],
[0.99, 5., 3.],
])
# The missing values:
miss = [1, 0, 1]
xmiss = [0.99, 0., 0.]
# The calculation mode:
itype = 0

print("Observations:")
print('[')
for i in range(x.shape[0]):
print('  ' + ', '.join(['{:5.2f}']*x.shape[1]).format(*x[i, :]))
print(']')

rr = correg.coeffs_kspearman_miss_case(
x, miss, xmiss, itype,
).rr

print("Correlation coefficients:")
print('[')
for i in range(rr.shape[0]):
print(
'  ' +
', '.join(['{:10.4f}']*rr.shape[1]).format(*rr[i, :])
)
print(']')

if __name__ == '__main__':
import doctest
import sys
sys.exit(
doctest.testmod(
None, verbose=True, report=False,
optionflags=doctest.REPORT_NDIFF,
).failed
)
```