Query Set #7c – imputing missing BNP values using a uniform distribution

While imputing the single missing temperature value was not difficult in our example, imputing the two missing BNP values is more problematic for a number of reasons:

While there is no perfect answer for this problem, if we do try to salvage the raw BNP values (which means imputing the missing values), in this query set, we impute from a uniform distribution of values in the normal range:

sqlite> ALTER TABLE MORT_FINAL_2 ADD COLUMN Raw_BNP INTEGER;

sqlite> UPDATE MORT_FINAL_2 SET Raw_BNP =
(SELECT CAST(Lab_value as INTEGER)
FROM LABS AS L
WHERE MORT_FINAL_2.Pid = L.Pid
AND MORT_FINAL_2.Visit_date = L.Lab_date
AND L.Lab_name = 'Natriuretic peptide B');

sqlite> UPDATE MORT_FINAL_2 SET Raw_BNP =
ROUND(ABS(RANDOM()) % (300 - 250) + 250)
WHERE Raw_BNP IS NULL;