Correlation

Created:6/18/2002
Description:

This sample consists of three classes and a form. The GeneralRegressor class uses a least squares algorithm to fit a curve to a dataset using an Nth degree polynomial. The BivariateRegressor draws on the GeneralRegressor to fit a regression curve to the data in two fields in a feature class. The RegressorUI provides the user access to the CalculateCorrelation form (pictured below) through the Feature Layer context menu. The form allows the user to select two fields from a feature layer and calculate their correlation. It returns an R-squared value and the Y intercept and slope of the regression line. It also asks the user to input the name of a field which will be used to store residual values for each feature in the feature layer. If this field does not exist in the feature layer, the BivariateRegressor will add it.



How to use:
  1. Ensure that you have a copy of the DLL on your local machine (Either compile the project or use the DLL provided)
  2. In ArcMap, open the Customize dialog by selecting Tools: Customize...
  3. In the Tool Bars tab make sure Context Menus is checked
  4. In the Commands tab select the Add from file... button, and add the Regression.dll file in the subsequent dialog.
  5. You should now be in the Analysis Samples category in the left pane of the Commands tab. Select the Correlation command from the right pane, and drag and drop it into the Feature Layer context menu. Close the customization dialog.
  6. To apply the correlation command, right-click on a feature layer, and select Correlation.

Application:
ArcMap

Requires: An ArcMap session with a feature layer.

Difficulty: Intermediate


Visual Basic
File Description
RegressorUI.cls Implements the ICommand interface to add the correlation tool to the UI.
BivariateRegressor.cls Uses takes to fields from a feature class and calculates their correlation
GeneralRegressor.cls Fits a nth degree polynomial to a dataset.
Regression.vbp Visual Basic project file.
Regression.dll The compiled component.
frmCalculateCorrelation.frm Dialog box for calculating correlation and regression curve.


Key CoClasses: Table, Field
Key Interfaces: ICommand, ICursor, ITable, IField
Key Members: AddField