1. Home
  2. FACTOR directive

FACTOR directive

Declares one or more factor data structures.

Options

NVALUES = scalar or vector Number of units, or vector of labels; default * takes the setting from the preceding UNITS statement, if any
LEVELS = scalar or vector Number of levels, or series of numbers which will be used to refer to levels in the program; default *
VALUES = numbers Values for all the factors, given as levels; default *
LABELS = text Labels for levels, for input and output; default *
MODIFY = string token Whether to modify (instead of redefining) existing structures (yes, no); default no
REFERENCELEVEL = scalar Defines the reference level used e.g. to define the parameterization of regression models
IPRINT = string tokens Information to be used by default to identify the factors in output (identifier, extra); if this is not set, they will be identified in the standard way for each type of output

Parameters

IDENTIFIER = identifiers Identifiers of the factors
VALUES = identifiers Values for each factor, specified as levels or labels
DECIMALS = scalars Number of decimals for printing levels
CHARACTERS = scalars Number of characters for printing labels
EXTRA = texts Extra text associated with each identifier
DREPRESENTATION = scalars or texts Default format to use when the contents represent dates and times

Description

Factors are used to indicate groupings of units. The commonest occurrence is in designed experiments. For example, suppose you had 12 observations in an experiment, the first four on one treatment, the next four on a second treatment, and the last four on a third. Then you could record which treatment went with which observation by declaring a factor with the values

1,1,1,1,2,2,2,2,3,3,3,3

Thus a factor is a vector that has only a limited set of possible values, one for each group; this limitation distinguishes factors from variates and texts. In Genstat, the groups are referred to by numbers known as levels. Unless otherwise specified these are the integers 1 up to the number of groups, as in our example; however, you can specify any other numbers by the LEVELS option of the FACTOR directive. You can also give textual labels to the groups, using the LABELS option of FACTOR: these might, for example, be mnemonics for the biochemical names of treatments in an experiment.

Use of the VALUES parameter to assign values has the advantage that you can refer either to labels or to levels; the VALUES option lets you refer only to levels. So, to summarize, the LEVELS and LABELS options list the groups that can occur, while the VALUES option or parameter specifies which groups actually do occur, and in what pattern over the units.

Our simple explanatory example would therefore be:

FACTOR [LEVELS=3; VALUES=4(1...3)] Treatment

Other examples are:

FACTOR [LEVELS=!(2,4,8,16); VALUES=8,4,2,16,4,2,16,8,2] Dose

FACTOR [LABELS=!T(male,female)] Sex;VALUES=!T(4(male,female))

FACTOR [LEVELS=!(0,2.5,5); LABELS=!T(none,standard,double)]\

  Rate; VALUES=!(0,5,2.5,5,0,2.5)

Notice that if we had assigned the values using the VALUES option in the second of these, we would have needed to use the (numerical) levels:

FACTOR [LABELS=!T(male,female); VALUES=4(1,2)] Sex

Conversely, in the VALUES parameter in the declaration of Rate, we can use either the labels or the levels; so the following statement gives Rate exactly the same values:

FACTOR [LEVELS=!(0,2.5,5); LABELS=!T(none,standard,double)]\

  Rate; VALUES=!T(none,double,standard,double,none,standard)

The DECIMALS parameter lets you define a number of decimal places to be used by default when the levels of each factor are printed. The CHARACTERS parameter allows you to define the number of characters to be printed by default when the labels of each factor are printed. You can associate a text of extra annotation with each factor using the EXTRA parameter.

The DREPRESENTATION parameter allows a scalar or a single-valued text to be specified for each factor to indicate that the factor stores dates and times, and to define a format to be used for these, by default, when they are printed; details are given in the description of the PRINT directive.

In some contexts Genstat needs to treat one of the levels of a factor as a reference level. For example, in regression with groups, the parameterization used by Genstat usually involves comparisons of the second and subsequent levels of the grouping factor with its first level. This can be changed by setting the REFERENCELEVEL option to a level other than the first level when the grouping factor is declared.

If the MODIFY option is set to yes any existing attributes and values of the factors are retained if still appropriate; otherwise these are lost.

The IPRINT option can be set to specify how the factors will be identified in output. If IPRINT is not set, they will be identified in whatever way is usual for the section of output concerned. For example, the PRINT directive generally uses their identifiers (although this can be changed using the IPRINT option of PRINT itself).

Options: NVALUES, LEVELS, VALUES, LABELS, MODIFY, REFERENCELEVEL, IPRINT.

Parameters: IDENTIFIER, VALUES, DECIMALS, CHARACTERS, EXTRA, DREPRESENTATION.

See also

Directives: GENERATE, GROUPS, VARIATE, TEXT, UNITS.

Procedures: FACAMEND, FACDIVIDE, FACPRODUCT, FACSORT, FACLEVSTANDARDIZE, FACUNIQUE, FMFACTORS, FFREERESPONSEFACTOR, FACCOMBINATIONS, QFACTOR.

Commands for: Data structures.

Example

" Example ANOV-1: one-way analysis of variance"

" This experiment studied the effect of different additives on the octane
  level of gasoline. There were 5 additives and 4 observations on each
  (P.W.M. John, Statistical Design and Analysis of Experiments, page 46).

  Define number of units in the experiment (5 types x 4 observations)."
UNITS [NVALUES=20]
" Define a factor to indicate the type of gasoline for each observation."
FACTOR [LABELS=!T(A,B,C,D,E)] Gasoline
" Define variate to store the octane level recorded at each observation."
VARIATE Octane
" Read the data, representing Gasoline by its labels."
READ Gasoline,Octane; FREPRESENTATION=labels
 A  91.7   A  91.2   A  90.9   A  90.6
 B  91.7   B  91.9   B  90.9   B  90.9
 C  92.4   C  91.2   C  91.6   C  91.0
 D  91.8   D  92.2   D  92.0   D  91.4
 E  93.1   E  92.9   E  92.4   E  92.4 :
" Define the treatments to be fitted in the analysis."
TREATMENTS Gasoline
" Analyse the variate Octane, printing just the AOV table."
ANOVA [PRINT=aov] Octane
" Further output can be displayed without repeating the analysis:
  here we print tables of means."
ADISPLAY [PRINT=means]

" Example ANOV-1a: linear and quadratic contrasts"

" Suppose that gasolines A-E contain 0,1,2,3,4 cc/gallon of additive,
  respectively (but are otherwise identical). Plot the means against 
  the amount of additive."
AGRAPH Gasoline; NEWXLEVELS=!(0,1,2,3,4)

" Estimate the linear and quadratic effects of the additive."
TREATMENT POL(Gasoline; 2)
ANOVA [PRINT=aov,contrasts] Octane
Updated on March 8, 2019

Was this article helpful?