Skip To Content
ArcGIS Developer
Dashboard

Generalized Linear Regression

Description

Generalized Linear Regression

This tool performs generalized linear regression (GLR) to generate predictions or to model a dependent variable's relationship to a set of explanatory variables. The GeneralizedLinearRegression tool can be used to fit continuous (Gaussian and OLS), binary (logistic), and count (Poisson) models.

The following are examples of the types of questions you can answer using this tool:

  • What demographic characteristics contribute to high rates of public transportation use?
  • Is there a positive relationship between vandalism and burglary?
  • Which variables effectively predict 911 call volume? Given future projections, what is the expected demand for emergency response resources?
  • What variables affect low birth rates?

Request parameters

ParameterDetails
inputLayer

(Required)

The layer containing the dependent and independent variables.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST Examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"inputLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter":"Month = 'September'"}
featuresToPredict

(Optional)

A layer containing features representing locations where estimates should be computed. Each feature in this dataset should contain values for all the explanatory variables specified. The dependent variable for these features will be estimated using the model calibrated for the input layer data.

Syntax: As described in Feature input, this parameter can be one of the following:

  • A URL to a feature service layer with an optional filter to select specific features
  • A URL to a big data catalog service layer with an optional filter to select specific features
  • A feature collection

REST Examples

//REST web example
{"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}

//REST scripting example
"pointLayer": {"url": "https://myportal.domain.com/server/rest/services/Hosted/hurricaneTrack/FeatureServer/0", "filter": "Month = 'September'"}
dependentVariable

(Required)

The numeric field containing the observed values to be modeled.

REST Examples

//REST web example
Earnings

//REST scripting examples
"dependentVariables": "Arrest"
explanatoryVariables

(Required)

One or more fields representing independent explanatory variables in the regression model.

REST Examples

//REST web example
Rate

//REST scripting example
"explanatoryVariables": "Rating,Nights"
regressionFamily

(Required)

Specifies the type of data to be modeled. This parameter can be defined as one of the following:

  • Continuous—The dependentVariable is continuous. The model used is Gaussian, and the tool performs ordinary least squares regression.
  • Binary—The dependentVariable represents presence or absence. Values must be 0 (absence) or 1 (presence), or mapped to 0 and 1 values using the parameter.
  • Count—The dependentVariable is discrete and represents events such as crime counts, disease incidents, or traffic accidents. The model used is Poisson regression.

REST Examples

//REST web example
Continuous

//REST scripting example
"regressionFamily": "Binary"
generateCoefficientTable

(Optional)

Specifies whether a table with coefficient values will be returned. By default, the coefficient table is not returned.

Values: true | false

REST Examples

//REST web example
false

//REST scripting example
"generateCoefficientTable": false
explanatoryVariableMatching

(Optional)

A list of the explanatoryVariables specified from the inputLayer and their corresponding fields from the featuresToPredict. By default, if an explanatoryVariable is not mapped, it will match to a field with the same name in the featuresToPredict. This parameter is only used if there is a featuresToPredict input. You do not need to use it if the names and types of the fields match between your two input datasets.

predictionLayerField is the name of a field specified in the explanatoryVariables parameter and trainingLayerField is the field that will match to the field in the explanatoryVariables parameter.

REST Examples

//REST web example
[{"predictionLayerField": "CrimeType", "trainingLayerField": "TypeOfCrime"},{"predictionLayerField": "population", "trainingLayerField": "population"}]

//REST scripting example
"explanatoryVariableMatching": [{"predictionLayerField": "isSunny", "trainingLayerField": "isSunny2010"}]
dependentMapping

(Optional)

A list representing the values used to map to 0 (absence) and 1 (presence) for binary regression. value0 is the string that will be used to represent 0 and value1 is the string that will be used to represent 1.

REST Examples

//REST web example
[{"value0": "NoArrest"},{"value1": "Arrest"}]

//REST scripting example
"dependentMapping": [{"value0": "Fail"},{"value1": "Pass"}]
outputName

(Required)

The task will create a feature service of the results. You define the name of the service.

REST Examples

//REST web example
myOutput

//REST scripting example
"outputName": "myOutput"
context

(Optional)

The context parameter contains additional settings that affect task execution. For this task, there are four settings:

  • Extent (extent)—A bounding box that defines the analysis area. Only those features that intersect the bounding box will be analyzed.
  • Processing spatial reference (processSR)—The features will be projected into this coordinate system for analysis.
  • Output spatial reference (outSR)—The features will be projected into this coordinate system after the analysis to be saved. The output spatial reference for the spatiotemporal big data store is always WGS84.
  • Data store (dataStore)—Results will be saved to the specified data store. The default is the spatiotemporal big data store.

Syntax:
{
"extent" : {extent},
"processSR" : {spatial reference},
"outSR" : {spatial reference},
"dataStore":{data store}
}

f

The response format. The default response format is html.

Values: html | json

Example usage

The following is a sample request URL for GeneralizedLinearRegression:

https://machine.domain.com/webadaptor/rest/services/System/GeoAnalyticsTools/GPServer/GeneralizedLinearRegression/submitJob?predictionType=Train&inputLayer={"url":"https://webadaptor.domain.com/server/rest/services/Hurricane/hurricaneTrack2017/0"}&featuresToPredict={"url":"https://webadaptor.domain.com/server/rest/services/Hosted/corpusChristi/0"}&dependentVariable=ShelterCapacity&explanatoryVariables=CityDensity, ShelterLocations&regressionFamily=Binary&generateCoefficientTable=false&explanatoryVariableMatching=[{"predictionLayerField":"Hurricane2019","trainingLayerField":"hurricanesIn2019"},{"predictionLayerField":"ShelterLocations","trainingLayerField":"CorpusChristiShelters"}]&dependentMapping=[{"value0":"Shelter"},{"value1":"NoShelter"}]&outputName=myOutput&context={"extent":{"xmin":-122.68,"ymin":45.53,"xmax":-122.45,"ymax":45.6,"spatialReference":{"wkid":4326}}}&f=json

Response

When you submit a request, the service assigns a unique job ID for the transaction.

Syntax:
{
"jobId": "<unique job identifier>",
"jobStatus": "<job status>"
}

After the initial request is submitted, you can use jobId to periodically check the status of the job and messages as described in Check job status. Once the job has successfully completed, use jobId to retrieve the results. To track the status, you can make a request of the following form:

https://<analysis url>/GeneralizedLinearRegression/jobs/<jobId>

Access results

When the status of the job request is esriJobSucceeded, you can access the results of the analysis by making a request of the following form:

https://<analysis-url>/GeneralizedLinearRegression/jobs/<jobId>/results/<response type>?token=<your token>&f=json

ResponseDescription
output

The input features that are fit to the model. The type of feature (table, point, line, or polygon) depends on the input layers.

{"url": "https://<analysis-url>/GeneralizedLinearRegression/jobs/<jobId>/results/output"}

The result has properties for parameter name, data type, and value. The contents of value depend on the outputName parameter provided in the initial request. The value contains the URL of the feature service layer.

{
"paramName":"output", 
"dataType":"GPRecordSet",
"value":{"url":"<hosted featureservice layer url>"}
}

See Feature output for more information about how the result layer is accessed.

outputPredicted

The features predicted using the model. The type of feature (table, point, line, or polygon) depends on the input layers. This result is optional and is only returned when featureToPredict is provided as input.

{"url": "https://<analysis-url>/GeneralizedLinearRegression/jobs/<jobId>/results/outputPredicted"}
coefficientTable

A table representing the coefficients from the model fit. This result is optional and is only returned when generateCoefficientTable is true.

{"url": "https://<analysis-url>/GeneralizedLinearRegression/jobs/<jobId>/results/coefficientTable"}
processInfo

The processInfo parameter contains strings that summarize the ForestBasedClassificationAndRegression result. These strings are used for reporting by GeneralizedLinearRegression in Map Viewer. You can create custom reports for your application using these strings. There are four parts in the returned JSON as follows:

  • messageCode—The serial number for each unique message
  • message—Text that may or may not contain parameters (in ${paramsName} format) that need to be replaced by values
  • params—A dictionary of the keys and values to be inserted into the ${paramsName} parameter in the message
  • style—The formatting of the report produced by the GeneralizedLinearRegression tool in Map Viewer.

{
  "messageCode" : "SS_84507",
  "message" : ["Attribute", "Min", "Max", "SD", "Mean","Input"],
  "params" : {},
  "style" : "<table><tr><th></th><th></th><th></th><th></th><th></th><th></th></tr>"
}