Difference between revisions of "One Way ANOVA"

From SOCR
Jump to: navigation, search
m
m (Text replacement - "{{translate|pageName=http://wiki.stat.ucla.edu/socr/" to ""{{translate|pageName=http://wiki.socr.umich.edu/")
 
Line 103: Line 103:
  
  
{{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=SOCR_Events_SOCR_CAUSEway_Workshop2007}}
+
"{{translate|pageName=http://wiki.socr.umich.edu/index.php?title=SOCR_Events_SOCR_CAUSEway_Workshop2007}}

Latest revision as of 14:30, 3 March 2020

/*

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

Source of example data: 
An Introduction to Computational Statitics by Robert I. Jennrich.
Page 199, 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.AnovaOneWayResult;


public class AnovaOneWayExample {
	public static void main(String args[]) {
		String[] group = 
                {"1","1","1","1","1","1", "2","2","2","2","2","2","2","2", "3","3","3","3","3"};
		double[] time = 
                {93,67,77,92,97,62, 136,120,115,104,115,121,102,130, 198,217,209,221,190};

		// 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(group, DataType.FACTOR);
		data.addResponse(time, DataType.QUANTITATIVE);

		try {
			AnovaOneWayResult result = data.modelAnovaOneWay();
			if (result != null) {

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

				double rssTotal = result.getRSSTotal();
				double rssModel = result.getRSSModel();
				double rssError = result.getRSSError();

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

				double fValue = result.getFValue();
				String pValue = result.getPValue();

				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 < 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