Bayesian Regression Model
Sep-13-2024
Source:vignettes/articles/bayesian_regression_model.Rmd
bayesian_regression_model.Rmd
Bayesian Regression Model
Bayesian Regression model were used for generating numerical synthetic data for BW, LB and OM domain. MCMCregress function from MCMCpack R package MCMCpack: Markov Chain Monte Carlo in R were used to build the model.
Example for LB Domain
Variable full name
- LBCAT (Category for Lab Test)
- LBTEST (Lab Test or Examination Name)
- LBTESTCD (Lab Test or Examination Short Name)
- LBSTRESN (Standardized Result in Numeric Format)
A group of Control, male rats were chosen whrere
value of LBCAT variable was CLINICAL CHEMISTRY.
Mean of all LBTESTCD (PHOS, CA, CHOL, BIL, ALP etc) calculated for that
group.
let’s say following table represent Mean of LBTESTCD.
LBTESTCD | MEAN |
---|---|
ALT | 58 |
PROT | 60 |
ALB | 36 |
CL | 105 |
GLUC | 7 |
To build a model for ALT, algorithmically we chose
two nearest value.
In this case, we chose PROT and
ALB
Model Formula:
MCMCpack::MCMCregress("ALT ~ PROT + ALB", b0=0,B0=0.1, data= line)
Here line is the table that contain LBSTRESN
(Standardized Result in Numeric Format)
for LBTESTCD (Lab Test or Examination Short Name)
ALT | PROT | ALB | CL | GLUC |
---|---|---|---|---|
58 | 59 | 36 | 105 | 6 |
59 | 60 | 37 | 104 | 9 |
57 | 61 | 35 | 106 | 6 |
Here is the model output:
INTERCEPT | COF_PROT | COF_ALB |
---|---|---|
0.05027991 | 2.3874235 | -1.956665 |
-4.40402458 | 1.9721626 | -1.627903 |
0.31785474 | 2.9303049 | -3.017695 |
NOTE: Error column removed from the table because we did not use in any calculation.
We used a randomly chosen sample/row from the model output and
calculated synthetic ALT value for a specific
animal.
ALT = INTERCEPT + COF_PROT * PROT + COF_ALB * ALB
- some noise added
noise <- stats::rnorm(1,mean=0,sd=(standard_deviation_of_that_group_for_ALT)
final_value = ALT + noise
- NOTE
when predicted value returned negative, algorithmically a different sample was chosen and value re-calculated. We try this approach maximum ten times if a value returns negative. If value returns negative after ten try, absolute value of the negative value is taken as final value.