I am working on a linear regression with R and there are many 0 values in my predictor variables. How are these handled in R's lm()
function? Should I remove this data for more accurate analysis?
Any advice is appreciated. Thanks.
I am working on a linear regression with R and there are many 0 values in my predictor variables. How are these handled in R's lm()
function? Should I remove this data for more accurate analysis?
Any advice is appreciated. Thanks.
The problem you described here is known as limited dependent variable problem usually represented by truncated or censored data (the former could be seen as a special case of the later). In this case application of lm()
function would not be the best choice, since it in general will produce biased and inconsistent estimates of the true regression line. However, truncation (dropping zeroes from the sample, as you suggested in the comment) will make this bias even larger.
Likely the problem is well known and there are usually two common options to solve it either to use a Tobit model or a Heckman's two step approach, it would be useful to study any common econometric textbook on the topic (this Cross Validated link will be useful). The difference in two models is that Heckman's method allows for either explanatory variables or parameter estimates to differ across the estimated parts that influence the zeros and the magnitude of the observed non zero values.
To implement the Tobit and Heckman models in R you will need sampleSelection
or censReg
packages. There are also nice Vignettes corresponding to these packages, so read them first.
What % of the predictor is 0, and what other values does it take on?
The concern is whether a predictor with such little variation (vast majority being the value of 0) would be useful in a regression model.
To approach this, you can first stratify and do one analysis with the subset of the data where predictor is 0, and another analysis where the predictor is != 0. Once you get a sense of the structure of the data, you can decide whether to proceed with analysis using the entire dataset, and whether the predictor variable should stay in the model.