Gretl Manual: Gnu Regression, Econometrics and Time-series Library | ||
---|---|---|
Prev | Chapter 10. User-defined functions | Next |
A user function is called or invoked by typing its name, followed by zero or more arguments. If there are two or more arguments these should be separated by commas. For example:
myfun arg1, arg2
In case more arguments are supplied than are referenced in the function body (see above), the excess arguments are simply ignored. In case less arguments are supplied than are referenced in the function, the missing references become blanks.
Function arguments can take the form of single terms or lists. Here is a trivial example:
# function definition function myfun open $1 ols $2 0 $3 end function # function call myfun data4-1, 1, 2 3 4
The function call gives three arguments, the third of which is a list of regressors. The effect is to open the data file data4-1 and run a regression given by the command ols 1 0 2 3 4.
(As a side note here, if you want a function to calculate some value having to do with a regression, but are not interested in the full results of the regression, you may wish to use the --quiet flag with the estimation command.)