Select to view content in your preferred language

OLS and Time

568
3
10-28-2013 06:45 AM
RobertFord1
Frequent Contributor
Is there are a way to perform OLS only on selected records/years from my feature layer? I am trying to analyze species occurrence over time. I have a "Year" field that denotes different years worth of data. I am using ArcGIS 10.1 SP1 on Win7 x64

Thanks!
0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor
Is there are a way to perform OLS only on selected records/years from my feature layer? I am trying to analyze species occurrence over time. I have a "Year" field that denotes different years worth of data. I am using ArcGIS 10.1 SP1 on Win7 x64

Thanks!


Hi Robert,

If you have a lot of years in your data you may want to consider using Python:

import arcpy, os
from arcpy import env

ws = "c:/Folder/yourFileGeodatabase.gdb" # change this
fcName = "yourFC"                        # change this

# fields in input FC
fldYear = "Year"
fldID = "yourUniqueIDfieldName"          # change this
fldDepVar = "Rainfall"                   # change this: Dependent_Variable
fldExpVar = "Temperature;..."            # change this: Explanatory_Variables
Coefficient_Output_Table = "olsCoefTab"
Diagnostic_Output_Table = "olsDiagTab"
olsReport = "c:/Folder/OLSreport"


# set workspace
env.workspace = ws

# create unique set of values in Year field
fc = ws + os.sep + fcName
values = [row[0] for row in arcpy.da.SearchCursor(fc, (fldYear))]
uniqueYears = set(values)


# loop through the values
for year in uniqueYears:

    # create feature layer for year
    qDef = "{0} = {1}".format(fldYear,year)
    fcFL = "Year_{0}".format(year)
    arcpy.MakeFeatureLayer_management(fc,fcFL,qDef,"#")

    # perform OLS on feasturelayer
    fcOLS = "OLS_{0}".format(year)
    ols = arcpy.OrdinaryLeastSquares_stats(fcFL, fldID, fcOLS, fldDepVar, fldExpVar, "{0}{1}".format(Coefficient_Output_Table,year),"{0}{1}".format(Diagnostic_Output_Table,year),"{0}{1}.pdf".format(olsReport,year))


This code will make a unique list of years, and then loop through the years, create a featurelayer based on that year and perform an OLS on it. The result for the year 2000 will be:

  • OLS_2000 (OLS featureclass)

  • olsCoefTab2000 (Coefficient Output Table)

  • olsDiagTab2000 (Diagnostic Output Table)

  • OLSreport2000.pdf (OLS report as PDF)


I haven't tested the code. See for more explanation on how to define the required variables for OLS:
Ordinary Least Squares (OLS) (Spatial Statistics)


Kind regards,

Xander
0 Kudos
RobertFord1
Frequent Contributor
Xander,

Thanks for the help! I have 10 years worth of data. Also, after reading the OLS link you provided, I noticed it said that it is not recommended for predicting binary outcomes. My dependent variable is just that: presence (1) or absence (0) of a species. Should I continue to use OLS? What is the best tool in ArcGIS for predicting binary outcomes?

Thanks a million!
0 Kudos
XanderBakker
Esri Esteemed Contributor
Xander,

Thanks for the help! I have 10 years worth of data. Also, after reading the OLS link you provided, I noticed it said that it is not recommended for predicting binary outcomes. My dependent variable is just that: presence (1) or absence (0) of a species. Should I continue to use OLS? What is the best tool in ArcGIS for predicting binary outcomes?

Thanks a million!


Hi Robert,

Do you think there is a relationship between the occurence of a specie and the other data your have (I believe you had rainfall and temperature?). What happens if you plot the rainfall vs the temperature for all polygons where species occur and you also plot this for those polygons where the species don't occur. Do you see any relationship?

Can you convert the binary data of the occurrences into richer data (count)?

I came across this presentation on Models for binary data: Logit and Probit by Kenneth Benoit, but I don't know if it's useful.


Kind regards,

Xander
0 Kudos