# How are zero values handled in lm()?

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?

• The zero is an observable value, that is your predictor can take such a value?
– chl
Commented Mar 5, 2011 at 19:09
• If zero is special, that suggests the response is non-negative or bounded at zero. Is that the case? Commented Mar 5, 2011 at 19:18
• 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.
– whuber
Commented Mar 5, 2011 at 19:19
• 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... Commented Mar 5, 2011 at 20:54
• @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? Commented Mar 6, 2011 at 7:32

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.

• 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? Commented Nov 7, 2013 at 19:07
• @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. Commented 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.