Difference between revisions of "SOCR Data Analysis Documentation"
(→More Examples) |
(→More Examples) |
||
Line 110: | Line 110: | ||
Survival Analysis using Kaplan-Meier | Survival Analysis using Kaplan-Meier | ||
* Example: [[Survival Analysis Using Kaplan-Meier]] | * Example: [[Survival Analysis Using Kaplan-Meier]] | ||
+ | |||
+ | |||
{{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=SOCR_Data_Analysis_Documentation}} | {{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=SOCR_Data_Analysis_Documentation}} |
Revision as of 20:06, 21 January 2007
Contents
Framework and Implementation
Framework of the Analysis Component
In the "anaylsis component", there are three "sets" of classes: data, Model, and Result. They are at:
- Data: edu.ucla.stat.SOCR.analysis.data.Data class.
- Model Classes: under the directory of edu.ucla.stat.SOCR.analyses.model.
- Result Classes: under the directory of edu.ucla.stat.SOCR.analyses.result.
A Data Object is the one that does the work for you. It stores the data you sibmit, as its member variables, and it calls Model classes (behind the scene) for results. It has "getter" methods that you can get computed results from. All the methods are public and non-static. See example below for how this works.
Example
Here is an example snippet. Suppose we would like to run a simple linear regression on two variables: height and weight, and the data are of the same length.
double[] height = new double[] {60, 55, 51, 54, 63}; double[] weight = new double[] {190, 160, 110, 120, 130}; // First, you need to instantiate a data instance. Data testData = new Data(); // Second, submit the independent variable by addPredictor, // and submit the dependent variable by addResponse. data.addPredictor(height , DataType.QUANTITATIVE); data.addResponse(finalGrade, DataType.QUANTITATIVE); // Last, use the following to get the result. try { SimpleLinearRegressionResult result = data.modelSimpleLinearRegression(); if (result != null) { /* Getting the model's parameter estiamtes and statistics. Here are two of them: alpha(intercept) and beta(slope). double alpha = result.getAlpha(); double beta = result.getBeta(); System.out.println("alpha = " + alpha); System.out.println("beta = " + beta ); } } catch (Exception e) { System.out.println("Something is wrong. No result generated. " + e); }
A Few Points to Note
Here are a few things you should know when you code analysis method calls:
- The Exception of the outer try above consists of: DataIsEmptyException (SOCR defined), WrongAnalysisException (SOCR defined), InstantiationException, IllegalAccessException, ClassNotFoundException. What if anaysis type is not specified corretly? A WrongAnalysisException would be generated. Or, what if the array that holds data is actually null or with length zero, a DataIsEmptyException will be generated. In a public method in Data, "Exception" is thrown and that include all the above. During any of the exception situation, check exception stacks for details.
- For the complete set of avaialble results, please see more examples below or check class API under edu.ucla.stat.SOCR.analsyses.example directory. All of the methods to fetch the output are under under edu.ucla.stat.SOCR.analsyses.result directory.
- Data Type: Note that we have two big categories of data: QUANTITATIVE and FACTOR. For example, QUANTITATIVE can be variables like height, weight, SAT score, etc. And FACTOR can be catogorical variables such as sex(Male/Female), race(White/Black/Asian/Hispanic, etc.). The variables "QUANTITATIVE" and "FACTOR" are coded as Java constants and they are declared in DataType.java class.
- A few words about addPreditor and addResponse methods: All the QUANTITATIVE varialbles must be submited in a form of int, long, float or double. All the FACTOR must be submitted in form of String. If the mapping of "QUANTITATIVE as double" and "FACTOR as String" is not used, an exception will be caused and the computation is paused. For example, if you intend to submit an array of data as QUANTITATIVE but you submit them as String, the code cannot compute for results.
- Note that, for the models and Parametric and Non-Parametric categories, you only need to instantiant a "Data" object then call one of the Data class's methods to get a "Result" Object back. (For example, getting "TwoPairedTResult", which is a subclass of "Result". However, For those models under the Linear Model categoriy, you will have to call "addPredictor" and "addResponse" to submit the data.
Implemented Analysis Models
As of August 1, 2006, we have implemented:
Under Linear Models:
- One Way ANOVA
- Two Way ANOVA
- Simple Linear Regression
- Multiple Linear Regression
Under Parametric Testing:
- One Sample T-Test
- Two Independent Sample T-Test
- Two Paired Sample T-Test
Under Non-Parametric Testing:
- Two Independent Sample Wilconxon Test
- Multiple Independent Sample Kruskal-Wallis Test
More Examples
The linear model ones are based on the logic described in section 1.
- Example: Simple Linear Regression
- Example: Multiple Linear Regression
- Example: One Way ANOVA
- Example: Two Way ANOVA
The parametric and non-parametric tests are even easier to use with ad hoc static methods.
- Example:One Sample T-Test
- Example: Two Independent Sample T-Test
- Example: Two Paired Sample T-Test
- Example: Two Independent Sample Wilcoxon Test
Survival Analysis using Kaplan-Meier
- Example: Survival Analysis Using Kaplan-Meier
Translate this page: