APPENDIX 2

Method of Least Squares

The following programs, written in Microsoft FORTRAN for the IBM PC,1 solve the 2-variable regression analysis using the method of least squares. The program allows for the regression of two series against one another, and the regression of one series against time.

OPERATING INSTRUCTIONS

In the following example, the user's entries are underlined:

LSTSQ
Enter data in sets of 2 (Y then X).
If second variable is omitted, sequential numbers will be used for x.
Extra <return> ends input.
Enter below:
YYYYYY XXXXXX
1.27   2.43
1.19   2.26
1.10   2.15
<RETURN>
Print data (Y/N)? Y
(Computer prints data and solutions)

Sample results (Y/N)?Y
Enter start, end and increments below
ssssss eeeeee iiiiii
1.00   7.00   .50
(Computer prints sample results)
Plot results (Y/N)?Y
Name for X-scale (9 chars)?
SOYBEANS
Name for Y-scale (9 chars)?
CORN
Which plot?
   1: Linear
   2: Logarithmic
   3: Exponential
   4: Curvilinear
Which number? 1
(Computer plots)
Another plot (Y/N)?Y
Which plot?
   1: Linear
(and so forth)

COMPUTER PROGRAMS

1 $TITLE: ‘LSTSQ: LEAST SQUARES’ 2 $SUBTITLE: ‘COPYRIGHT 1986 P J KAUFMAN’ 3 $STORAGE:2 4 PROGRAM LSTSQ 5 C---- Least Squares Regression Analysis for 2 variables 6 7 CHARACTER*1 ANS 8 DIMENSION X(100),Y(100) 9 10 DATA MAX/100/ 11 12 OPEN(6,FILE=‘PRN’) 13 14 C---- Read data in sets of 2 variables 15 I = 1 16 WRITE(*,7000) 17 7000 FORMAT(‘ Enter data in sets of 2 (Y then X).’/ 18 + ‘ If second variable is omitted, sequential numbers’, 19 + ‘ will ...

Get New Trading Systems and Methods, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.