SOCR Data Analysis Documentation

From Socr

Jump to: navigation, search

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:

  1. Data: edu.ucla.stat.SOCR.analysis.data.Data class.
  2. Model Classes: under the directory of edu.ucla.stat.SOCR.analyses.model.
  3. 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

Under Survival Analysis:

  • Kaplan-Meier Method


More Examples

The linear model ones are based on the logic described in section 1.


The parametric and non-parametric tests are even easier to use with ad hoc static methods.


Survival Analysis using Kaplan-Meier




Translate this page:

(default)

Deutsch

Español

Français

Italiano

Português

日本語

България

الامارات العربية المتحدة

Suomi

इस भाषा में

Norge

한국어

中文

繁体中文

Русский

Nederlands

Ελληνικά

Hrvatska

Česká republika

Danmark

Polska

România

Sverige

Personal tools