I dont know what is the right terminology for this, but basically I have a set of rules for imputing a value in , lets say column B, based on what values are in column A , rowise. It goes something like this.
if column A = 0, then impute Column B = 35
if column A = 0, then impute Column B = 35
if column A = 1, then impute Column B = 36
.
,
,if column A = 2, then impute Column B = 37
Like this are 150 rows of rules for imputing values in Column B based on values in Column A. Now multiply this by times 2, one set of rules if gender = male, another set of rules/values if gender = female. Basically lot of, if then else, or case_when , or lot of lines of coding if I try to code these rules in r.
So instead, I tried this, lrm(ColumnB ~ ColumnA, data= df) and what I get is an intercept and Beta for ColumnA. The R2 adjusted values is around 0.998.
So my question is , can I use the intercept and slope from linear model to impute for future values in Column B based on random values in Column A , by converting the rule above into a linear model which saves me a lot of time and effort by avoiding to write 500 lines of if_then_else , code ?
Please note, I am using the intercept term when imputing for values in Column B based on values in Column A, because there is a rule that says, if Column A =0 then Column B = 37 so I am using the intercept to handle Column A =0 cases. So I am wondering if I can use this regression based approach when R2 adjusted = 0.998 instead of writing 500 lines of if-then-else or case-when statement.