STATISTICA







STATISTICA BASIC Program Resplots.stb

{ This program will fetch the data from the Predicted & Residual Values Scrollsheet (in Multiple Regression, Residual Analysis dialog), and produce:
[Graph]   [Graph]
1. a 2D plot of the case numbers versus the standardized residual values; in this plot all standardized residuals with absolute values greater than 2 will be highlighted and labeled.   2. a 3D scatterplot of the case numbers (x) by observed values (y) by standardized residuals (z)

Program written, modified, or edited at StatSoft, Inc.}


randomaccess;
NoDataFileVariableNames;
{ get the Scrollsheet handle for the currently active
  (highlighted) Scrollsheet }
	handl:=GetScrollsheet (0); {get the Scrollsheet handle of the currently
			         active (highlighted) Scrollsheet}
{Check whether its title is 'Predicted & Residual Values' }
{first get Scrollsheet title}
	if handl=0 then begin
 	  DisplayMessageBox (MB_OK,
 	   'No Scrollsheet was found',
	   'No valid Scrollsheet was found; first produce the Predicted & Residual Values
Scrollsheet, then run this STB program.');
	  stop;
	end;
	ScrollsheetGetTitle (handl, 1, title$);
{then check for valid title}
	line01$:='Predicted & Residual Values';
	ilen:=Len (line01$);
	title$:=Mid(title$, 1, ilen);
	if title$<>line01$ then begin
 	  DisplayMessageBox (MB_OK,
 	   'Incorrect Active Scrollsheet',
	   'The currently active (highlighted) Scrollsheet is not the Predicted & Residual
Values Scrollsheet; first produce that Scrollsheet, then run this STB program.');
	  stop;
	end;

{Get dimensions (number of rows) of the Scrollsheet}
	n:=ScrollsheetGetNbRows (handl)-4; {-4, because summary statistics are appended
							at the end of the Scrollsheet}
{allocate memory for arrays}
	redim stdresiduals(n);
	redim extremes(n);
	redim extremeno(n);
	redim casenumbs(n);
	redim observed (n);

{Get observed, predicted, and residual values }
	nextreme:=0;kname$:='';
	for i:=1 to n do begin
	 ScrollsheetGetValue (handl, i, 1, observed(i));
	 ScrollsheetGetValue (handl, i, 5, stdresiduals(i));
	 if Abs(stdresiduals(i))>2 then begin
	  nextreme:=nextreme+1;
	  extremes(nextreme):=stdresiduals(i);
	  extremeno(nextreme):=i;
	  ScrollsheetGetRowName (handl, i, name$);
	  kname$:=kname$+name$+'|';
	 end;
	 casenumbs(i):=i;
	end;

{Graph 1: 2D plot of the standard residual alues against the case numbers}
	 graph:=NewGraph (SCATTERPLOT, 'Standardized Residuals vs. Case Numbers',
	  'Standardized Residuals', 'Case Numbers', n, casenumbs, stdresiduals);
{Set extreme values}
	 if nextreme>0 then begin
	  GraphAddPlot (graph, SCATTERPLOT, '', nextreme, extremeno, extremes);
	  GraphSetPlotPointStyle (graph, 2, ON, P_FILLED_CIRCLE, ?Size, RED);
	  GraphSetDataPointLabels (graph, 2, nextreme, kname$);
	 end;
{customize Graph 1}
	 ScrollsheetGetTitle (handl, 2, line01$);
	 GraphSetTitle (graph, 2, line01$);
	 if nextreme>0 then
	   GraphSetTitle (graph, 3, 'NOTE: Std. residuals >2 and <-2 are labeled');
	 GraphSetPlotFitting (graph, 1, FIT_LINEAR);
	 GraphSetPlotConfidBands (graph, 1, ON, .90);
	 GraphSetPlotEllipse (graph, 1, ON, .90);

{Graph 2: 3D scatterplot of the case numbers (x) by observed values (y)}
	 graph:=NewSurface (FIT_QUADRATIC_3D,'hosenduft',
	   'Case numbers vs. Observed Values vs. Standarized Residuals',
	   'Case Numbers', 'Observed Values', 'Standardized Residuals',
	   n, casenumbs, observed, stdresiduals);
{customize Graph 2}
	 ScrollsheetGetTitle (handl, 2, line01$);
	 GraphSetTitle (graph, 2, line01$);
	 GraphSetXYZFittingParam (graph, 25, 25, ON,
         ON, CONTOUR_AREAS, ?PolyOrder, ?LogBase);
Back to List of Programs



[StatSoft]
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217

[StatSoft]e-mail: info@statsoft.com

©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.