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.

  • 2
    $\begingroup$ The zero is an observable value, that is your predictor can take such a value? $\endgroup$
    – chl
    Mar 5, 2011 at 19:09
  • $\begingroup$ If zero is special, that suggests the response is non-negative or bounded at zero. Is that the case? $\endgroup$ Mar 5, 2011 at 19:18
  • 1
    $\begingroup$ To echo @chl: in some contexts the zero might be a code for a missing value or an undetectable amount, whereas in other contexts it might be a "true" zero (e.g., a count). The proper way to deal with these situations varies radically. $\endgroup$
    – whuber
    Mar 5, 2011 at 19:19
  • $\begingroup$ someone remind me - "predictor variables" are what another third of the world calls "covariates" and another third calls "explanatory variables" yup? Actually there's another third that either calls them dependent or independent variables, I forget which... $\endgroup$
    – Spacedman
    Mar 5, 2011 at 20:54
  • $\begingroup$ @chi yes, the zero is a valid value. these are all spending variables and the 0 indicates that there was no spend. The goal is to understand how spending impacts response. Are the zero's included in the calculation of lm()? If I want to omit them should I convert them to NA and use na.omit to ignore them? $\endgroup$ Mar 6, 2011 at 7:32

2 Answers 2


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.

  • 1
    $\begingroup$ Sorry to resurrect this thread, but I came across this through google. It looks like the question is asking about zeros in his independent variables. In that case, it's not a sample selection problem right? $\endgroup$
    – jseabold
    Nov 7, 2013 at 19:07
  • $\begingroup$ @jseabold, thanks a lot, yes you are right, the correct link to the answer is in one of W.Huber's comments below the original question. $\endgroup$ May 6, 2014 at 18:57

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.