STATISTICA







STATISTICA BASIC Program Log.stb

{ This program functions by finding the log of a variable and then computes its mean and stdev (of logged variable). It then converts this into a Normal dsn where the probability scales are calculated from this. The fitted line is the equation y=exp(mean+stdev*inverse Normal Dsn).

Program written, modified, or edited at StatSoft Pacific}


RandomAccess;

ReDim Results(ncases,3);
ReDim Variab(ncases,1);
ReDim lgVar(ncases,1);
ReDim Probab(ncases,1);

If SelectVariables1 ('Transformed Data', 1, 1, XVar, count1, 'Variable to be Recoded')=0 then Exit;

for i:=1 to ncases do
	begin
		Variab(i,1):=Data(i,xvar);
	end;

VectorSort (Variab, SORT_ASCENDING);

for i:=1 to ncases do
	begin
		lgvar(i,1):=log(variab(i,1));
	end;

ValMean (lgvar, 1, ncases, mean);
ValStDeviation (lgvar, 1, ncases, stdev);

For i:=1 to ncases do
	begin
		probab(i,1):=(i-.375)/(ncases+.25);
	end;

redim probab1(ncases,1);

redim probab2(ncases,1);

{NORMALISED}
For i:=1 to ncases do
	begin
		probab1(i,1):=iNormal(lgvar(i,1),mean,stdev);
		probab2(i,1):=vNormal(probab(i,1),0,1);
	end;

for i:=1 to ncases do
	begin
		Results(i,1):=probab(i,1);
		Results(i,2):=variab(i,1);
		Results(i,3):=lgvar(i,1);
	end;

redim probsl(10);
redim gridsly(30);

probsl(1):=0.001;
probsl(2):=0.005;
probsl(3):=0.01;
probsl(4):=0.05;
probsl(5):=.1;
probsl(6):=0.5;
probsl(7):=0.75;
probsl(8):=0.9;
probsl(9):=0.95;
probsl(10):=0.99;

for i:=1 to 10 do
	begin
		strt:=(i-1)*3;
		gridsly(strt+1):=vnormal(probsl(i),0,1);
		gridsly(strt+2):=vnormal(probsl(i),0,1);
		gridsly(strt+3):=missing;
	end;

ValMax (variab, 1, ncases, max1);
ValMin (variab, 1, ncases, min1);

redim gridlx(30);

for i:=1 to 10 do
	begin
		strt:=(i-1)*3;
		gridlx(strt+1):=.01;
		gridlx(strt+2):=max1+10;
		gridlx(strt+3):=missing;
	end;

New_Plot:=NewGraph(scatterplot,'LOG PROBABILITY PLOT FOR '+
varname(xvar),varname(xvar),'Probability (Cumulative %)',ncases,probab2,variab);

GraphSetPlotFitting(new_plot,1, Fit_exp);

GraphAddPlot(New_Plot,Lineplot,?Name$,30,gridsly,gridlx);
GraphSetPlotLineStyle (new_plot,2,on,l_dotted,?size,gray);

for i:=1 to 10 do
	begin
		labely$:=str(100*probsl(i),3,2);
		labelp:=vnormal(probsl(i),0,1);
		GraphSetScaleTextLabel(new_plot,ax_x,labelp,labely$);
	end;

Graphsetgridlines(new_plot,gridlines_y);

GraphSetScaleTickmarks(new_plot, AX_X, Tickmarks_off, ?MajorSize, Tickmarks_off,
?MinorSize,?MinorCount );

GraphSetScaleTickmarks(new_plot, AX_top, Tickmarks_off, ?MajorSize, Tickmarks_off,
?MinorSize,?MinorCount );

GraphSetScaleParam (New_Plot, AX_Y, SCALING_LOGarithmic, ?ValueLayout, ?ShiftScale,
?ScaleBreak, ?ScaleReversed);
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.