## HOMA-IR Approximates Average Blood Insulin Resistance in Console Example Demo for TCL

### Preface

gold 1sep2021 Here are some calculations for converting HOMA-IR measurement from average blood glucose mg/dl over a 3 month period. Table is in US Units for Blood Glucose etc. Console program outputs data as table in TCL table format and comma delimited spreadsheet.

### Introduction

Here are TCL calculations on the equation converting HOMO-IR from Fasting Blood Glucose mg/dl and insulin measures. HOMA-IR standing for Homeostatic Model Assessment of Insulin Resistance is an indirect measurement that tells you and your doctor how much insulin your pancreas needs to make to control your blood sugar levels and evaluate pancreas/liver functions. The formula is HOMA_IR = expr { \$insulin * \$glucose * \$scale_factor} . \$scale_factor is (1/405.). Example calculation as HOMA_IR = expr { \$insulin * \$glucose * \$scale_factor }, expr { 4 * 100 * \$scale_factor }, rounds to 1.0 . Console program example demo was written on Windows 10, working under TCL version 8.6 Table is in US Units for Blood Glucose etc. As a peg point, 5 HbA1c units converts to 100 mg/dl abbreviation for milligrams per deciliter. Note. This Diabetes Care field is rapidly changing, one needs to check in at ADA professional.diabetes.org and pubmed search < HOMO-IR > for the latest up to date info.

European SI units as best understood. The HOMA-IR calculations here requires U.S. standard units.

```To convert component terms ( \$insulin & \$glucose) from international S.I. units:
Insulin: pmol/L to uIU/mL, divide by (÷) 6
Glucose: mmol/L to mg/dL, multiply by (x) 18```

### References:

• Wikipedia search engine < diabetes insulin resistance >
• Wikipedia search engine < Richard K. Bernstein >
• Wikipedia search engine < Programming Examples >
• Google search engine < vaporware >
• Google search engine < Blood Glucose insulin resistance >
• Book >> The Diabetes Code: Prevent and Reverse Type 2 Diabetes Naturally
• One Liners Programs Pie in the Sky
• One Liners
• One Liners Programs Compendium [L1 ]
• WIKI BOOKS, Programming_Examples pdf
• WIKI BOOKS, Tcl_Programming_Introduction pdf
• google search engine < HgA1c to Average Blood Glucose>
• How Do You Calculate Your A1c? diabetestalk.net
• BLOOD SUGAR HOW DO YOU CALCULATE YOUR A1C? DEC 5, 2017
• table
• The Diabetes Code: Prevent and Reverse Type 2 Diabetes Naturally
• 2018 · 4.88 MB by Dr Jason Fung
• Dr. Bernstein's Diabetes Solution: The Complete Guide to Achieving Normal Blood Sugars
• 2007 by Richard K. Bernstein
• care.diabetesjournals.org 2012
• Measurement of Hemoglobin A1c , Diabetes Care
• labs.selfdecode.com/blog/homa-ir
• A new twist on the path to harmony
• David B. Sacks, December 2012, full pdf available from ADA
• Translating the A1C Assay pdf, Richard Kahn and Vivian Fonseca, Diabetes Care, 2008
• see ADA professional.diabetes.org diapro glucose_calc for up to date
• see ADA professional.diabetes.org for up to date
• Use of HOMA-IR to diagnose non-alcoholic fatty liver disease, pubmed search < HOMO-IR >
• Non-Alcoholic Fatty Liver Disease in Children, pubmed search < HOMO-IR >
• pubmed search < HOMO-IR children>
• Insulin resistance index (HOMA-IR) in the differentiation of patients with non-alcoholic fatty liver disease
• mdcalc.com, many medical calculators
• David R. Matthews, MD Look up many papers on pubmed. Esp, Use and abuse of HOMA modeling
• David R. Matthews, MD, 10-year follow-up of intensive glucose control in type 2 diabetes

David R. Matthews, MD is a Professor of Diabetic Medicine at the University of Oxford. He is the Deputy co-ordinator and member of the Executive and Policy Advisory Committees of the UK Prospective Study of Diabetes (UKPDS). David R. Matthews, MD is currently investigating the inter-relationships between insulin resistance and beta cell function, and the effects of a low carbohydrate diet in people with and without type 2 diabetes at Churchill Hospital with the Center of Diabetes, in the United Kingdom.

ADA Quotes. Therefore, to change glucose from mg/dL to mmol/L, one divides by 18.016 (usually rounded off to 18), and values are multiplied by 18 to switch from mmol/L to mg/dL. For example, 126 mg/dL is equivalent to 7.0 mmol/L, and 40 mg/dL is 2.2 mmol/L.

• Developing an HbA1c-Based Equation to Estimate Blood Glucose in Maintenance Hemodialysis Patients
• Junichi Hoshino, MD, MPH1,2,3, Miklos Z. Molnar, MD, PHD1,
• September 2020

ADA Quotes. Developing an HbA1c-Based Equation to Estimate Blood Glucose in Maintenance Hemodialysis Patients,2013. Some equations showing a good correlation between HbA1c and average BG (AG) levels.The Diabetes Control and Complications Trial DCCT formula is Average Blood Glucose = expr { 35.6 * HbA1c − 77.3} < in milligrams per deciliter>.

table 1 printed inTCL format
homa_IR_2 units insulin units glucose units comment, if any
0.81500 3.3000 100.
0.84000 3.4000 100.
0.86400 3.5000 100.
0.88900 3.6000 100.
0.91400 3.7000 100.
0.93800 3.8000 100.
0.96300 3.9000 100.
0.98800 4.0000 100. answer for testcase 1
1.0120 4.1000 100.
1.0370 4.2000 100.

### Pretty Print Version

```        # pretty print from autoindent and ased editor
# Convert homa_IR_2 from Average Blood Glucose mg/dl V2
# Console program example demo
# written on Windows 10 on  TCL
# working under TCL version 8.6
# gold on TCL Club , 30aug2021
# Each homa_IR_2 reading usually from
# limits of 0.4 to 11
# Roughly 5 HbA1c converts to 100
# mg/dl abbrev. for milligrams per deciliter
# mmol/L abbrev. for milligrams per Liter
package require Tk
package require math::numtheory
package require math::constants
package require math::trig
package require math
namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
set tclprecision 17
console show
# following dresses up console output to easy eye
console eval {.console config -bg palegreen}
console eval {.console config -font {fixed 20 bold}}
console eval {wm geometry . 40x20}
set tclprecision 17
# conversion unit formulas in procs
# HOMA_IR = expr { \$insulin * \$glucose * \$scale_factor}
proc HOMA_IR2 { insulin  glucose }  {
set scale_factor [ expr { 1. / 405. } ]
return [expr { \$insulin * \$glucose * \$scale_factor}]}
# hbA1c_convert_to_average_blood_glucose mg/dl  HbA1c
proc a1c hbA1c {  expr { 35.6*\$hbA1c -77.3} }
# convert mg/dl to mmol/L average blood glucose
# some papers round off 18.016 to mgdl/18.
proc mgdl_to_mmoll mgdl {  expr { \$mgdl/18.0 } }
# convert  mmol/L to mg/dl average blood glucose
proc mmoll_to_mgdl mmoll {  expr { \$mmoll*18.0 } }
# proc precisionx used to round off floating point numbers
proc precisionx {precision float}  {
#  tcl:wiki:Floating-point formatting, <AM>
# select numbers only, not used on every number.
set x [ expr {round( 10 ** \$precision * \$float) / (10.0 ** \$precision)} ]
#  rounded or clipped to nearest 5ird significant figure
set x [ format "%#.5g" \$x ]
return \$x
}
proc table_format_out  n {
set sum 0
# initial  level
set count 0.0
set glucose 100.
puts "%| table|  | printed in|TCL format |% "
puts "%| homa_IR_2 units | insulin units |glucose units  |comment, if any|% "
# printout in TCL WIKI format table
for { set i 1 } { \$i <= \$n } { incr i } {
set count [+ \$count .1]
set insulin \$count
set homa_IR_2 [ HOMA_IR2 \$insulin \$glucose  ]
set insulin [ precisionx 3 \$insulin ]
set glocose [ precisionx 3 \$glucose ]
puts "&| [ precisionx 3  \$homa_IR_2  ] |  \$insulin  | \$glucose | |&"
incr sum \$i
}
return \$sum
}
table_format_out 90               ```