2.14.15 xop
Brief Information
Run operations such as NLFit, ANOVA etc using a tree
Command Line Usage
See the Examples section for details.
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
Variables
Display Name
|
Variable Name
|
I/O and Type
|
Default Value
|
Description
|
Execute Mode
|
execute
|
Input
int
|
init
|
It specifies the execute mode on the operation tree.
Option list
- init:Init Tree
- This method is used to initialize a Tree.
- update:Update Tree
- This method is used to update a Tree.
- run:Output Tree
- This method is used to out a Tree.
- report:Generate Report
- This method is used to output a Tree and generate a report.
- cleanup:Clean Operation Object
- This method is used to clean up the Operation Object
|
Class Name
|
classname
|
Input
string
|
<optional>
|
This variable specifies the class name.
The available class names are:
- DescStats: Statistics on Columns
- DescStats_1: Statistics on Rows
- NormalityTest: Normality Test
- ANOVAOneWay: One-Way ANOVA
- ANOVATwoWay: Two-Way ANOVA
- ANOVAOneWayRM: One-Way Repeated Measures ANOVA
- ANOVATwoWayRM: Two-Way Repeated Measures ANOVA
- FitLinear: Fit Linear
- FitPolynomial:Fit Polynomial
- MR: Multilple Linear Regression
- FitNL: Nonlinear Curve Fit
- ROCCurve: ROC Curve
|
GUI Tree
|
iotrgui
|
Input/Output
TreeNode
|
<optional>
|
This variable specifies the input/output GUI tree. It varies according to different operation class.
|
Out Tree
|
otrresult
|
Output
TreeNode
|
<optional>
|
This variable specifies the output tree. It varies according to different operation class.
|
Dialog Theme
|
theme
|
Input
string
|
<optional>
|
This variable specifies the dialog theme.
|
Need Fit Baseline
|
baseline
|
Input
int
|
0
|
Specify whether to fit the Baseline.
|
Description
Some analyses, such as NLFit, ANOVA, etc, are quite complicated and they have been implemented through a framework of Origin C called the operation framework.
This framework allows complexities that the X-Function framework is not yet designed to handle.
On the other hand, the operation framework allows these operation based classes to be called from Origin C, and thus an X-Function (xop) has been created to run these operation classes.
Just like many other X-Functions, xop has been designed to be used in LabTalk.
Examples
More examples on these two pages: Statistics with Labtalk and Analysis LabTalk Script Examples
Example 1: xop to run "Linear Fit" from worksheet
Perform a linear fit on A(X)B(Y) in the active sheet and generate a report sheet.
// first import some data
filename$ = system.path.program$ + "Samples\Curve Fitting\Linear Fit.dat";
newbook;
impASC filename$;
// use the FitLinear class to create a GUI tree "lrGUI"
tree lrGUI;
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;
// specify the input data in the GUI tree
lrGUI.GUI.InputData.Range1.X$=Col(A);
lrGUI.GUI.InputData.Range1.Y$=Col(B);
// specify some settings of the linear fit, for example, fix intercept to 0.1
lrGUI.GUI.Fit.FixIntercept=1;
lrGUI.GUI.Fit.FixInterceptAt=0.1;
// generate a linear fit report with the prepared GUI tree
xop execute:=report iotrgui:=lrGUI;
//Clean up operation objects after fit
xop execute:=cleanup;
Example 2: xop to run "Linear Regression" from graph
Perform Linear Regression from a graph with multiple dataplots in a single layer and generate all fitted lines on graph.
// first import some data
filename$ = system.path.program$ + "Samples\Curve Fitting\Linear Fit.dat";
newbook;
impASC filename$;
//create a graph with the data
range data = [<active>]1!(1, 2: wcol(wks.ncols));
plotxy data plot:=201 ogl:=<active>; // Plot source data as scatter
//use the FitLinear class to create a GUI tree "lrGUI"
tree lrGUI;
// initialize the GUI tree, with the FitLinear class
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;
//Specify all data plots on graph to be input data in the GUI tree
ii = 1;
doc -e d //loop all plots in the active layer
{
%A = xof(%C); //Specify XY datasets
lrGUI.GUI.InputData.Range$(ii).X$ = %A;
lrGUI.GUI.InputData.Range$(ii).Y$ = %C;
range rPlot = $(ii); //define a labtalk range for each dataplot
int uid = range2uid(rPlot); //get the uid of the range
lrGUI.GUI.InputData.Range$(ii).SetAttribute("PlotObjUID", $(uid)); // set the uid for plot
ii = ii + 1;
}
// perform linear fit and generate a report with the prepared GUI tree
xop execute:=report iotrgui:=lrGUI;
// clean up linear fit operation objects after fitting
xop execute:=cleanup;
Example 3: xop to run "Statistics on Columns"
Perform descriptive statistics on data with grouping in the active sheet and create a report tree.
// first import the desirable data into a new book
filename$ = system.path.program$ + "Samples\Statistics\body.dat";
newbook;
impASC filename$;
// use the DescStats class to create a GUI tree "statGUI"
tree statGUI;
xop execute:=init classname:=DescStats iotrgui:=statGUI;
// specify the input data in the GUI tree
statGUI.GUI.InputData.Range1.X$=Col(height);
// specify the grouping data
statGUI.GUI.InputData.Range1.F$=Col(gender);
// specify some settings of the Statistics on Columns,
// for example, you want to know who is the tallest in two kinds of genders respectively
statGUI.GUI.Quantities.quantiles.iMax=1;
// generate a report tree with the prepared GUI tree
xop execute:=run iotrgui:=statGUI otrresult:=statOut;
//Clean up operation objects after fit
xop execute:=cleanup;
// show the report tree which includes the group labels to check the results
statout.list(0,1);
// Or you can get the results and the group labels by this way
statout.=;
statout.Statistics.c1.GetLabel(1)$=;
statout.Statistics.c2.GetLabel(1)$=;
Example 4: xop to run "One-Way ANOVA"
Perform One-Way ANOVA on raw form data and generate a report sheet.
/// first import the desirable data into a new book
filename$ = system.path.program$ + "Samples\Statistics\ANOVA\One-Way_ANOVA_raw.dat";
newbook;
impASC filename$;
// use the ANOVAOneWay class to create a GUI tree "onewayGUI"
tree onewayGUI;
xop execute:=init classname:=ANOVAOneWay iotrgui:=onewayGUI;
// need to update the GUI tree since by default data in the tree has an indexed data form.
// now we need a raw form GUI tree.
// It is an attribute in LT and needs to access by a special node ".Use".
onewayGUI.GUI.InputData.Use = 1; //0 for Indexed, 1 for Raw
xop execute:=update iotrgui:=onewayGUI;
// specify the input data in the updated GUI tree
onewayGUI.GUI.InputData.Data.Factor_0$=Col(A);
onewayGUI.GUI.InputData.Data.Factor_1$=Col(B);
onewayGUI.GUI.InputData.Data.Factor_2$=Col(C);
// generate a One-Way ANOVA report with the prepared GUI tree
xop execute:=report iotrgui:=onewayGUI;
//Clean up operation objects after fit
xop execute:=cleanup;
Example 5: xop to run "Nonlinear Curve Fit"
Perform global nonlinear curve fit on A(X)B(Y)C(Y) in the active sheet and generate a report sheet.
//First import the desirable data into a new book
filename$ = system.path.program$ + "Samples\Curve Fitting\Gaussian.dat";
newbook;
impASC filename$;
//Use the NLSF class to create a GUI tree "nlGUI"
tree nlGUI;
xop execute:=init classname:=FitNL iotrgui:=nlGUI;
//Specify function and input data, then update operation tree before fitting.
nlGUI.GUI.FunctionSelection.FunctionList$="Gauss";
nlGUI.GUI.InputData.Range1.X$=Col(A);
nlGUI.GUI.InputData.Range1.Y$=Col(B);
nlGUI.GUI.InputData.Range2.X$=Col(A);
nlGUI.GUI.InputData.Range2.Y$=Col(C);
//Set fit mode as Global Fit
//It is an attribute in LT and needs to access by a special node ".Use".
nlGUI.GUI.InputData.Use=3;
xop execute:=update iotrgui:=nlGUI;
//Change parameter table to show Fix and Dependency which are not shown by default
nlGUI.GUI.Quantities.Parameters.Fix=1;
nlGUI.GUI.Quantities.Parameters.Dependency=1;
//Fix y0 at value of 0 for both datasets
nlGUI.UserSettings.Parameters.Values.y0=0;
nlGUI.UserSettings.Parameters.Fixed.y0=1;
nlGUI.UserSettings.Parameters.Values.y0_2=0;
nlGUI.UserSettings.Parameters.Fixed.y0_2=1;
//Share w
nlGUI.UserSettings.Parameters.Share.w=1;
xop execute:=report iotrgui:=nlGUI;
//Clean up operation objects after fit
xop execute:=cleanup;
Example 6: xop to run "Multiple Linear Regression"
Perform Multiple Linear Regression on data with three independents and one dependent in the active sheet and generate a report sheet.
// first import some data
filename$ = system.path.program$ + "Samples\Curve Fitting\Multiple Linear Regression.dat";
newbook;
impASC filename$;
// use the Multiple Linear Regression class to create a GUI tree "mrGUI"
tree mrGUI;
xop execute:=init classname:=MR iotrgui:=mrGUI;
// specify the input data in the GUI tree
mrGUI.GUI.InputData.Range1.X$=col(A):col(C);
mrGUI.GUI.InputData.Range1.Y$=col(D);
// specify some settings
// to see the whole tree node, use command "mrGUI.=" after running this example
mrGUI.GUI.Quantities.Parameters.ConfInterval = 1;
mrGUI.GUI.Quantities.Statistics.ReducedChiSq = 1;
mrGUI.GUI.ResAnalysis.Stad = 1;
mrGUI.GUI.Residuals.Graph3 = 1;
mrGUI.GUI.Residuals.Graph4 = 1;
mrGUI.GUI.Residuals.Graph5 = 1;
mrGUI.GUI.Residuals.Graph6 = 1;
mrGUI.GUI.Residuals.Graph7 = 1;
// generate a report with the prepared GUI tree
xop execute:=report iotrgui:=mrGUI;
//Clean up operation objects
xop execute:=cleanup;
Example 7: xop to set Positive State value for ROC curve
newbook;
fname$ = system.path.program$ + "Samples\Statistics\sodium.dat";
impasc fname$;
xop execute:=init classname:=ROCCurve iotrgui:=rocGUI;
// specify the input data in the GUI tree
rocGUI.GUI.InputData.Range1.X$="1!col(B)";
// specify the grouping data
rocGUI.GUI.InputData.Range1.F$="1!Col(A)";
/// StateValue is for old compatibility usage, the items are separated by space
rocGUI.GUI.CompControl.StateValue$="RMSF";
StringArray stateList = {"RMSF"};
rocGUI.GUI.CompControl.StateList.SetStrArray(stateList);
xop execute:=report iotrgui:=rocGUI;
Example 8: use Units row as grouping when using XOP to do statistics on rows
tree statGUI;
xop execute:=init classname:=DescStats_1 iotrgui:=statGUI;
statGUI.GUI.InputData.Range1.X$=col(1):col(4); //data
statGUI.GUI.InputData.Range1.F$="A[U]:D[U]"; //grouping
statGUI.GUI.Output.Report.Book$ = ""; //use this ONLY to create a new different book or set "" for active
statGUI.GUI.Output.Report.BookName$ = ""; // this is the book longname
statGUI.GUI.Output.Report.Sheet$ = ""; //use this only to create a new sheet or set "" for active
statGUI.GUI.Output.Report.SheetName$ = ""; //this is the sheet longnanme
xop execute:=Report iotrgui:=statGUI otrresult:=statOut; // use Execute:=RUN (to get tree only) or REPORT (to get usual Report)
xop execute:=cleanup;// Clean up essential before running another calculation
Example 9: xop to run "Statistics on Columns" on matrix object
tree statGUI;
xop execute:=init classname:=DescStats iotrgui:=statGUI;
statGUI.GUI.InputData.Range1.X$=[MBook1]MSheet1!1:0; // all matrix objects
statGUI.GUI.Output.Report.Book$ = "Book1"; // must not use default value, default is output to source book, but now source book is matrix
statGUI.GUI.Output.FlatOut.Book$ = "<report>"; //output to to the same book as report sheet
xop execute:=report iotrgui:=statGUI; //get report
xop execute:=cleanup; // Clean up essential before running another calculation
Related X-Functions
|