               NEWS NLREG has been selected as the "Editor"s Pick" by SoftSeek. NLREG is in use at hundreds of universities, laboratories, and government agencies around the world (over 20 countries). For a list of a few organizations using NLREG click here. If you have categorical variables, you may want to use a Decision Tree to model your data. Check out the DTREG Decision Tree Builder. You also should check out the News Rover program that automatically scans Usenet newsgroups, downloads messages of interest to you, decodes binary file attachments, reconstructs files split across multiple messages, and eliminates spam and duplicate files.  ## Orthogonal Regression

In ordinary linear regression, the goal is to minimize the sum of the squared vertical distances between the y data values and the corresponding y values on the fitted line. In orthogonal regression the goal is to minimize the orthogonal (perpendicular) distances from the data points to the fitted line.

The slope-intercept equation for a line is:

Y = m*X + b

where m is the slope and b is the intercept.

A line perpendicular to this line will have -(1/m) slope, so the equation will be:

Y' = -X/m + b'

If this line passes through some data point (X0,Y0), its equation will be:

Y' = -X/m + (X0/m + Y0)

The perpendicular line will intersect the fitted line at a point (Xi,Yi) where Xi and Yi are defined by:

Xi = (X0 + m*Y0 - m*b) / (m^2 + 1)
Yi = m*Xi + b

So the orthogonal distance from (X0,X0) to the fitted line is the distance between (X0,Y0) and (Xi,Yi) which is computed as:

distance = sqrt((X0-Xi)^2 + (Y0-Yi)^2)

So the goal of the NLREG program is to minimize the sum of these orthogonal distances. Here is a NLREG program that does this:

```Title "Fit a line to data points minimizing orthogonal distances";
Variables X0, Y0;
Parameters m, b;
Double Xi, Yi, distance;
Xi = (X0 + m*Y0 - m*b) / (m^2 + 1);
Yi = m*Xi + b;
distance = sqrt((X0-Xi)^2 + (Y0-Yi)^2);
Function distance;
Data;
```

For an example of a NLREG program that performs orthogonal regression to a 3D plane, please click here.