I have a dependent variable in my model which is non-zero only for part of all observations. The example dataset could look like this:
library(dplyr) library(ggplot2) df <- data.frame(x = c(rep(0, 10), runif(12, 0, 2000), rep(0, 8), runif(14, 0, 2000), rep(0, 23), runif(33, 0, 2000))) %>% mutate(y = exp(x / 1000) + rnorm(100, 0, 1)) %>% mutate(y = ifelse(x == 0, runif(100, 0, 10), y)) df %>% ggplot() + geom_point(aes(x, y))
So as you can see, there is a visible relationship for non-zero values of
y, but if
x == 0 the values of response variable are still varied. It's quite obvious that the problem occurs due to omitted variable bias and although I have other dependent variables to feed into my model, they can't really capture all the points of interest. I know that one way would be to limit my dataset to only those observations for which
x > 0, however it's unfortunetely not an option for me. So I wanted to ask how can I handle such a relationship in multivariable linear regression so I could fit a non-linear function to x (probably exponens in the case shown)? I was thinking about something like creating a dummy variable that would indicate if
x > 0 and potentially capture a little bit of variance from
x == 0 by predicting the mean of all those points. However, I'm not really sure if that's a valid approach and was thinking about possible alternatives.