JavaGrinders
Class NumberVariable

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by JavaGrinders.Variable
                  extended by JavaGrinders.NumberVariable
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess
Direct Known Subclasses:
AngleVariable, IntegerVariable

public class NumberVariable
extends Variable
implements java.lang.Cloneable

handles things that a general variable containing numbers should do or know about. Based on a more generic Variable it supports ways to select rows using a variety of criteria, and reports descriptive (parametric) statistics. All numbers are stored and handled as Doubles.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class JavaGrinders.Variable
autoExtracted, df, doWarnings, itsHighlitedColor, itsLineColor, itsLocationColor, rand
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
NumberVariable(java.lang.String varName, VariableOrganizer theOwner)
          Standard constructor for the root number Variable class using a VariableOrganizer
NumberVariable(java.lang.String varName, VariableOrganizer anOrganizer, double[] theData)
          Standard constructor for the NumberVariable class using a double array of data
 
Method Summary
 NumberVariable doLinRegressionAnalysis(NumberVariable theXVariable)
          fills the regression statistics for the variable with control over th intercept
 void fill(int nRows, double aValue)
          fills the variable with a constant
 void fill(int startRow, double[] values)
          fills the variable with a constant
 void fillCompleteTerms(VariableOrganizer aXOrganizer, ANOVAResults theResults)
          fills the n-way interaction terms for the ANOVA
 void fillDescriptives()
          fills the descriptive statistics for the variable
 void fillWithFormula(java.lang.String aFormula)
          fills the variable with individual datavalues created through a formula
 void fillWithGaussRandom(double theMean, double theSD)
          fills the variable with random values from a Gaussian Distribution
 void fillWithParser(DataFileParser aParser, int varNum, boolean firstRowAsLabels)
          fills the variable with individual datavalues read from a textfile using a DataFileParser object
 void fillWithRandomFromDistribution(NumberVariable theDistribution)
          fills the variable with random values from a Gaussian Distribution
 void fillWithRowNum()
          fills the variable with individual datavalues created through a formula
 void fillWithUniformRandom()
          fills the variable with random values from a uniform distribution between 0 and 1
 ANOVAResults getANOVAResults(Variable theXVariable)
          fills the ANOVA statistics for the variable
 ANOVAResults getANOVAResults(VariableOrganizer aXOrganizer)
          fills the ANOVA statistics for a full factorial model
 NumberVariable getDistancesToMean()
          returns a variable containing each values relative to its mean
 Descriptives[] getGroupDescriptives(Variable theXVariable)
          returns the descriptives for the groups identified by X
 NumberVariable getLinRegressionResiduals(NumberVariable theXVariable)
          fills the regression statistics for the variable with control over th intercept
 RegressionResults getLinRegressionResults(NumberVariable theXVariable)
          fills the regression statistics for the variable with control over th intercept
 double getMaxValue()
          returns the maximum value stored in the Vector as a double
 double getMeanValue()
          returns the average for values stored in the Vector as a double
 double getMinValue()
          returns the minimum value stored in the Vector as a double
 MultRegressionResults getMultLinRegressionResults(VariableOrganizer theXVariableOrganizer)
          fills the regression statistics for the variable with control over the intercept
 double[] getNumberArray()
          returns the values of selected rows into an array of doubles
 NumberDescriptives getNumberDescriptives()
          fills the descriptive statistics for the variable and returns the results
 double getRange()
          returns the minimum value stored in the Vector as a double
 double getSDValue()
          returns the average for values stored in the Vector as a double
 SquaresCrossproducts getSSCP(NumberVariable theXVariable)
          returns the sums of squares and crossproducts for the variable
 double getSumValue()
          returns the average for values stored in the Vector as a double
 tTestResults gettTestResults(double mean)
          fills the t-Test results for the variable
 double getVarianceValue()
          returns the average for values stored in the Vector as a double
 NumberVariable getzTransform()
          returns a variable containing each values relative to its mean
 void invalidDescriptives()
          descriptive stats need to be updated
 void listBasicDescriptives()
          lists the basic descriptive statistics for the variable
 void listDescriptives()
          lists the descriptive statistics for the variable
 void listGroupDescriptives(Variable theXVariable)
          lists the descriptives for the groups identified by X
 void listLinRegressionResults(NumberVariable theXVariable)
          fills the regression statistics for the variable with control over th intercept
 void listMultLinRegressionResults(VariableOrganizer theXVariableOrganizer)
          fills the regression statistics for the variable with control over the intercept
 void selectAbove(double cutoffValue, boolean fromPrevSelected)
          select all rows with a value greater than the one provided
 void selectAboveEqual(double cutoffValue, boolean fromPrevSelected)
          select all rows with a value greater or equal than the one provided
 void selectBelow(double cutoffValue, boolean fromPrevSelected)
          select all rows with a value less than the one provided
 void selectBelowEqual(double cutoffValue, boolean fromPrevSelected)
          select all rows with a value less or equal than the one provided
 void selectEqual(double aValue, boolean fromPrevSelected)
          select all rows with a value greater or equal than the one provided
 void selectRange(double lowValue, double highValue, boolean fromPrevSelected)
          select all rows with a value between the lower and upper limits provided.
 void selectValue(java.lang.Object whichValue, boolean fromPrevSelected)
          selects rows that match a given object from the currently selected set of rows
 void setContinuousType()
          sets the variable to type CONTINUOUS
 void sort(boolean ascending)
          sorts the values for all rows
 
Methods inherited from class JavaGrinders.Variable
addValue, asJAMAMatrix, asVariableOrganizer, checkMinUseRows, checkNumberIDs, checkSameIDs, checkSameSelectRows, checkSameSelectRows, checkSameUseRows, checkSameUseRows, checkValidRowRange, combineSelectedWithSavedSelectedRows, copySelectStateFrom, customColorSelectedRows, deleteMissingRows, deleteNonSelectedRows, deleteRow, deleteRows, deleteSelectedRows, deselectAllRows, deselectRows, fill, fill, fill, fill, fill, fillDescriptives, fillWithParser, fillWithVariable, findFirstValidRow, findLastValidRow, findNextNonMissingRow, findNextValidRow, findPreviousValidRow, getabasedintValue, getAbasedintValue, getbooleanValue, getcharValue, getCombinedIDs, getCrossTabulation, getCrossTabulation, getCustomColorRow, getDescriptives, getdoubleArray, getdoubleValue, getfloatValue, getHighlitedRow, getIDs, getIDString, getIDStrings, getInteractions, getintValue, getJaccard, getlongValue, getManhattan, getMissingRow, getName, getNIDs, getNMissingRows, getNotes, getNRows, getNSelectRows, getNUseRows, getNValidRows, getOrganizer, getProximity, getProximity, getRandomValue, getSelectRow, getSquEuclidian, getStringArray, getStringValue, getTransitions, getUseRow, getValue, getVariableDesignRole, getVariableDesignRoleString, getVariableFormat, getVariableType, highliteSelectedRows, invertSelectedRows, isAngleType, isContinuousType, isLocationType, isLocked, isNominalType, isOrdinalType, isXVariable, isYVariable, listBasics, listFrequencies, listGroupDescriptivesNoDia, listIDs, listRows, listRows, listSelectedRows, listSelectState, listSelectState, listUseRows, matchedIDs, reportWarnings, restoreSelectedRows, restrictToMatchingUseRows, restrictToMatchingUseRows, reverseRows, saveSelectedRows, selectAllRows, selectRows, selectStringValue, selectUseRows, setAnglesType, setCustomColorRow, setFormula, setHighliteColor, setHighlitedRow, setLineColor, setLocationColor, setLock, setMissingRow, setName, setNominalType, setNotes, setNRows, setOrdinalType, setOrganizer, setSelectRow, setSelectRowsToMissing, setValue, setValue, setValue, setValue, setValue, setValue, setVariableDesignRole, setVariableFormat, setVariableType, setWarnings
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

NumberVariable

public NumberVariable(java.lang.String varName,
                      VariableOrganizer theOwner)
               throws java.lang.Exception
Standard constructor for the root number Variable class using a VariableOrganizer

Parameters:
varName - assigns a name (String) to the variable
theOwner - an instance of VariableOrganizer class coordinates a set of variables with respect to number of data points available and the rows that are currently selected
Throws:
java.lang.Exception

NumberVariable

public NumberVariable(java.lang.String varName,
                      VariableOrganizer anOrganizer,
                      double[] theData)
               throws java.lang.Exception
Standard constructor for the NumberVariable class using a double array of data

Parameters:
varName - assigns a name (String) to the variable
anOrganizer - an instance of VariableOrganizer class coordinates a set of variables with respect to number of data points available and the rows that are currently selected
theData - a double array of data
Throws:
java.lang.Exception
Method Detail

setContinuousType

public void setContinuousType()
                       throws java.lang.Exception
sets the variable to type CONTINUOUS

Throws:
java.lang.Exception

fill

public void fill(int nRows,
                 double aValue)
          throws java.lang.Exception
fills the variable with a constant

Parameters:
nRows - the number of rows to fill
aValue - a double value
Throws:
java.lang.Exception

fill

public void fill(int startRow,
                 double[] values)
          throws java.lang.Exception
fills the variable with a constant

Parameters:
startRow - the starting rows to fill
values - the double values to use
Throws:
java.lang.Exception

fillWithParser

public void fillWithParser(DataFileParser aParser,
                           int varNum,
                           boolean firstRowAsLabels)
                    throws java.lang.Exception
fills the variable with individual datavalues read from a textfile using a DataFileParser object

Overrides:
fillWithParser in class Variable
Parameters:
aParser - the DataFileParser that was used to read data values from a text file
varNum - marks the number of the column to be filled into the variable
firstRowAsLabels - whether the first row contains a variable label
Throws:
java.lang.Exception

fillWithUniformRandom

public void fillWithUniformRandom()
                           throws java.lang.Exception
fills the variable with random values from a uniform distribution between 0 and 1

Throws:
java.lang.Exception

fillWithGaussRandom

public void fillWithGaussRandom(double theMean,
                                double theSD)
                         throws java.lang.Exception
fills the variable with random values from a Gaussian Distribution

Parameters:
theMean - the mean for the gaussian distribution
theSD - the standard devaiation for the gaussian distribution
Throws:
java.lang.Exception

fillWithRandomFromDistribution

public void fillWithRandomFromDistribution(NumberVariable theDistribution)
                                    throws java.lang.Exception
fills the variable with random values from a Gaussian Distribution

Parameters:
theDistribution - a distribution from which to sample random numbers
Throws:
java.lang.Exception

fillWithFormula

public void fillWithFormula(java.lang.String aFormula)
                     throws java.lang.Exception
fills the variable with individual datavalues created through a formula

Parameters:
aFormula - the formula to use for filling the variable with values
Throws:
java.lang.Exception

fillWithRowNum

public void fillWithRowNum()
                    throws java.lang.Exception
fills the variable with individual datavalues created through a formula

Throws:
java.lang.Exception

selectValue

public void selectValue(java.lang.Object whichValue,
                        boolean fromPrevSelected)
                 throws java.lang.Exception
selects rows that match a given object from the currently selected set of rows

Overrides:
selectValue in class Variable
Parameters:
whichValue - the object to match
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

selectEqual

public void selectEqual(double aValue,
                        boolean fromPrevSelected)
                 throws java.lang.Exception
select all rows with a value greater or equal than the one provided

Parameters:
aValue - lists the comparison value
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

selectAboveEqual

public void selectAboveEqual(double cutoffValue,
                             boolean fromPrevSelected)
                      throws java.lang.Exception
select all rows with a value greater or equal than the one provided

Parameters:
cutoffValue - lists the comparison value
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

selectAbove

public void selectAbove(double cutoffValue,
                        boolean fromPrevSelected)
                 throws java.lang.Exception
select all rows with a value greater than the one provided

Parameters:
cutoffValue - lists the comparison value
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

selectBelowEqual

public void selectBelowEqual(double cutoffValue,
                             boolean fromPrevSelected)
                      throws java.lang.Exception
select all rows with a value less or equal than the one provided

Parameters:
cutoffValue - lists the comparison value
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

selectBelow

public void selectBelow(double cutoffValue,
                        boolean fromPrevSelected)
                 throws java.lang.Exception
select all rows with a value less than the one provided

Parameters:
cutoffValue - lists the comparison value
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

selectRange

public void selectRange(double lowValue,
                        double highValue,
                        boolean fromPrevSelected)
                 throws java.lang.Exception
select all rows with a value between the lower and upper limits provided. This includes values equal to the lower limit and excludes the upper limit

Parameters:
lowValue - the lower limit
highValue - the upper limit
fromPrevSelected - notes whether the search should only be performed on currently selected rows
Throws:
java.lang.Exception

getMaxValue

public double getMaxValue()
                   throws java.lang.Exception
returns the maximum value stored in the Vector as a double

Throws:
java.lang.Exception

getMinValue

public double getMinValue()
                   throws java.lang.Exception
returns the minimum value stored in the Vector as a double

Throws:
java.lang.Exception

getRange

public double getRange()
                throws java.lang.Exception
returns the minimum value stored in the Vector as a double

Throws:
java.lang.Exception

getMeanValue

public double getMeanValue()
                    throws java.lang.Exception
returns the average for values stored in the Vector as a double

Throws:
java.lang.Exception

getSumValue

public double getSumValue()
                   throws java.lang.Exception
returns the average for values stored in the Vector as a double

Throws:
java.lang.Exception

getVarianceValue

public double getVarianceValue()
                        throws java.lang.Exception
returns the average for values stored in the Vector as a double

Throws:
java.lang.Exception

getSDValue

public double getSDValue()
                  throws java.lang.Exception
returns the average for values stored in the Vector as a double

Throws:
java.lang.Exception

sort

public void sort(boolean ascending)
          throws java.lang.Exception
sorts the values for all rows

Overrides:
sort in class Variable
Parameters:
ascending - sort in ascending order?
Throws:
java.lang.Exception

invalidDescriptives

public void invalidDescriptives()
descriptive stats need to be updated

Overrides:
invalidDescriptives in class Variable

fillDescriptives

public void fillDescriptives()
                      throws java.lang.Exception
fills the descriptive statistics for the variable

Throws:
java.lang.Exception

getNumberDescriptives

public NumberDescriptives getNumberDescriptives()
                                         throws java.lang.Exception
fills the descriptive statistics for the variable and returns the results

Throws:
java.lang.Exception

listBasicDescriptives

public void listBasicDescriptives()
                           throws java.lang.Exception
lists the basic descriptive statistics for the variable

Throws:
java.lang.Exception

listDescriptives

public void listDescriptives()
                      throws java.lang.Exception
lists the descriptive statistics for the variable

Overrides:
listDescriptives in class Variable
Throws:
java.lang.Exception

getNumberArray

public double[] getNumberArray()
                        throws java.lang.Exception
returns the values of selected rows into an array of doubles

Throws:
java.lang.Exception

getzTransform

public NumberVariable getzTransform()
                             throws java.lang.Exception
returns a variable containing each values relative to its mean

Throws:
java.lang.Exception

getDistancesToMean

public NumberVariable getDistancesToMean()
                                  throws java.lang.Exception
returns a variable containing each values relative to its mean

Throws:
java.lang.Exception

getGroupDescriptives

public Descriptives[] getGroupDescriptives(Variable theXVariable)
                                    throws java.lang.Exception
returns the descriptives for the groups identified by X

Parameters:
theXVariable - the independent NumberVariable
Throws:
java.lang.Exception

listGroupDescriptives

public void listGroupDescriptives(Variable theXVariable)
                           throws java.lang.Exception
lists the descriptives for the groups identified by X

Overrides:
listGroupDescriptives in class Variable
Parameters:
theXVariable - the independent NumberVariable
Throws:
java.lang.Exception

doLinRegressionAnalysis

public NumberVariable doLinRegressionAnalysis(NumberVariable theXVariable)
                                       throws java.lang.Exception
fills the regression statistics for the variable with control over th intercept

Parameters:
theXVariable - the independent NumberVariable
Throws:
java.lang.Exception

listLinRegressionResults

public void listLinRegressionResults(NumberVariable theXVariable)
fills the regression statistics for the variable with control over th intercept

Parameters:
theXVariable - the independent NumberVariable

getLinRegressionResults

public RegressionResults getLinRegressionResults(NumberVariable theXVariable)
                                          throws java.lang.Exception
fills the regression statistics for the variable with control over th intercept

Parameters:
theXVariable - the independent NumberVariable
Throws:
java.lang.Exception

getLinRegressionResiduals

public NumberVariable getLinRegressionResiduals(NumberVariable theXVariable)
                                         throws java.lang.Exception
fills the regression statistics for the variable with control over th intercept

Parameters:
theXVariable - the independent NumberVariable
Throws:
java.lang.Exception

getMultLinRegressionResults

public MultRegressionResults getMultLinRegressionResults(VariableOrganizer theXVariableOrganizer)
                                                  throws java.lang.Exception
fills the regression statistics for the variable with control over the intercept

Parameters:
theXVariableOrganizer - the independent variables in a VariableOrganizer
Throws:
java.lang.Exception

listMultLinRegressionResults

public void listMultLinRegressionResults(VariableOrganizer theXVariableOrganizer)
fills the regression statistics for the variable with control over the intercept

Parameters:
theXVariableOrganizer - the independent variables in a VariableOrganizer

fillCompleteTerms

public void fillCompleteTerms(VariableOrganizer aXOrganizer,
                              ANOVAResults theResults)
                       throws java.lang.Exception
fills the n-way interaction terms for the ANOVA

Throws:
java.lang.Exception

gettTestResults

public tTestResults gettTestResults(double mean)
                             throws java.lang.Exception
fills the t-Test results for the variable

Parameters:
mean - the mean to compare to
Throws:
java.lang.Exception

getANOVAResults

public ANOVAResults getANOVAResults(Variable theXVariable)
                             throws java.lang.Exception
fills the ANOVA statistics for the variable

Parameters:
theXVariable - the independent Variable
Throws:
java.lang.Exception

getANOVAResults

public ANOVAResults getANOVAResults(VariableOrganizer aXOrganizer)
                             throws java.lang.Exception
fills the ANOVA statistics for a full factorial model

Parameters:
aXOrganizer - the VariableOrganizer containing independent variables
Throws:
java.lang.Exception

getSSCP

public SquaresCrossproducts getSSCP(NumberVariable theXVariable)
                             throws java.lang.Exception
returns the sums of squares and crossproducts for the variable

Parameters:
theXVariable - the independent NumberVariable
Throws:
java.lang.Exception