This is the third step in building the oneway advisor. In the first step the code for the main window was developed. In the second step the code was revised to handle access to the icon files.
The advisor will validate the assumptions associated with a oneway analysis of variance. It is assumed that the user has created the oneway analysis prior to running the advisor. In this step this assumption is validated.
Detecting Reports
If a report window is open and contains a oneway analysis then it can have one of two possible appearances – as shown below:
The reports differ by their title – the first was created using Fit Y by X, the second was created using the Oneway option on the JMP Starter window. The following code will detect the presence of one of these report windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// Check that the current window is a oneway analysis isWinOpen = 0; cr = Current Report(); If (!IsEmpty(cr), winTitle = cr << Get Window Title; If (Contains(winTitle,"Fit Y by X") | Contains(winTitle,"Oneway"), isWinOpen = 1 ) ); If (!isWinOpen, New Window("Oneway Analysis Not Found", <<Modal, Border Box(Top(20),Bottom(20),Left(20),Right(20), V List Box( Text Box("Unable to find a window containing"), Text Box("a oneway analysis of variance") ) ) ); Throw() ); |
If the report window is not found then an error message is displayed and execution is aborted.
Pattern Matching
The title of the window contains useful information – the name of the data table and the names of the columns used for the X and Y variables. The following code retrieves these values by exploiting JMP’s pattern matching capabilities.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Determine the variables associated with the analysis obTitle = cr[Outline Box(1)] << Get Title; pat = PatArb()>>dtName + " - " + PatAltern("Fit Y by X","Oneway") + " of " + PatArb()>>yColName + " by " + PatRem()>>xColName; success = Pat Match(winTitle,pat); If (!success, New Window("Error Inspecting Oneway Window", <<Modal, Border Box(Top(20),Bottom(20),Left(20),Right(20), V List Box( Text Box("Unable to determine the variables used"), Text Box("to construct the oneway analysis") ) ) ); Throw() ); |
You should test the code with and without a oneway window open to verify that the code works as expected.
If you are not familiar with pattern matching you should note that the if the pattern matching is successful then the following variables are created: dtName, xColName and yColName.
You can add the following line at the end of the code to verify that these variables are successfully created:
show(dtName,xColName,yColName);
And Finally
The code step2.jsl needs to be revised to include this new logic. Save the revisions as step3.jsl:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
Names Default To Here(1); // Include files Include("Filepath Definitions.jsl"); // Namespaces nsICONS = Get Icons Namespace(); // Check that the current window is a oneway analysis isWinOpen = 0; cr = Current Report(); If (!IsEmpty(cr), winTitle = cr << Get Window Title; If (Contains(winTitle,"Fit Y by X") | Contains(winTitle,"Oneway"), isWinOpen = 1 ) ); If (!isWinOpen, New Window("Oneway Analysis Not Found", <<Modal, Border Box(Top(20),Bottom(20),Left(20),Right(20), V List Box( Text Box("Unable to find a window containing"), Text Box("a oneway analysis of variance") ) ) ); Throw() ); // Determine the variables associated with the analysis obTitle = cr[Outline Box(1)] << Get Title; pat = PatArb()>>dtName + " - " + PatAltern("Fit Y by X","Oneway") + " of " + PatArb()>>yColName + " by " + PatRem()>>xColName; success = Pat Match(winTitle,pat); If (!success, New Window("Error Inspecting Oneway Window", <<Modal, Border Box(Top(20),Bottom(20),Left(20),Right(20), V List Box( Text Box("Unable to determine the variables used"), Text Box("to construct the oneway analysis") ) ) ); Throw() ); // Main window wrapSize = 220; New Window("Oneway Advisor", Show Menu( 0 ), Show Toolbars( 0 ), Border Box(Top(20),Bottom(20),Left(10),Right(10), V List Box( H List Box( Spacer Box(Size(30,0)), Text Box("Assumption Checker",<<Set Font Style("Bold")) ), LineUpBox(NCol(2), Spacing(30,20), Text Box("Data within each level of the grouping variable are normally distributed",<<Set Wrap(wrapSize)), Button Box( "",,<<Set Icon(nsICONS:READY_ICON)), Text Box("Residuals are normally distributed",<<Set Wrap(wrapSize)), Button Box( "",,<<Set Icon(nsICONS:READY_ICON)), Text Box("Data within each level of the grouping variable have equal variance",<<Set Wrap(wrapSize)), Button Box( "",,<<Set Icon(nsICONS:READY_ICON)), Text Box("The data are independent, exhibiting no serial correlation",<<Set Wrap(wrapSize)), Button Box( "",,<<Set Icon(nsICONS:READY_ICON)), ) ) ) ); |
allvar …. detta är en ovärderlig hemsida .