I am working with loan data. I have a field for "months since last delinquency". If a borrower has not been delinquent on any of their accounts for the past 7 years, this field has missing value (NA). As you can see, this is a "genuine" case of missing data.

In the dataset I got, the field is missing only for less than 4% of the data points (306 out of 8965), but dropping the rows will exclude the "good" borrowers and bias the dataset. Also, I believe this field is of value for prediction purposes, so I don't want to remove it.

I know tree-based models can handle missing values. In fact, I already have a model built with XGBoost and it has decent performance.

Now I want to build a simpler linear regression model (with regularization) for making the case that the XGBoost model is worth its complexity. This requires me to impute these missing values.

What is the value I can use for imputing the missing values? Setting it to 84 (number of months in 7 years) seems to make some sense, but that would mean the borrower was last delinquent 84 months ago, which is not true. I am also worried about imputing the value to something very large (like 999), since these points may then have high leverage.

Here is the summary of the data (in R code):

> nrow(loans)
[1] 8965

> summary(loans$MONTHS_SINCE_DEL)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
  0.000   0.000   1.000   5.058   3.000  81.000     306 

How does one deal with this problem in practice, when working with models that cannot handle missing values?

  • 3
    $\begingroup$ You could try including a missing indicator and then imputing a constant for the missing values. The missing indicator would capture the effect of never having been delinquent, and the constant you impute is just a "dummy" value that ends up being irrelevant in terms of the estimated slope for the predictor. $\endgroup$
    – dsaxton
    Nov 14, 2016 at 21:58
  • 2
    $\begingroup$ I believe most people would characterize these data as not applicable rather than "missing." There is nothing to impute. If your model requires a value for such observations, then it's simply not applicable and you should choose an applicable model rather than trying to invent meaningless data to put into it. $\endgroup$
    – whuber
    Nov 14, 2016 at 22:26
  • $\begingroup$ @whuber What problem do you see with dsaxton's approach? $\endgroup$
    – arun
    Nov 14, 2016 at 23:10
  • $\begingroup$ It goes in the right direction--and it's different than any that might be suggested by how you have formulated the problem, because it uses an appropriate model. I think its description might be a little deceptive, though, because nothing needs to be imputed. The constant merely is a placeholder to allow the usual matrix software to do its calculations. I have recommended similar solutions; see stats.stackexchange.com/a/4833 for instance. $\endgroup$
    – whuber
    Nov 14, 2016 at 23:13
  • $\begingroup$ For what it's worth, this kind of data is called "right censored": you know it was at least 84 months, but not how much it might actually be. If you would throw these rows out because of the NA's, you will have "right truncated" your samples. (It would make no sense to take a survival analysis approach to your problem, just throwing the phrases out there.) $\endgroup$
    – Wayne
    Nov 14, 2016 at 23:31

3 Answers 3


One possible solution... Discretize the "months since last delinquency" variable and into categories such as:

  1. Never delinquent (based on NAs)
  2. Last delinquent 0 to 12 months ago
  3. Last delinquent 13 to 34 months ago
  4. And so on...

Or use some modification of this, and use dummy variables in the regression to estimate the parameters associated with each category. Playing around with the category definitions to find appropriate cut points would be good.


  • It incorporates all the available information without imputation
  • It may have the benefit of capturing different effect sizes of time since delinquency (rather than assuming a linear slope).


  • It does require more parameters to be estimated in your model
  • Coefficients for dummy variables won't have the standard linear coefficient interpretation. But they're still relatively straightforward to interpret.

Edit: You do not have missing data, therefore imputation is not justified at a theoretical level. At a more practical level, if you were to impute the NAs, they would be assigned values that will have to be based on the data (people) that already exist in full. This will give the "non-delinquents" values of around 0 to 81, meaning the imputed data would essentially say, these people actually are delinquents. This is untrue and will bias your model. Additionally, your model will only be applicable to "delinquents" since it will only have data for "delinquents" in it (imputed or otherwise).


Creating an extra binary variable for delinquency could be an option too. You could possibly impute some value (84 or so), which will be less important in the model in combination with the new dummy.


You have two things going on here: the missing data and the loans that were always current. You have to handle them differently.

If you can imply that the loan was always current by looking at other fields, then you should add a new indicator column (variable) to encode these loans. The time since default is meaningless for these loans.

For loans that were delinquent at some point but the column has NA you have a case of missing data. You may need to impute this data if possible, but likely cannot.


Your Answer

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

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