-
-
Save jessetmoy/a6c44721575161f39ecf18d92ba85e77 to your computer and use it in GitHub Desktop.
SE conversion functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def high_ci_to_se(high_ci, est): | |
return round( | |
( | |
np.sqrt( | |
np.exp(((np.log(high_ci) - np.log(est)) / 1.96) ** 2) - 1 | |
) / est | |
), 3 | |
) | |
def low_ci_to_se(low_ci, est): | |
return round( | |
( | |
np.sqrt( | |
np.exp(((np.log(est) - np.log(low_ci)) / 1.96) ** 2) - 1 | |
) / est | |
), 3 | |
) | |
# Record 535 D.1 | |
# est = 1.49 | |
# se = 0.61 | |
# low_ci = 0.69 | |
# high_ci = 3.21 | |
print('Record 535 D.1', '| reported SE: 0.61') | |
print('result high CI to SE:', high_ci_to_se(high_ci=3.21, est=1.49)) | |
print('result lower CI to SE:', low_ci_to_se(low_ci=0.69, est=1.49)) | |
print('\n') | |
# TESTS | |
# record 114 D.2 | |
# est = 14.3 | |
# se = 2.8 | |
# low_ci = 9.6 | |
# high_ci = 20.5 | |
print('Record 114 D.2', '| reported SE: 2.8') | |
print('result high CI to SE:', high_ci_to_se(high_ci=20.5, est=14.3)) | |
print('result lower CI to SE:', low_ci_to_se(low_ci=9.6, est=14.3)) | |
print('\n') | |
# record 540 D.2 | |
# est = 1.64 | |
# se = 0.62 | |
# low_ci = 0.7 | |
# high_ci = 2.92 | |
print('Record 540 D.2', '| reported SE: 0.62') | |
print('result high CI to SE:', high_ci_to_se(high_ci=2.92, est=1.64)) | |
print('result lower CI to SE:', low_ci_to_se(low_ci=0.7, est=1.64)) | |
print('\n') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Record 535 D.1 | reported SE: 0.61
result high CI to SE: 0.273
result lower CI to SE: 0.274
Record 114 D.2 | reported SE: 2.8
result high CI to SE: 0.013
result lower CI to SE: 0.014
Record 540 D.2 | reported SE: 0.62
result high CI to SE: 0.183
result lower CI to SE: 0.278