Difference between revisions of "Two Way ANOVA"

From SOCR
Jump to: navigation, search
 
m
 
Line 122: Line 122:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
 +
{{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=Two_Way_ANOVA}}

Latest revision as of 00:48, 19 January 2007

/*

July 2006. Annie Che <chea@stat.ucla.edu>. UCLA Statistics.

Source of example data: An Introduction to Computational Statitics by Robert I Jennrich,
Page 207, example of regression on time for coins to reach bottom of fountains.

*/
package edu.ucla.stat.SOCR.analyses.example;

import java.util.HashMap;
import edu.ucla.stat.SOCR.analyses.data.Data;
import edu.ucla.stat.SOCR.analyses.data.DataType;
import edu.ucla.stat.SOCR.analyses.result.AnovaTwoWayResult;


public class AnovaTwoWayExample {
	public static void main(String args[]) {
		String[] group1 = {"1","1","1","2","2","2"};
		String[] group2 = {"1","2","3","1","2","3"};
		double[] score = {93,136,198,88,148,279};

		// you'll need to instantiate a data instance first.
		Data data = new Data();

		/*********************************************************************
		then put the data into the Data Object.
		append the predictor data using method "addPredictor".
		append the response data using method "addResponse".
		**********************************************************************/
		data.addPredictor("I", group1, DataType.FACTOR);
		data.addPredictor("J", group2, DataType.FACTOR);
		data.addResponse("Y", score, DataType.QUANTITATIVE);


		try {
			AnovaTwoWayResult result = data.modelAnovaTwoWay();
			System.out.println("result = " + result);
			if (result != null) {



				// Getting the model's parameter estiamtes and statistics.
				int dfCTotal = result.getDFTotal();
				int dfModel = result.getDFModel();
				int dfError = result.getDFError();
				System.out.println("dfCTotal = " + dfCTotal);
				System.out.println("dfModel = " + dfModel);
				System.out.println("dfError = " + dfError);

				double rssTotal = result.getRSSTotal();
				double rssModel = result.getRSSModel();
				double rssError = result.getRSSError();
				System.out.println("rssTotal = " + rssTotal);
				System.out.println("rssModel = " + rssModel);
				System.out.println("rssError = " + rssError);

				double mssModel = result.getMSSModel();
				double mssError = result.getMSSError();

				System.out.println("mssModel = " + mssModel);
				System.out.println("mssError = " + mssError);

				double fValue = result.getFValue();
				String pValue = result.getPValue();
				System.out.println("fValue = " + fValue);
				System.out.println("pValue = " + pValue);

				String[] varList = result.getVariableList();
				int[] dfGroup = result.getDFGroup();
				double[] rssGourp = result.getRSSGroup();
				double[] mseGourp = result.getMSEGroup();
				double[] fValueGroup = result.getFValueGroup();
				String[] pValueGroup = result.getPValueGroup();
				double[] residuals = result.getResiduals();
				double[] predicted = result.getPredicted();

				// residuals after being sorted ascendantly.
				double[] sortedResiduals = result.getSortedResiduals();

				// sortedResiduals after being standardized.
				double[] sortedStandardizedResiduals = 
                                result.getSortedStandardizedResiduals();

				// the original index of sortedResiduals, stored as integer array.
				int[] sortedResidualsIndex = result.getSortedResidualsIndex();

				// the normal quantiles of sortedResiduals.
				double[] sortedNormalQuantiles = result.getSortedNormalQuantiles();

				// sortedNormalQuantiles after being standardized.
				double[] sortedStandardizedNormalQuantiles = 
                                result.getSortedStandardizedNormalQuantiles();

				System.out.println("dfCTotal = " + dfCTotal);
				System.out.println("dfModel = " + dfModel);
				System.out.println("dfError = " + dfError);

				System.out.println("rssTotal = " + rssTotal);
				System.out.println("rssModel = " + rssModel);
				System.out.println("rssError = " + rssError);

				System.out.println("mssModel = " + mssModel);
				System.out.println("mssError = " + mssError);

				System.out.println("fValue = " + fValue);
				System.out.println("pValue = " + pValue);

				for (int i = 0; i < varList.length; i++) {
					System.out.println("varList["+i+"] = " + varList[i]);
				}
				for (int i = 0; i < residuals.length; i++) {
					System.out.println("residuals["+i+"] = " + residuals[i]);
				}

			}
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}




Translate this page:

(default)
Uk flag.gif

Deutsch
De flag.gif

Español
Es flag.gif

Français
Fr flag.gif

Italiano
It flag.gif

Português
Pt flag.gif

日本語
Jp flag.gif

България
Bg flag.gif

الامارات العربية المتحدة
Ae flag.gif

Suomi
Fi flag.gif

इस भाषा में
In flag.gif

Norge
No flag.png

한국어
Kr flag.gif

中文
Cn flag.gif

繁体中文
Cn flag.gif

Русский
Ru flag.gif

Nederlands
Nl flag.gif

Ελληνικά
Gr flag.gif

Hrvatska
Hr flag.gif

Česká republika
Cz flag.gif

Danmark
Dk flag.gif

Polska
Pl flag.png

România
Ro flag.png

Sverige
Se flag.gif