STATISTICA







STATISTICA BASIC Program BoxCoxP.stb

[Graph] { This program will produce (1) a plot of the means versus standard deviations, and (2) the log(means) versus log(standard deviations) from the "Display" Scrollsheet in Experimental Design (if all means and standard deviations are greater than zero). The program will look for column headers "Means" and "Std.Dev."

For the latter plot, the slope of the regression line B suggests a transformation for the dependent variable y=y^(1-b).

For additional information, see: Box, G. E. P. & Cox, D. R. (1964). An analysis of transformations. Journal of the Royal Statistical Society, B, 26, 211-234.

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


randomaccess;
NoDataFileVariableNames;
	delta:=1.e-10;

{ get the Scrollsheet handle for the currently active (highlighted) Scrollsheet }
	Handle:=GetScrollsheet (0);
	if Handle=0 then begin
 	  DisplayMessageBox (MB_OK,
 	   'No Scrollsheet was found',
	   'No valid Scrollsheet was found; first produce the Scrollsheet with all
distinct runs in the design (and with Means and Standard Deviations); then run this STB
program.');
	  stop;
	end;
	ncols:=ScrollsheetGetNbCols (Handle);
	n:=ScrollsheetGetNbRows (Handle)-1;
{allocate memory for arrays}
	redim stdv(n);
	redim means(n);
	iflag:=0;
	for i:=1 to ncols do begin
	 ScrollsheetGetColName (Handle, i, Name1$, Name2$);
	 title$:=Mid(Name2$, 1, 6);
	 if title$=' Means' then begin
         iflag:=iflag+1;
	   imean:=i;
	 end;
	 title$:=Mid(Name2$, 1, 8);
	 if title$='Std.Dev.' then begin
	  iflag:=iflag+1;
	  istdv:=i;
	 end;
	end;
	if iflag<>2 then begin
 	  DisplayMessageBox (MB_OK,
 	   'Incorrect Active Scrollsheet',
	   'The currently active (highlighted) Scrollsheet does not contain all distinct
runs in the design (andMeans and Standard Deviations); first produce (or highlight) that
Scrollsheet, then run this STB program.');
	  stop;
	 end;

{ read means, standard deviations}
	iflag:=0;
	for i:=1 to n do begin
	 ScrollsheetGetValue (Handle, i, imean, means(i));
	 if means(i)<delta then iflag:=1;
	 ScrollsheetGetValue (Handle, i, istdv, stdv(i));
	 if stdv(i)<delta then iflag:=1;
	end;

{plot 1: means versus standard deviations}
	graph:=NewGraph (SCATTERPLOT, 'Means vs. Standard Deviations',
	 'Standard Deviation', 'Mean', n, means, stdv);
	ScrollsheetGetTitle (Handle, 1, line01$);
	GraphSetTitle (Graph, 2, LINE01$);
	GraphSetPlotFitting (Graph, 1, FIT_LINEAR);
	GraphSetTitle (Graph, 3, 'Linear fit: @F');

	if iflag=1 then begin
 	  DisplayMessageBox (MB_OK,
 	   'Negative or Zero Values',
	   'Some means and standard deviations are negative or equal to zero; cannot
produce the log-log plot');
	  stop;
	 end;

{plot 2: log means versus log standard deviations}
	for i:=1 to n do begin
	 means(i):=log(means(i));
	 stdv(i):=log(stdv(i));
	end;
	graph:=NewGraph (SCATTERPLOT, 'Log(Means) vs. Log(Std. Devs)',
	 'Log(Standard Deviation)', 'Log(Mean)', n, means, stdv);
	ScrollsheetGetTitle (Handle, 1, line01$);
	GraphSetTitle (Graph, 2, LINE01$);
	GraphSetPlotFitting (Graph, 1, FIT_LINEAR);
	GraphSetTitle (Graph, 3, 'Linear fit: @F');
	ohandle:=GraphDrawTextParam (Graph, '@BSuggested
Transformations@B@aSlope@t[8]1-Slope@t[20]Transformation@a2@t[8]-1@t[20]reciprocal@a1@t[8
]0@t[20]logarithm@a.5@t[8].5@t[20]square root@a0@t[8]1@t[20]none',
	?FontName$, ?FontSize, ?Color, ?Orientation, ?HorizAlignment, ?VertAlignment,
	ON, ON, 3, 90, FALSE);
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.