Chat with us, powered by LiveChat

What’s this about?

Nonparametric regression, like linear regression, estimates mean outcomes for a given set of covariates.

Unlike linear regression, nonparametric regression is agnostic about the functional form between the outcome and the covariates and is therefore not subject to misspecification error.

In nonparametric regression, you do not specify the functional form. You specify the dependent variable—the outcome—and the covariates. 

The method does not assume that g() is linear; it could just as well 

The method does not even assume the function is linear in the parameters. It could just as well be

Or it could be anything else.

The result is not returned to you in algebraic form, but predicted values and derivatives can be calculated. To fit whatever the model is, you type

npregress needs more observations than linear regression to produce consistent estimates, of course, but perhaps not as many extra observations as you would expect. A model like this one could easily be fit on 500 observations.

Let’s see it work

We have fictional data on wine yield (hectoliters) from 512 wine-producing counties around the world. That will be our dependent variable. We believe output is affected by

taxleveltaxes on wine production
rainfallrainfall in mm/hour
avgtempaverage temperature in degrees Celsius
irrigatewhether winery irrigates
organicwhether winery uses organic fertilizers

We will ultimately fit a model of hectoliters on all the above variables, but we will start with a model of hectoliters on taxlevel so that we can show you a graph of the result, which is the nonlinear function that npregress produces.

First, we fit the model:

There are two parts to the output.

The first part reports two bandwidths, one for calculating the mean and the other for calculating the effect. These are technical details but sometimes useful.

The second part reports the fitted results as a summary about the fitted model’s predictions.

The first summary is about the average predicted value of hectoliters given taxlevel and is not especially interesting. It is 433.

The second summary is more interesting. It reports the average derivative of hectoliters with regard to taxlevel, what economists would call the marginal effect of taxes on production. It is −312.

That means higher taxes result in lower output. It is significant, too.

At this point, you may be thinking you could have obtained a different kind of average tax effect using linear regression. You would be right.

You could have typed regress hectoliters taxlevel, and you would have obtained −245 as the average effect.

npregress provides more information than just the average effect. It fit an entire functon and we can graph it. The function is shown in red on top of the data:

The effect of taxes is not linear! In fact, you now understand why regress reported a smaller average effect than npregress reported. The tax-level effect is bigger on the front end.

We wanted you to see the nonlinear function before we fit a model in higher dimensional space. In higher dimensional space, we will not be able to graph the function using npgraph, but we will be able to use Stata’s margins and marginsplot commands to obtain and help us visualize the effects.

Here is our full model:

Reported are average effects for each of the covariates.

To help us understand the function, we can use margins. What would happen to output if tax rates were increased by 15%? The answer is that output would fall by 36.9 hectoliters, or about 8.5%:

We said output falls by about 8.5%. We calculated that by hand based on the −36.9 hectoliter decrease and average level of output of 432.

We can explore tax-level changes graphically, too. The above output was for a taxlevel increase of 15%. Here are the results for tax-levels of 10–30%:

Just as in the one-variable case, we see that tax-level effects are largest at the front end.

You can also contact us  for this service or view other services .

External links


  1. Just want to say your article is as amazing. The clearness in your post is simply excellent and i could assume you’re an expert on this subject. Well with your permission allow me to grab your feed to keep up to date with forthcoming post. Thanks a million and please carry on the rewarding work.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Share your experience.

× Chat with me