13.07.2015 Views

Download pdf guide - VSN International

Download pdf guide - VSN International

Download pdf guide - VSN International

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1 variate 17 Employ2 variate 17 Opdays3 variate 17 Product4 variate 17 Temp5 variate 17 Water9.2 Block-if structures 1053 POINTER [VALUES=Employ,Opdays,Product,Temp] Vars4 CALCULATE Nvars = NVALUES(Vars)5 FOR [NTIMES=Nvars; INDEX=i]6 CALCULATE Corr = CORRELATION(Water; Vars[i])7 & Nobservations = NOBS(Water + Vars[i])8 & Abscorr = ABS(Corr)9 PRCORRELATION [NOBSERVATIONS=Nobservations] \10 Abscorr; CUPROBABILITY=Prob11 CALCULATE Prob = 0.5 * Prob12 PRINT Corr,Prob13 ENDFORCorr Prob0.4132 0.02480Corr Prob-0.08883 0.1836Corr Prob0.6307 0.001658Corr Prob0.2858 0.06655On the first pass through the loop, the scalar i from the INDEX option of FOR has thevalue one. So line 6 calculates the correlation between Water and the first element of theVars pointer, namely Employ. On the second pass, the correlation is between Water andOpdays, and so on.In line 7, NOBS is a summary function that gives the number of observations (i.e. nonmissingvalues). Remember from Section 5.1 that a unit inWater + Vars[i]will be missing if it is missing in either Water or Vars[i]. So Nobservations in line7 will be the number of units that available to calculate the correlation in line 6. This isthen used in line 9 by the PRCORRELATION procedure when it calculate the cumulativeupper probability Prob of the absolute correlation Abscorr. The next line multiplies theprobability by 0.5 to take account of the fact that we are doing a two-sided test.In this and later examples we have indented the contents of the loop by two spaces.This is to make it easier to read, and is not required by GenStat.9.2 Block-if structuresThe directives IF, ELSIF, ELSE, and ENDIF can be used to select between alternativesets of statements. In the simplest case, we can use this to control whether or not aparticular set of statements is executed. For exampleIF Prob .LE. 0.05PRINT 'Significant correlation'ENDIFGenStat evaluates the logical condition in the IF statement and then, if it is true, executesthe statements between IF and ENDIF; otherwise, if the condition is untrue, it skips thosestatements and continues with whatever comes after ENDIF. (Logical expressions are

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!