home *** CD-ROM | disk | FTP | other *** search
- # include <stdio.h>
- # include <stdlib.h>
- # include <math.h>
- # include "gj.h"
- # include "mulreg.h"
- # include "miscio.h"
-
- float storedata[10][2];
- float sales[10];
- float eqncoef[3];
- float coefsig[3];
- int numobs;
- int numiv;
- int i;
- char error;
- float yest[10];
- float resid[10];
- float rsq;
- float r;
- float see;
- char varstring[8][32];
-
-
- void DisplayRegData()
- {
- int i;
- int j;
-
- ClrScr();
- printf("multiple regression - store sales vs district income and population\n");
- printf("\n");
- printf(" actual district district estimated \n");
- printf("index sales income population sales residuals\n");
- printf("===== ===== ======== ========== ========= =========\n");
- for ( i = 0; i <= numobs-1; ++i ) {
- printf("%2d %8.2f %8.2f %8.2f %8.2f %8.2f\n", i,
- sales[i], storedata[i][0], storedata[i][1],
- yest[i], resid[i]);
- }
- printf("\n");
- printf("estimated regression equation is: \n");
- printf("%s %s\n", varstring[0] ," (y) = variable x coefficient error" );
- printf( " ======== =========== =====\n");
- for ( i = 0; i <= 2; ++i ) {
- printf(" %s %2d %s %10s %8.2f %8.2f\n", " x( ",i ,
- " ) ",(varstring[i]), eqncoef[i], coefsig[i]);
- }
- printf(" correlation coef (r ) = %4.3f coefficient OF determination rsqr = %4.3f\n", r, rsq);
- printf("standard error of estimate (see) = %10.2f\n", see);
- printf( "press carriage return to end program");
- }
-
-
-
- void main()
- {
- storedata[0][0] = 305.0;
- storedata[0][1] = 35.0;
- storedata[1][0] = 130.0;
- storedata[1][1] = 98.0;
- storedata[2][0] = 189.0;
- storedata[2][1] = 83.0;
- storedata[3][0] = 175.0;
- storedata[3][1] = 76.0;
- storedata[4][0]= 101.0;
- storedata[4][1]= 93.0;
- storedata[5][0] = 269.0;
- storedata[5][1] = 77.0;
- storedata[6][0] = 421.0;
- storedata[6][1] = 44.0;
- storedata[7][0] = 195.0;
- storedata[7][1] = 57.0;
- storedata[8][0] = 282.0;
- storedata[8][1] = 31.0;
- storedata[9][0] = 203.0;
- storedata[9][1] = 92.0;
- sales[0]= 20.0;
- sales[1]= 15.0;
- sales[2] = 17.0;
- sales[3] = 9.0;
- sales[4] = 16.0;
- sales[5] = 27.0;
- sales[6] = 35.0;
- sales[7] = 7.0;
- sales[8] = 22.0;
- sales[9] = 23.0;
- strcpy(varstring[0], "sales");
- strcpy(varstring[1], "constant");
- strcpy(varstring[2], "income");
- strcpy(varstring[3], "population");
- numobs = 10;
- numiv = 2;
- MultipleReg(&storedata[0][0],sales,numiv,numobs,eqncoef,yest,resid,&see,coefsig,&rsq,&r,&error);
- DisplayRegData();
- }