Skip to content

Instantly share code, notes, and snippets.

@AndrewTheTM
Created July 24, 2015 15:00
Show Gist options
  • Save AndrewTheTM/63ee34f08f0737306782 to your computer and use it in GitHub Desktop.
Save AndrewTheTM/63ee34f08f0737306782 to your computer and use it in GitHub Desktop.
Voyager Pearsons Correlation Coefficient
; Do not change filenames or add or remove FILEI/FILEO statements using an editor. Use Cube/Application Manager.
RUN PGM=MATRIX PRNFILE="C:\MODELRUN\TRUCKMODEL\CUBE\NPMAT00A.PRN"
FILEO PRINTO[1] = "C:\Modelrun\TruckModel\Cube\Inputs\InitStats.RPT"
FILEI DBI[1] = "C:\Modelrun\TruckModel\Cube\Inputs\TrucksLoaded.DBF"
PAR ZONES = 1
LOOP r = 1, DBI.1.NUMRECORDS
x=DBIReadRecord(1, r)
IF(DI.1.TSCN > 0)
n = n + 1
xx = xx + DI.1.AADT_TRK
y = y + DI.1.V_1
ENDIF
ENDLOOP
mux = xx / n
muy = y / n
PRINT PRINTO = 1, LIST = "Avg AADT_TRK = ",mux
PRINT PRINTO = 1, LIST = "Avg VOLUME = ",muy
PRINT PRINTO = 1, LIST = "n = ",n,"\n\n\n"
n = 0
LOOP r = 1, DBI.1.NUMRECORDS
x=DBIReadRecord(1, r)
IF(DI.1.TSCN > 0)
num = num + ((DI.1.AADT_TRK - mux) * (DI.1.V_1 - muy))
sdx1 = sdx1 + (DI.1.AADT_TRK - mux)^2
sdy1 = sdy1 + (DI.1.V_1 - muy)^2
n = n + 1
ENDIF
ENDLOOP
PRINT PRINTO = 1 LIST = "sdx1 = ",sdx1
PRINT PRINTO = 1 LIST = "sdy1 = ",sdy1
sdx = sqrt(sdx1 / n)
sdy = sqrt(sdy1 / n)
r2 = num / (sdx * sdy)
PRINT PRINTO = 1 LIST="n = ",n
PRINT PRINTO = 1 LIST="sd AADT_TRK = ",sdx
PRINT PRINTO = 1 LIST="sd Volume = ",sdy
PRINT PRINTO = 1 LIST="r2 = ",r2
ENDRUN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment