Can I use SVB to develop "extensions" of Statistica and my own new "modules?"

This is one of the many useful applications for Statistica Visual Basic programs; see also What are some of the applications of SVB?. By recording routine analyses (see How can I record my analysis in an SVB program?), you can quickly generate all the necessary program code to perform particular analyses. By combining the code from different programs, and by customizing perhaps some of the user interface (see Can I create custom dialogs and other interactive user input controls in SVB?), a completely new module can be created that will perform custom analyses. Shown below is an example program that will combine multiple analyses.

' This program will compute tests comparing the ' central tendency measures in multiple groups. ' The Basic Statistics Breakdowns options will ' be used to compute the ANOVA; the Nonparametric ' Statistics Kruskal-Wallis and Median tests will ' be computed as nonparametrics alternatives to ' ANOVA. ' The following variables are declared as public ' symbols, i.e., they will be "visible" to ' all routines throughout this program. Public GroupingVariable As Integer Public DependentVariableList() As Integer Public ndep As Integer Public NVars As Long Public ResultsWorkbook As Workbook Public Folder As WorkbookItem Public InputSpreadsheet As Spreadsheet ' The main program will ask for variable selections ' and then perform the necessary computations by calling ' two subroutines. Sub Main

Set InputSpreadsheet = ActiveDataSet

' Determine the number of variables in the input data file

NVars = InputSpreadsheet.NumberOfVariables

' Set up an array to hold the dependent variable list

ReDim DependentVariableList(1 To NVars) Dim i As Integer, ret As Integer, nindep As Integer

' Bring up the Statistica variable selection dialog

ret = SelectVariables2 (InputSpreadsheet, _ "Select dependent variables, and grouping variable", _ 1, NVars, DependentVariableList, ndep, _ "Dependent variables:", _ 1, 1, GroupingVariable, nindep, _ "Independent (grouping) variable: ")

If ret=0 Then GoTo Finish

' Make new workbook

Set ResultsWorkbook = Workbooks.New ResultsWorkbook.Visible = True

' Call the subroutine to compute the ANOVA tables

ANOVATable

' Call the subroutine to compute the Kruskal-Wallis ' and Median tests

KruskalWallisAndMedianTests

Finish: End Sub ' This subroutine uses the Basic Statistics modules, option ' Breakdowns to compute the ANOVA tables; the results will ' be moved into the Workbook set up in the Main program. Sub ANOVATable

Set newanalysis = Analysis (scBasicStatistics, InputSpreadsheet) newanalysis.Dialog.Statistics = scBasBreakdowns newanalysis.Run

' NOTE: The Array function is a standard Visual Basic ' function that combines the (two in this case) arrays of integers into ' a Variant that is an array of those arrays.

newanalysis.Dialog.Variables = _ Array(DependentVariableList,GroupingVariable)

newanalysis.Dialog.Codes = ""

newanalysis.Run

' Compute the ANOVA results Spreadsheet

Set ResultsSpreadsheet _ =newanalysis.Dialog.AnalysisOfVariance

' Set up a folder in the Workbook, and call it "ANOVA Results"

Set Folder=ResultsWorkbook.InsertFolder( _ ResultsWorkbook.Root, scWorkbookLastChild)

Folder.Name="ANOVA Results"

' Move the results Spreadsheet into the Workbook; remember ' that all results Spreadsheets returned from analysis objects ' in Statistica are collections of objects (Spreadsheets); ' thus we need to explicitly reference Item(1) in the collection.

ResultsWorkbook.InsertObject( _ ResultsSpreadsheet.Item(1), Folder, scWorkbookLastChild)

End Sub ' This subroutine uses the Nonparametric Statistics module ' to compute the Kruskal-Wallis and Median tests; the results ' will be moved into the Workbook set up in the Main program. Sub KruskalWallisAndMedianTests

Dim i As Integer Set newanalysis = Analysis (scNonparametrics, InputSpreadsheet) newanalysis.Dialog.NonparametricStatistics = _ scNonComparingMultipleIndependentSamples

newanalysis.Run

' NOTE: The Array function is a standard Visual Basic ' function that turns the two arrays of integers into ' arrays of type Variant

newanalysis.Dialog.Variables = _ Array(DependentVariableList,GroupingVariable)

newanalysis.Dialog.Codes = ""

Set ResultsSpreadsheet=newanalysis.Dialog.Summary Set Folder=ResultsWorkbook.InsertFolder( _ ResultsWorkbook.Root, scWorkbookLastChild)

' Set up a folder in the Workbook, and call it ' "Nonparametric tests"

Folder.Name="Nonparametric tests"

' Move the results Spreadsheet into the Workbook; remember ' that all results Spreadsheets returned from analysis objects ' in Statistica are collections of objects (Spreadsheets); ' the .Count property will retrieve the number of objects ' (Spreadsheets) in the collection.

For i =1 To ResultsSpreadsheet.Count

ResultsWorkbook.InsertObject( _ ResultsSpreadsheet.Item(i), Folder, scWorkbookLastChild)

Next i

End Sub

As you can see, the SVB environment not only allows you to automate routine analyses, but also in a sense to "program your own Statistical package" with various nonstandard options tailored to your specific needs.