🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 6 (from laksa071)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
1 month ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH1.8 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm
Last Crawled2026-02-14 13:09:57 (1 month ago)
First Indexednot set
HTTP Status Code200
Meta TitleOrdinary Least Squares (OLS) (Spatial Statistics)—ArcGIS Pro | Documentation
Meta DescriptionArcGIS geoprocessing tool that performs Ordinary Least Squares (OLS) regression.
Meta Canonicalnull
Boilerpipe Text
Illustration Ordinary Least Squares regression, predicted values in relation to observed values, is shown. Usage The primary output for this tool is a report file that is written as messages at the bottom of the Geoprocessing pane during tool execution. You can access the messages by hovering over the progress bar, clicking the pop-out button, or expanding the messages section in the Geoprocessing pane. You can also access the messages for a previous run of Exploratory Regression via the geoprocessing history . The OLS tool also produces an output feature class and optional tables with coefficient information and diagnostics. All of these are accessible from the messages at the bottom of the Geoprocessing pane . The output feature class is automatically added to the table of contents, with a hot/cold rendering scheme applied to model residuals . A full explanation of each output is provided in How OLS regression works . Results from OLS regression are only trustworthy if your data and regression model satisfy all of the assumptions inherently required by this method. Consult the Common regression problems, consequences, and solutions table in Regression analysis basics to ensure that your model is properly specified. Dependent and Explanatory variables should be numeric fields containing a variety of values. OLS cannot solve when variables have the same value (all the values for a field are 9.0, for example). Linear regression methods, such as OLS, are not appropriate for predicting binary outcomes (for example, all of the values for the dependent variable are either 1 or 0). The Unique ID field links model predictions to each feature. Consequently, the Unique ID values must be unique for every feature, and typically should be a permanent field that remains with the feature class. If you don't have a Unique ID field, you can create one by adding a new integer field to your feature class table and calculating the field values to be equal to the FID/OID field. You cannot use the FID/OID field directly for the Unique ID parameter. Whenever there is statistically significant spatial autocorrelation of the regression residuals, the OLS model will be considered misspecified. Consequently, results from OLS regression are unreliable. Be sure to run the Spatial Autocorrelation tool on your regression residuals to assess this potential problem. Statistically significant spatial autocorrelation of regression residuals almost always indicates one or more key explanatory variables are missing from the model. Visually inspect the over- and underpredictions evident in your regression residuals to see if they provide clues about potential missing variables from your regression model. It may help to run Hot Spot Analysis on the residuals to help you visualize spatial clustering of the over- and underpredictions. When misspecification is the result of trying to model nonstationary variables using a global model (OLS is a global model), Geographically Weighted Regression can be used to improve predictions and to better understand the nonstationarity (regional variation) inherent in your explanatory variables. When the result of a computation is infinity or undefined, the output for nonshapefiles will be Null; for shapefiles the output will be -DBL_MAX (-1.7976931348623158e+308, for example). Model summary diagnostics are written to the OLS summary report and the optional diagnostic output table. Both include diagnostics for the corrected Akaike Information Criterion (AICc), Coefficient of Determination, Joint F statistic, Wald statistic, Koenker's Breusch-Pagan statistic, and the Jarque-Bera statistic. The diagnostic table also includes uncorrected AIC and Sigma-squared values. The optional coefficient and diagnostic output tables, if they already exist, will be overwritten when the Allow geoprocessing tools to overwrite existing datasets option is checked on. On machines configured with the ArcGIS language packages for Arabic and other right-to-left languages, you might notice missing text or formatting problems in the PDF Output Report File . These problems are addressed in this article . Map layers can be used to define the Input Feature Class . When using a layer with a selection, only the selected features are included in the analysis. Caution: When using shapefiles, keep in mind that they cannot store null values. Tools or other procedures that create shapefiles from nonshapefile inputs may store or interpret null values as zero. In some cases, nulls are stored as very large negative values in shapefiles. This can lead to unexpected results. See Geoprocessing considerations for shapefile output for more information. Parameters Dialog Python Label Explanation Data Type Input Feature Class The feature class containing the dependent and independent variables for analysis. Feature Layer Unique ID Field An integer field containing a different value for every feature in the Input Feature Class . Field Output Feature Class The output feature class that will receive dependent variable estimates and residuals. Feature Class Dependent Variable The numeric field containing values for what you are trying to model. Field Explanatory Variables A list of fields representing explanatory variables in your regression model. Field Coefficient Output Table (Optional) The full path to an optional table that will receive model coefficients, standardized coefficients, standard errors, and probabilities for each explanatory variable. Table Diagnostic Output Table (Optional) The full path to an optional table that will receive model summary diagnostics. Table Output Report File (Optional) The path to the optional PDF file the tool will create. This report file includes model diagnostics, graphs, and notes to help you interpret the OLS results. File arcpy.stats.OrdinaryLeastSquares(Input_Feature_Class, Unique_ID_Field, Output_Feature_Class, Dependent_Variable, Explanatory_Variables, {Coefficient_Output_Table}, {Diagnostic_Output_Table}, {Output_Report_File}) Name Explanation Data Type Input_Feature_Class The feature class containing the dependent and independent variables for analysis. Feature Layer Unique_ID_Field An integer field containing a different value for every feature in the Input Feature Class . Field Output_Feature_Class The output feature class that will receive dependent variable estimates and residuals. Feature Class Dependent_Variable The numeric field containing values for what you are trying to model. Field Explanatory_Variables [Explanatory_Variables,...] A list of fields representing explanatory variables in your regression model. Field Coefficient_Output_Table (Optional) The full path to an optional table that will receive model coefficients, standardized coefficients, standard errors, and probabilities for each explanatory variable. Table Diagnostic_Output_Table (Optional) The full path to an optional table that will receive model summary diagnostics. Table Output_Report_File (Optional) The path to the optional PDF file the tool will create. This report file includes model diagnostics, graphs, and notes to help you interpret the OLS results. File Code sample OrdinaryLeastSquares example 1 (Python window) The following Python window script demonstrates how to use the OrdinaryLeastSquares function. import arcpy arcpy.env.workspace = r"c:\data" arcpy.stats.OrdinaryLeastSquares("USCounties.shp", "MYID", "olsResults.shp", "GROWTH","LOGPCR69;SOUTH;LPCR_SOUTH;PopDen69", "olsCoefTab.dbf", "olsDiagTab.dbf") OrdinaryLeastSquares example 2 (stand-alone script) The following stand-alone Python script demonstrates how to use the OrdinaryLeastSquares function. # Analyze the growth of regional per capita incomes in US # Counties from 1969 -- 2002 using Ordinary Least Squares Regression # Import system modules import arcpy # Set property to overwrite existing outputs arcpy.env.overwriteOutput = True # Local variables... workspace = r"C:\Data" try: # Set the current workspace (to avoid having to specify the full path to the feature classes each time) arcpy.env.workspace = workspace # Growth as a function of {log of starting income, dummy for South # counties, interaction term for South counties, population density} # Process: Ordinary Least Squares... ols = arcpy.stats.OrdinaryLeastSquares("USCounties.shp", "MYID", "olsResults.shp", "GROWTH", "LOGPCR69;SOUTH;LPCR_SOUTH;PopDen69", "olsCoefTab.dbf", "olsDiagTab.dbf") # Create Spatial Weights Matrix (Can be based on input or output FC) # Process: Generate Spatial Weights Matrix... swm = arcpy.stats.GenerateSpatialWeightsMatrix("USCounties.shp", "MYID", "euclidean6Neighs.swm", "K_NEAREST_NEIGHBORS", "#", "#", "#", 6) # Calculate Moran's Index of Spatial Autocorrelation for # OLS Residuals using a SWM File. # Process: Spatial Autocorrelation (Morans I)... moransI = arcpy.stats.SpatialAutocorrelation("olsResults.shp", "Residual", "NO_REPORT", "GET_SPATIAL_WEIGHTS_FROM_FILE", "EUCLIDEAN_DISTANCE", "NONE", "#", "euclidean6Neighs.swm") except: # If an error occurred when running the tool, print out the error message. print(arcpy.GetMessages()) Environments Output Coordinate System , Geographic Transformations , Current Workspace , Scratch Workspace , Qualified Field Names , Output has M values , M Resolution , M Tolerance , Output has Z values , Default Output Z Value , Z Resolution , Z Tolerance , XY Resolution , XY Tolerance Licensing information Basic: Yes Standard: Yes Advanced: Yes Related topics An overview of the Modeling Spatial Relationships toolset How Geographically Weighted Regression works Regression analysis basics Geographically Weighted Regression (GWR) Spatial Autocorrelation (Global Moran's I) Hot Spot Analysis (Getis-Ord Gi*) What is a z-score? What is a p-value? How OLS regression works What they don't tell you about regression analysis Exploratory Regression Interpreting Exploratory Regression results How Exploratory Regression works Find a geoprocessing tool Feedback on this topic?
Markdown
[Back to Top](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm) # Ordinary Least Squares (OLS) (Spatial Statistics) #### In this topic 1. [Summary](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#S_GUID-9FCE8C39-07F4-4A74-9F2E-7BFEF24FCC62) 2. [Illustration](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#I_ESRI_TOOLILLUSTRATION_56AB9BAA06444C00A098EBDFCF5403A2) 3. [Usage](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#ESRI_USAGES_3D4DD07CCDE34CDC931610085F4A4DE2) 4. [Parameters](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#GUID-9965D84B-8790-4D79-9B0C-80342B2C0B8E) 5. [Environments](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#GUID-4CF323C1-9117-42A8-BAD1-A06CC2CACB83) 6. [Licensing information](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#L_) ## Summary Performs global Ordinary Least Squares (OLS) linear regression to generate predictions or to model a dependent variable in terms of its relationships to a set of explanatory variables. ##### Note: The functionality of this tool is included in the [Generalized Linear Regression](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/generalized-linear-regression.htm) tool added at ArcGIS Pro 2.3. The Generalized Linear Regression tool supports additional models. [Learn more about how Ordinary Least Squares regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm) ## Illustration ![OLS tool illustration](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/GUID-8278E3D7-7E53-4DEF-B0B8-8BE33F969BEA-web.png) Ordinary Least Squares regression, predicted values in relation to observed values, is shown. ## Usage - The primary output for this tool is a report file that is written as [messages](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_EC4BDAB5BB444522BF0DA1050D5D00C4) at the bottom of the Geoprocessing pane during tool execution. You can [access the messages](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_EC4BDAB5BB444522BF0DA1050D5D00C4) by hovering over the progress bar, clicking the pop-out button, or expanding the messages section in the Geoprocessing pane. You can also access the messages for a previous run of Exploratory Regression via the [geoprocessing history](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_0D89ACBC4AEB43418C82B8015C2BE258). - The OLS tool also produces an output feature class and optional tables with coefficient information and diagnostics. All of these are accessible from the [messages](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_EC4BDAB5BB444522BF0DA1050D5D00C4) at the bottom of the Geoprocessing pane . The output feature class is automatically added to the table of contents, with a hot/cold rendering scheme applied to model [residuals](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm#GUID-098D339F-9442-4D2F-AA11-C72755E4866B). A full explanation of each output is provided in [How OLS regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm). - Results from OLS regression are only trustworthy if your data and regression model satisfy all of the assumptions inherently required by this method. Consult the [Common regression problems, consequences, and solutions](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm#GUID-6D27B3A1-FFC6-4BF5-893F-F6D60AB2E783) table in [Regression analysis basics](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm) to ensure that your model is properly specified. - Dependent and Explanatory variables should be numeric fields containing a variety of values. OLS cannot solve when variables have the same value (all the values for a field are 9.0, for example). Linear regression methods, such as OLS, are not appropriate for predicting binary outcomes (for example, all of the values for the dependent variable are either 1 or 0). - The Unique ID field links model predictions to each feature. Consequently, the Unique ID values must be unique for every feature, and typically should be a permanent field that remains with the feature class. If you don't have a Unique ID field, you can create one by adding a new integer field to your feature class table and calculating the field values to be equal to the FID/OID field. You cannot use the FID/OID field directly for the Unique ID parameter. - Whenever there is statistically significant spatial autocorrelation of the regression residuals, the OLS model will be considered misspecified. Consequently, results from OLS regression are unreliable. Be sure to run the [Spatial Autocorrelation](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/spatial-autocorrelation.htm) tool on your regression residuals to assess this potential problem. Statistically significant spatial autocorrelation of regression residuals almost always indicates one or more key explanatory variables are missing from the model. - Visually inspect the over- and underpredictions evident in your regression residuals to see if they provide clues about potential missing variables from your regression model. It may help to run [Hot Spot Analysis](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/hot-spot-analysis.htm) on the residuals to help you visualize spatial clustering of the over- and underpredictions. - When misspecification is the result of trying to model nonstationary variables using a global model (OLS is a global model), [Geographically Weighted Regression](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/geographically-weighted-regression.htm) can be used to improve predictions and to better understand the [nonstationarity](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm#GUID-5831FE0B-0225-45A6-AABA-D17FB73B2AE6) (regional variation) inherent in your explanatory variables. - When the result of a computation is infinity or undefined, the output for nonshapefiles will be Null; for shapefiles the output will be -DBL\_MAX (-1.7976931348623158e+308, for example). - Model summary diagnostics are written to the OLS summary report and the optional diagnostic output table. Both include diagnostics for the corrected Akaike Information Criterion (AICc), Coefficient of Determination, Joint F statistic, Wald statistic, Koenker's Breusch-Pagan statistic, and the Jarque-Bera statistic. The diagnostic table also includes uncorrected AIC and Sigma-squared values. - The optional coefficient and diagnostic output tables, if they already exist, will be overwritten when the [Allow geoprocessing tools to overwrite existing datasets](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/geoprocessing-options.htm#GUID-8A6E65E0-33A6-41A0-979E-2A2915212EAD) option is checked on. - On machines configured with the ArcGIS language packages for Arabic and other right-to-left languages, you might notice missing text or formatting problems in the PDF Output Report File. These problems are addressed in [this article](https://support.esri.com/en/technical-article/000011486). - Map layers can be used to define the Input Feature Class. When using a layer with a selection, only the selected features are included in the analysis. ## Parameters [Dialog]()[Python]() | | | | |---|---|---| | Label | Explanation | Data Type | | Input Feature Class | The feature class containing the dependent and independent variables for analysis. | Feature Layer | | Unique ID Field | An integer field containing a different value for every feature in the Input Feature Class. | Field | | Output Feature Class | The output feature class that will receive dependent variable estimates and residuals. | Feature Class | | Dependent Variable | The numeric field containing values for what you are trying to model. | Field | | Explanatory Variables | A list of fields representing explanatory variables in your regression model. | Field | | Coefficient Output Table(Optional) | The full path to an optional table that will receive model coefficients, standardized coefficients, standard errors, and probabilities for each explanatory variable. | Table | | Diagnostic Output Table(Optional) | The full path to an optional table that will receive model summary diagnostics. | Table | | Output Report File(Optional) | The path to the optional PDF file the tool will create. This report file includes model diagnostics, graphs, and notes to help you interpret the OLS results. | File | ``` arcpy.stats.OrdinaryLeastSquares(Input_Feature_Class, Unique_ID_Field, Output_Feature_Class, Dependent_Variable, Explanatory_Variables, {Coefficient_Output_Table}, {Diagnostic_Output_Table}, {Output_Report_File}) ``` | | | | |---|---|---| | Name | Explanation | Data Type | | Input\_Feature\_Class | The feature class containing the dependent and independent variables for analysis. | Feature Layer | | Unique\_ID\_Field | An integer field containing a different value for every feature in the Input Feature Class. | Field | | Output\_Feature\_Class | The output feature class that will receive dependent variable estimates and residuals. | Feature Class | | Dependent\_Variable | The numeric field containing values for what you are trying to model. | Field | | Explanatory\_Variables\[Explanatory\_Variables,...\] | A list of fields representing explanatory variables in your regression model. | Field | | Coefficient\_Output\_Table(Optional) | The full path to an optional table that will receive model coefficients, standardized coefficients, standard errors, and probabilities for each explanatory variable. | Table | | Diagnostic\_Output\_Table(Optional) | The full path to an optional table that will receive model summary diagnostics. | Table | | Output\_Report\_File(Optional) | The path to the optional PDF file the tool will create. This report file includes model diagnostics, graphs, and notes to help you interpret the OLS results. | File | ### Code sample OrdinaryLeastSquares example 1 (Python window) The following Python window script demonstrates how to use the OrdinaryLeastSquares function. ``` import arcpy arcpy.env.workspace = r"c:\data" arcpy.stats.OrdinaryLeastSquares("USCounties.shp", "MYID", "olsResults.shp", "GROWTH","LOGPCR69;SOUTH;LPCR_SOUTH;PopDen69", "olsCoefTab.dbf", "olsDiagTab.dbf") ``` OrdinaryLeastSquares example 2 (stand-alone script) The following stand-alone Python script demonstrates how to use the OrdinaryLeastSquares function. ``` # Analyze the growth of regional per capita incomes in US # Counties from 1969 -- 2002 using Ordinary Least Squares Regression # Import system modules import arcpy # Set property to overwrite existing outputs arcpy.env.overwriteOutput = True # Local variables... workspace = r"C:\Data" try: # Set the current workspace (to avoid having to specify the full path to the feature classes each time) arcpy.env.workspace = workspace # Growth as a function of {log of starting income, dummy for South # counties, interaction term for South counties, population density} # Process: Ordinary Least Squares... ols = arcpy.stats.OrdinaryLeastSquares("USCounties.shp", "MYID", "olsResults.shp", "GROWTH", "LOGPCR69;SOUTH;LPCR_SOUTH;PopDen69", "olsCoefTab.dbf", "olsDiagTab.dbf") # Create Spatial Weights Matrix (Can be based on input or output FC) # Process: Generate Spatial Weights Matrix... swm = arcpy.stats.GenerateSpatialWeightsMatrix("USCounties.shp", "MYID", "euclidean6Neighs.swm", "K_NEAREST_NEIGHBORS", "#", "#", "#", 6) # Calculate Moran's Index of Spatial Autocorrelation for # OLS Residuals using a SWM File. # Process: Spatial Autocorrelation (Morans I)... moransI = arcpy.stats.SpatialAutocorrelation("olsResults.shp", "Residual", "NO_REPORT", "GET_SPATIAL_WEIGHTS_FROM_FILE", "EUCLIDEAN_DISTANCE", "NONE", "#", "euclidean6Neighs.swm") except: # If an error occurred when running the tool, print out the error message. print(arcpy.GetMessages()) ``` ## Environments [Output Coordinate System](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/output-coordinate-system.htm), [Geographic Transformations](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/geographic-transformations.htm), [Current Workspace](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/current-workspace.htm), [Scratch Workspace](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/scratch-workspace.htm), [Qualified Field Names](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/qualified-field-names.htm), [Output has M values](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/output-has-m-values.htm), [M Resolution](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/m-resolution.htm), [M Tolerance](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/m-tolerance.htm), [Output has Z values](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/output-has-z-values.htm), [Default Output Z Value](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/default-output-z-value.htm), [Z Resolution](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/z-resolution.htm), [Z Tolerance](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/z-tolerance.htm), [XY Resolution](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/xy-resolution.htm), [XY Tolerance](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/xy-tolerance.htm) ## Licensing information - Basic: Yes - Standard: Yes - Advanced: Yes #### Related topics - [An overview of the Modeling Spatial Relationships toolset](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/an-overview-of-the-modeling-spatial-relationships-toolset.htm) - [How Geographically Weighted Regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-geographicallyweightedregression-works.htm) - [Regression analysis basics](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm) - [Geographically Weighted Regression (GWR)](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/geographicallyweightedregression.htm) - [Spatial Autocorrelation (Global Moran's I)](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/spatial-autocorrelation.htm) - [Hot Spot Analysis (Getis-Ord Gi\*)](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/hot-spot-analysis.htm) - [What is a z-score? What is a p-value?](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/what-is-a-z-score-what-is-a-p-value.htm) - [How OLS regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm) - [What they don't tell you about regression analysis](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/what-they-don-t-tell-you-about-regression-analysis.htm) - [Exploratory Regression](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/exploratory-regression.htm) - [Interpreting Exploratory Regression results](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/interpreting-exploratory-regression-results.htm) - [How Exploratory Regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-exploratory-regression-works.htm) - [Find a geoprocessing tool](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/find-geoprocessing-tools.htm) *** [Feedback on this topic?](https://pro.arcgis.com/feedback/) ##### In this topic 1. [Summary](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#S_GUID-9FCE8C39-07F4-4A74-9F2E-7BFEF24FCC62) 2. [Illustration](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#I_ESRI_TOOLILLUSTRATION_56AB9BAA06444C00A098EBDFCF5403A2) 3. [Usage](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#ESRI_USAGES_3D4DD07CCDE34CDC931610085F4A4DE2) 4. [Parameters](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#GUID-9965D84B-8790-4D79-9B0C-80342B2C0B8E) 5. [Environments](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#GUID-4CF323C1-9117-42A8-BAD1-A06CC2CACB83) 6. [Licensing information](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm#L_) [flist](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/flisting.htm)
Readable Markdown
## Illustration ![OLS tool illustration](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/GUID-8278E3D7-7E53-4DEF-B0B8-8BE33F969BEA-web.png) Ordinary Least Squares regression, predicted values in relation to observed values, is shown. ## Usage - The primary output for this tool is a report file that is written as [messages](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_EC4BDAB5BB444522BF0DA1050D5D00C4) at the bottom of the Geoprocessing pane during tool execution. You can [access the messages](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_EC4BDAB5BB444522BF0DA1050D5D00C4) by hovering over the progress bar, clicking the pop-out button, or expanding the messages section in the Geoprocessing pane. You can also access the messages for a previous run of Exploratory Regression via the [geoprocessing history](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_0D89ACBC4AEB43418C82B8015C2BE258). - The OLS tool also produces an output feature class and optional tables with coefficient information and diagnostics. All of these are accessible from the [messages](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_EC4BDAB5BB444522BF0DA1050D5D00C4) at the bottom of the Geoprocessing pane . The output feature class is automatically added to the table of contents, with a hot/cold rendering scheme applied to model [residuals](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm#GUID-098D339F-9442-4D2F-AA11-C72755E4866B). A full explanation of each output is provided in [How OLS regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm). - Results from OLS regression are only trustworthy if your data and regression model satisfy all of the assumptions inherently required by this method. Consult the [Common regression problems, consequences, and solutions](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm#GUID-6D27B3A1-FFC6-4BF5-893F-F6D60AB2E783) table in [Regression analysis basics](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm) to ensure that your model is properly specified. - Dependent and Explanatory variables should be numeric fields containing a variety of values. OLS cannot solve when variables have the same value (all the values for a field are 9.0, for example). Linear regression methods, such as OLS, are not appropriate for predicting binary outcomes (for example, all of the values for the dependent variable are either 1 or 0). - The Unique ID field links model predictions to each feature. Consequently, the Unique ID values must be unique for every feature, and typically should be a permanent field that remains with the feature class. If you don't have a Unique ID field, you can create one by adding a new integer field to your feature class table and calculating the field values to be equal to the FID/OID field. You cannot use the FID/OID field directly for the Unique ID parameter. - Whenever there is statistically significant spatial autocorrelation of the regression residuals, the OLS model will be considered misspecified. Consequently, results from OLS regression are unreliable. Be sure to run the [Spatial Autocorrelation](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/spatial-autocorrelation.htm) tool on your regression residuals to assess this potential problem. Statistically significant spatial autocorrelation of regression residuals almost always indicates one or more key explanatory variables are missing from the model. - Visually inspect the over- and underpredictions evident in your regression residuals to see if they provide clues about potential missing variables from your regression model. It may help to run [Hot Spot Analysis](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/hot-spot-analysis.htm) on the residuals to help you visualize spatial clustering of the over- and underpredictions. - When misspecification is the result of trying to model nonstationary variables using a global model (OLS is a global model), [Geographically Weighted Regression](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/geographically-weighted-regression.htm) can be used to improve predictions and to better understand the [nonstationarity](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm#GUID-5831FE0B-0225-45A6-AABA-D17FB73B2AE6) (regional variation) inherent in your explanatory variables. - When the result of a computation is infinity or undefined, the output for nonshapefiles will be Null; for shapefiles the output will be -DBL\_MAX (-1.7976931348623158e+308, for example). - Model summary diagnostics are written to the OLS summary report and the optional diagnostic output table. Both include diagnostics for the corrected Akaike Information Criterion (AICc), Coefficient of Determination, Joint F statistic, Wald statistic, Koenker's Breusch-Pagan statistic, and the Jarque-Bera statistic. The diagnostic table also includes uncorrected AIC and Sigma-squared values. - The optional coefficient and diagnostic output tables, if they already exist, will be overwritten when the [Allow geoprocessing tools to overwrite existing datasets](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/geoprocessing-options.htm#GUID-8A6E65E0-33A6-41A0-979E-2A2915212EAD) option is checked on. - On machines configured with the ArcGIS language packages for Arabic and other right-to-left languages, you might notice missing text or formatting problems in the PDF Output Report File. These problems are addressed in [this article](https://support.esri.com/en/technical-article/000011486). - Map layers can be used to define the Input Feature Class. When using a layer with a selection, only the selected features are included in the analysis. ## Parameters [Dialog]()[Python]() | | | | |---|---|---| | Label | Explanation | Data Type | | Input Feature Class | The feature class containing the dependent and independent variables for analysis. | Feature Layer | | Unique ID Field | An integer field containing a different value for every feature in the Input Feature Class. | Field | | Output Feature Class | The output feature class that will receive dependent variable estimates and residuals. | Feature Class | | Dependent Variable | The numeric field containing values for what you are trying to model. | Field | | Explanatory Variables | A list of fields representing explanatory variables in your regression model. | Field | | Coefficient Output Table(Optional) | The full path to an optional table that will receive model coefficients, standardized coefficients, standard errors, and probabilities for each explanatory variable. | Table | | Diagnostic Output Table(Optional) | The full path to an optional table that will receive model summary diagnostics. | Table | | Output Report File(Optional) | The path to the optional PDF file the tool will create. This report file includes model diagnostics, graphs, and notes to help you interpret the OLS results. | File | ``` arcpy.stats.OrdinaryLeastSquares(Input_Feature_Class, Unique_ID_Field, Output_Feature_Class, Dependent_Variable, Explanatory_Variables, {Coefficient_Output_Table}, {Diagnostic_Output_Table}, {Output_Report_File}) ``` | | | | |---|---|---| | Name | Explanation | Data Type | | Input\_Feature\_Class | The feature class containing the dependent and independent variables for analysis. | Feature Layer | | Unique\_ID\_Field | An integer field containing a different value for every feature in the Input Feature Class. | Field | | Output\_Feature\_Class | The output feature class that will receive dependent variable estimates and residuals. | Feature Class | | Dependent\_Variable | The numeric field containing values for what you are trying to model. | Field | | Explanatory\_Variables\[Explanatory\_Variables,...\] | A list of fields representing explanatory variables in your regression model. | Field | | Coefficient\_Output\_Table(Optional) | The full path to an optional table that will receive model coefficients, standardized coefficients, standard errors, and probabilities for each explanatory variable. | Table | | Diagnostic\_Output\_Table(Optional) | The full path to an optional table that will receive model summary diagnostics. | Table | | Output\_Report\_File(Optional) | The path to the optional PDF file the tool will create. This report file includes model diagnostics, graphs, and notes to help you interpret the OLS results. | File | ### Code sample OrdinaryLeastSquares example 1 (Python window) The following Python window script demonstrates how to use the OrdinaryLeastSquares function. ``` import arcpy arcpy.env.workspace = r"c:\data" arcpy.stats.OrdinaryLeastSquares("USCounties.shp", "MYID", "olsResults.shp", "GROWTH","LOGPCR69;SOUTH;LPCR_SOUTH;PopDen69", "olsCoefTab.dbf", "olsDiagTab.dbf") ``` OrdinaryLeastSquares example 2 (stand-alone script) The following stand-alone Python script demonstrates how to use the OrdinaryLeastSquares function. ``` # Analyze the growth of regional per capita incomes in US # Counties from 1969 -- 2002 using Ordinary Least Squares Regression # Import system modules import arcpy # Set property to overwrite existing outputs arcpy.env.overwriteOutput = True # Local variables... workspace = r"C:\Data" try: # Set the current workspace (to avoid having to specify the full path to the feature classes each time) arcpy.env.workspace = workspace # Growth as a function of {log of starting income, dummy for South # counties, interaction term for South counties, population density} # Process: Ordinary Least Squares... ols = arcpy.stats.OrdinaryLeastSquares("USCounties.shp", "MYID", "olsResults.shp", "GROWTH", "LOGPCR69;SOUTH;LPCR_SOUTH;PopDen69", "olsCoefTab.dbf", "olsDiagTab.dbf") # Create Spatial Weights Matrix (Can be based on input or output FC) # Process: Generate Spatial Weights Matrix... swm = arcpy.stats.GenerateSpatialWeightsMatrix("USCounties.shp", "MYID", "euclidean6Neighs.swm", "K_NEAREST_NEIGHBORS", "#", "#", "#", 6) # Calculate Moran's Index of Spatial Autocorrelation for # OLS Residuals using a SWM File. # Process: Spatial Autocorrelation (Morans I)... moransI = arcpy.stats.SpatialAutocorrelation("olsResults.shp", "Residual", "NO_REPORT", "GET_SPATIAL_WEIGHTS_FROM_FILE", "EUCLIDEAN_DISTANCE", "NONE", "#", "euclidean6Neighs.swm") except: # If an error occurred when running the tool, print out the error message. print(arcpy.GetMessages()) ``` ## Environments [Output Coordinate System](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/output-coordinate-system.htm), [Geographic Transformations](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/geographic-transformations.htm), [Current Workspace](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/current-workspace.htm), [Scratch Workspace](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/scratch-workspace.htm), [Qualified Field Names](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/qualified-field-names.htm), [Output has M values](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/output-has-m-values.htm), [M Resolution](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/m-resolution.htm), [M Tolerance](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/m-tolerance.htm), [Output has Z values](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/output-has-z-values.htm), [Default Output Z Value](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/default-output-z-value.htm), [Z Resolution](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/z-resolution.htm), [Z Tolerance](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/z-tolerance.htm), [XY Resolution](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/xy-resolution.htm), [XY Tolerance](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/environment-settings/xy-tolerance.htm) ## Licensing information - Basic: Yes - Standard: Yes - Advanced: Yes #### Related topics - [An overview of the Modeling Spatial Relationships toolset](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/an-overview-of-the-modeling-spatial-relationships-toolset.htm) - [How Geographically Weighted Regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-geographicallyweightedregression-works.htm) - [Regression analysis basics](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/regression-analysis-basics.htm) - [Geographically Weighted Regression (GWR)](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/geographicallyweightedregression.htm) - [Spatial Autocorrelation (Global Moran's I)](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/spatial-autocorrelation.htm) - [Hot Spot Analysis (Getis-Ord Gi\*)](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/hot-spot-analysis.htm) - [What is a z-score? What is a p-value?](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/what-is-a-z-score-what-is-a-p-value.htm) - [How OLS regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-ols-regression-works.htm) - [What they don't tell you about regression analysis](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/what-they-don-t-tell-you-about-regression-analysis.htm) - [Exploratory Regression](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/exploratory-regression.htm) - [Interpreting Exploratory Regression results](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/interpreting-exploratory-regression-results.htm) - [How Exploratory Regression works](https://pro.arcgis.com/en/pro-app/3.4/tool-reference/spatial-statistics/how-exploratory-regression-works.htm) - [Find a geoprocessing tool](https://pro.arcgis.com/en/pro-app/3.4/help/analysis/geoprocessing/basics/find-geoprocessing-tools.htm) *** [Feedback on this topic?](https://pro.arcgis.com/feedback/)
Shard6 (laksa)
Root Hash2426365108422851406
Unparsed URLcom,arcgis!pro,/en/pro-app/3.4/tool-reference/spatial-statistics/ordinary-least-squares.htm s443