Estimates functions of parameters of a linear, generalized linear, generalized additive or nonlinear model.

### Options

`PRINT` = string tokens |
What to print (`estimates, se, correlations` ); default `esti,se` |
---|---|

`CHANNEL` = identifier |
Channel number of file, or identifier of a text to store output; default current output file |

`CALCULATION` = expression structures |
Calculation of functions involving nonlinear and/or linear parameters; no default |

`SE` = variate |
To save approximate standard errors; default `*` |

`VCOVARIANCE` = symmetric matrix |
To save approximate variance-covariance matrix; default `*` |

`SAVE` = identifier |
Specifies save structure of regression model; default `*` i.e. that from last model fitted |

### Parameter

scalars |
Identifiers of scalars assigned values of the functions by the calculations |
---|

### Description

The `RFUNCTION`

directive provides estimates of functions of parameters in regression models, together with approximate standard errors and correlations. It can be used after any regression model except after fitting standard curves with separate nonlinear parameters for each level of a factor (option `NONLINEAR=separate`

in `FITCURVE`

, `ADD`

, `DROP`

and `SWITCH`

). However, if there are any linear parameters in a general nonlinear model for which standard errors have not been estimated, standard errors and correlations cannot be estimated for functions that depend on those parameters.

The functions are defined by the `expressions`

supplied by the `CALCULATION`

option of `RFUNCTION`

. These define how to calculate the function from the values of the parameters.

In linear and generalized linear models, the parameters have no identifiers associated with them. You should then refer to each parameter by using a text structure containing the name of the parameter as displayed, for example, by the option `PRINT=estimates`

of the `FIT`

directive. The text structure can, of course, just be a string, for example `'Constant'`

. However, it must match exactly, including case, the name displayed by `FIT`

.

Unless initial values have been specified using the `RCYCLE`

directive, parameters in standard curves (fitted by `FITCURVE`

) usually also have no identifiers and so should be referred to using texts as for linear regression models. However, in nonlinear models (fitted by `FITNONLINEAR`

) identifiers are specified for the nonlinear parameters using `RCYCLE`

. Names can be specified for the linear parameters of nonlinear models using the `LINEARPARAMETERS`

option of `RCYCLE`

; if not, texts must be used as in linear regression models.

The parameter of `RFUNCTION`

provides a list of scalars that are to hold the estimated values of the functions. These need not be declared in advance, but will be defined automatically if necessary. The `CALCULATION`

option specifies a list of one or more expressions to define the calculations necessary to evaluate the functions from the parameters of the model, and place the results into the scalars.

The `PRINT`

option controls output as usual. By default, the estimates of the function values are formed – as could be done simply by a `CALCULATE`

statement using the expressions if the parameters were available in scalars. In addition, approximate standard errors are calculated, using a first-order approximation based on difference estimates of the derivatives of each function with respect to each parameter. Approximate correlations can also be requested.

The `SE`

and `VCOVARIANCE`

options allow standard errors and the approximate variance-covariance matrix of the functions to be stored; the estimates of the functions themselves are automatically available in the scalars listed by the parameter of `RFUNCTION`

. The `SAVE`

option specifies which fitted model is to be used, as in the `RDISPLAY`

and `RKEEP`

directives.

Options: `PRINT`

, `CHANNEL`

, `CALCULATION`

, `SE`

, `VCOVARIANCE`

, `SAVE`

.

Parameter: unnamed.

### See also

Directives: `EXPRESSION`

, `FIT`

, `FITCURVE`

, `FITNONLINEAR`

.

Commands for: Regression analysis.

### Example

CAPTION 'RFUNCTION Example'; STYLE=meta "Remove any predefined structures that may clash with this example" DELETE [REDEFINE=yes] X,Y,model,Fit,B,M,beta,gamma,Fitted,Parms,DF,N,\ MinX,MaxX,Fit_X,N1,Fit_Y,Fit_SE,MFit,fmodel,i,ec50_calc,\ CI_Lo,CI_Hi,X50,Y50,EC50,H50,LMin "Data for response function" VARIATE X; !(-2.204,-2.204,-1.903,-1.903,-1.602,-1.602,-1.3,-1.3,-0.999,\ -0.999,-0.698,-0.698,-0.397,-0.397,-0.096,-0.096,0.204,0.204) VARIATE Y; !(0.523,-0.141,0.959,1.095,2.586,1.677,6.381,5.684,7.681,\ 9.769,12.049,13.884,14.683,12.344,15.531,16.674,16.187,18.672) "Fit a Non-Linear Model" EXPRESSION [VALUE = Fit = B + (M - B)/(1+ EXP(beta - gamma*X))] model MODEL [DISTRIBUTION=normal; DISPERSION=*] Y; FITTED=Fit RCYCLE [MAXCYCLE=100; METHOD=GaussNewton] B,M,beta,gamma FITNONLINEAR [PRINT=model,summary,estimates; CALC=model;\ CONSTANT=estimate; FPROB=yes] RKEEP FITTEDVALUES=Fitted; ESTIMATES=Parms; SE=SEParms; DF=DF "Calculate SE's of fitted values over range of data" SCALAR N; 100 CALC MinX = MIN(X) & MaxX = MAX(X) & Fit_X = MinX + (MaxX - MinX)*!(0...N)/100 & N1 = N + 1 VARIATE [N1] Fit_Y,Fit_SE SCALAR B,M,beta,gamma; #Parms EXPRESSION [VALUE = MFit = B + (M - B)/(1 + EXP(beta - gamma*x))] fmodel FOR [NTIMES=N1;INDEX=i] CALC x = Fit_X$[i] RFUNCTION [PRINT=*;CALC=fmodel;SE=MF_se] MFit CALC (Fit_Y,Fit_SE)$[i] = MFit,MF_se ENDFOR "Calculate 95% confidence limits around fit" CALC CI_Lo,CI_Hi = Fit_Y + (-1,1)*Fit_SE*EDT(0.975;DF) "Calculate point at which function reaches 50% of maximum with SE" EXPRESSION [VALUE=EC50 = beta/gamma] ec50_calc RFUNCTION [PRINT=e,se;CALC=ec50_calc] EC50 "Create points to plot 50% value on graph" CALC H50 = B + (M - B)/2 CALC LMin = MIN(CI_Lo) VARIATE X50,Y50; !(MinX,EC50,EC50),!(H50,H50,LMin) "Draw Graph of fitted values with confidence curves" FRAME [RESET=yes] WINDOW=3; BOX=omit FRAME [RESET=yes] WINDOW=2; YL=0.14; YU=0.25; XL=0.7; XU=0.925; BOX=include XAXIS [RESET=yes] WINDOW=3; TITLE='X'; YAXIS [RESET=yes] WINDOW=3; TITLE='Y' PEN [RESET=yes] 1; METHOD=point; SYMBOL=2; CSYMBOL=2; CFILL=2; COLOUR=2 PEN [RESET=yes] 2...5; METHOD=3(monotonic),line; SYMBOL=0;\ CLINE=4,12,12,2; THICKNESS=5,2,2,1; LINESTYLE=1,2,2,1 DGRAPH [WINDOW=3; TITLE='Fitted Model vs Observed Data';Key=2]\ Y=Y,Fit_Y,CI_Lo,CI_Hi,Y50; X=X,3(Fit_X),X50;\ DESC='Data','Fitted','95% CI',' ','50% of max'