level | typeofA | typeofB | typeofC | var |
A | x | . | . | . |
A | y | . | . | 55 |
B | . | p | . | 10.5 |
B | . | q | . | . |
B | . | r | . | 20 |
C | . | . | s | 43.1 |
C | . | . | t | . |
If there is a missing value in var:
if the observation belongs to level A
- If typeofA = x, then impute with mean(var) of x
- if typeofA = y, then impute with mean(var) of y
- and so on
There are a lot of types for each level, so i don't know if I can hardcode this. Maybe I have to use a loop for this, but I am really lost and don’t know where to begin.
0 Response to imputing missing values based on categories of other variables
Post a Comment