rvl.datasim
Class Factor

java.lang.Object
  |
  +--rvl.datasim.Predictor
        |
        +--rvl.datasim.Factor
All Implemented Interfaces:
java.lang.Cloneable

public class Factor
extends Predictor

A Factor is a Predictor that has discrete levels. This class provides for factors having either fixed or random levels.

Version:
2002.8.6
Author:
Russ Lenth

Fields inherited from class rvl.datasim.Predictor
ARRAY, component, COVARIATE, FACTOR, RARRAY, RESPONSE
 
Constructor Summary
Factor(java.lang.String name, int nLevels, double SD)
          Construct a random factor named name with nLevels levels that will be labeled 1, 2, ..., nLevels.
Factor(java.lang.String name, java.lang.String[] levelNames, double SD)
          Construct a random factor named name with levels named as specified by labels in levelNames.
Factor(java.lang.String name, java.lang.String[] levelNames, double[] effects)
          Construct a fixed factor named name with levels named as specified by labels in levelNames and effects in effects
 
Method Summary
 double getEffect()
          This method should be overridden in derived classes.
 double[] getEffects()
           
 int getLevel()
           
 java.lang.String getLevelName()
           
 java.lang.String[] getLevelNames()
           
 void setAuto()
          Make the factor "automatic"; i.e., its level advances each time that data are collected.
 void setLevel(int level)
          set the current level of the factor to level
 void setLevels(java.lang.String[] lNames, double[] effs)
          Set names of factor level names and effects.
 void setRandomLevels()
          Set the effects based on a new set of normal random numbers with the standard deviation previously specified in construction.
 void setRandomLevels(double sd)
          Set the effects based on a new set of normal random numbers with standard deviation sd.
 
Methods inherited from class rvl.datasim.Predictor
clone, getName, getType, setVisible
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factor

public Factor(java.lang.String name,
              int nLevels,
              double SD)
Construct a random factor named name with nLevels levels that will be labeled 1, 2, ..., nLevels. At time of construction, the effects are generated from a normal distribution having mean zero and standard deviation SD.

Factor

public Factor(java.lang.String name,
              java.lang.String[] levelNames,
              double SD)
Construct a random factor named name with levels named as specified by labels in levelNames. At time of construction, the effects are generated from a normal distribution having mean zero and standard deviation SD.

Factor

public Factor(java.lang.String name,
              java.lang.String[] levelNames,
              double[] effects)
Construct a fixed factor named name with levels named as specified by labels in levelNames and effects in effects
Method Detail

getEffect

public double getEffect()
Description copied from class: Predictor
This method should be overridden in derived classes.
Overrides:
getEffect in class Predictor
Returns:
the effect at the current level

getEffects

public double[] getEffects()
Returns:
the factor effects

getLevel

public int getLevel()
Returns:
the current level

getLevelName

public java.lang.String getLevelName()
Returns:
the label associated with the current level

getLevelNames

public java.lang.String[] getLevelNames()
Returns:
the labels of the factor levels

setAuto

public void setAuto()
Make the factor "automatic"; i.e., its level advances each time that data are collected. If you do this, you probably also want to write a public int nextRun() method to advance the factor level(s)

setLevel

public void setLevel(int level)
set the current level of the factor to level

setLevels

public void setLevels(java.lang.String[] lNames,
                      double[] effs)
Set names of factor level names and effects. The two arrays must be the same length. Note: factor is reset to its first level (level 0).

setRandomLevels

public void setRandomLevels()
Set the effects based on a new set of normal random numbers with the standard deviation previously specified in construction.

setRandomLevels

public void setRandomLevels(double sd)
Set the effects based on a new set of normal random numbers with standard deviation sd.