# Model functions

## leg() function

leg(`v`,[-]`n`)

forms `n`+1 legendre
polynomials of order 0 (intercept), 1 (linear) ... ` n` from the
values in `v`; the intercept polynomial is
omitted if `n` is preceded by the negative
sign.
The
actual values of the coefficients are written to the .res
file. This is similar to the pol() function described below.
## pol() function

pol(`v,n`)
or
p(`v,n`)

forms a set
of orthogonal polynomials of order
abs(`n`) based on the unique values in variate (or factor) `v` and any additional interpolated points, see
!PPOINTS and !PVAL.
It includes the intercept if
`n` is positive, omits it if `n` is negative.
For example, pol(time,2) forms a design matrix with three columns of the orthogonal polynomial
of degree 2 from the variable time. Alternatively, pol(time,-2) is a term with two columns
having centred and scaled linear coefficients in the first column and
centred and scaled quadratic coefficients in the second column.
The
actual values of the coefficients are written to the .res
file. This factor could be interacted with a design factor to fit
random regression models.
The leg() function differs
from the pol() function in the
way the quadratic and higher polynomials are calculated.
**Return to start**