1. Home
  2. EXPRESSION directive

EXPRESSION directive

Declares one or more expression data structures.

Options

VALUE = expression Value for all the expressions; default *
MODIFY = string token Whether to modify (instead of redefining) existing structures (yes, no); default no
IPRINT = string tokens Information to be used by default to identify the expressions 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 expressions
VALUE = expression structures Expression data structures providing values for the expressions
EXTRA = texts Extra texts associated with the identifiers

Description

The IDENTIFIER parameter lists the identifiers of the expressions that are to be declared. The expression data structure stores a Genstat expression, for example

Hours = Minutes/60

Usually you will find it easiest to type out an expression like this explicitly whenever you need it. The main use, then, for this rather specialized data structure is to supply an expression as the argument of a procedure.

Values can be assigned to the expressions by either the VALUE option or the VALUE parameter. The option defines a common value for all the structures in the declaration, while the parameter allows the structures each to be given a different value. If both the option and the parameter are specified, the parameter takes precedence.

You can associate a text of extra annotation with each expression using the EXTRA parameter. If MODIFY is set to yes any existing attributes and values of the expressions are retained; otherwise these are lost.

Here are two examples using the VALUE option:

EXPRESSION [VALUE=Length*Width*Height] Vcalc

EXPRESSION [VALUE=Dose=LOG10(Dose)] Dtrans

These put the expression Length*Width*Height into the identifier Vcalc, and the expression Dose=LOG10(Dose) into Dtrans. Both expressions could be declared simultaneously, using the VALUE parameter, by putting

EXPRESSION Vcalc,Dtrans; VALUE=!E(Length*Width*Height),\

  !E(Dose=LOG10(Dose))

!E(Length*Width*Height), for example, is an unnamed expression.

The IPRINT option can be set to specify how the expressions 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: VALUE, MODIFY, IPRINT.

Parameters: IDENTIFIER, VALUE, EXTRA.

See also

Directives: CALCULATE, FARGUMENTS, SETCALCULATE.

Procedure: DFUNCTION.

Commands for: Data structures, Calculations and manipulation.

Example

" Example FITN-1: Fitting a standard curve using FITNONLINEAR

  Modelling the relationship between yield of sugar from cane
  and amount of nitrogen fertilizer.
  NOTE: this model is fitted most efficiently in Genstat by
  the FITCURVE directive with option CURVE=exponential.
  This example is to illustrate the use of FITNONLINEAR, which
  is really provided for fitting models that are not in FITCURVE."

READ Nitrogen,Yield
  0  60     0  73     0  77     0  72 
 50 125    50 144    50 145    50 116
100 152   100 154   100 160   100 141
150 182   150 167   150 181   150 185
200 198   200 188   200 189   200 182 :

" 1) Three parameters treated as nonlinear"
MODEL Yield; FITTED=Expon
RCYCLE PARAMETER=Rate,Range,Inter; INITIAL=0.95,-100,100;\
  UPPER=1,*,*; STEP=0.01,*,*
EXPRESSION [VALUE=(Expon=Inter+Range*Rate**Nitrogen)] Calcexp
FITNONLINEAR [CALCULATION=Calcexp]

" Display the fitted curve.
  Note that the parameter of the RGRAPH procedure must be set to
  the x-variate to be used in the plot after a nonlinear fit."
RGRAPH [GRAPHICS=high] Nitrogen

" Plot residuals against fitted values.
  Note that the RCHECK procedure cannot be used to check assumptions
  after a nonlinear fit."
RKEEP  RESIDUAL=r; FITTED=f
DGRAPH r; f

" 2) Linear parameters separated"
MODEL Yield
RCYCLE PARAMETER=Rate; INITIAL=0.95; UPPER=1; STEP=0.01
EXPRESSION [VALUE=(Expon=Rate**Nitrogen)] Calcexp
FITNONLINEAR [PRINT=model,summary,estimates,correl,fitted;\
  CALCULATION=Calcexp] Expon

" Estimate s.e.s for linear parameters as well"
FITNONLINEAR [PRINT=m,s,e,c; CALCULATION=Calcexp; SELINEAR=yes] Expon

" 3) Explicit likelihood"
MODEL [FUNCTION=Sum]
RCYCLE PARAMETER=Rate,Range,Inter; INITIAL=0.95,-100,100;\
  UPPER=1,*,*; STEP=0.001,*,*
EXPRESSION [VALUE=(Sum=SUM((Yield-Inter-Range*Rate**Nitrogen)**2))]\
  Calcexp
FITNONLINEAR [CALC=Calcexp]
" To provide true standard errors, multiply SE by residual variance."
RKEEP ESTIMATES=Estimates; SE=se
CALC  sigma2 = Sum / (NVALUES(Yield) - 3)
&     se = se * SQRT(sigma2)
PRINT Estimates,se
Updated on March 8, 2019

Was this article helpful?