7.4 Interactive Quantlet GAMFIT
gamfit(t, y{, opt})
- interactive tool for fitting of GAM models
|
library("gam")
randomize(1234)
t = uniform(50,2)*2-1
g1 = 2*t[,1]
g2 = t[,2]^2
g2 = g2 - mean(g2)
y = g1 + g2 + normal(50,1) * sqrt(0.25)
gamfit(t,y)
gamfit provides a convenient interactive tool for the estimation of
additive models.
The inputs t and y are obligatory parameters. All the other variables,
selections and options needed for the estimation will be inquired
interactively.
The Break option ends the dialogue at any level without doing any
calculations.
gamfit starts with the model selection:
For the additive (AM) and the additive partially linear model
(APLM) it is necessary to specify the estimation procedure. Since so
far the backfitting procedure is not implemented for generalized
additive models, the marginal integration estimator is automatically
applied for GAM and GAPLM.
Depending on these selections
gamfit
checks the input and finds out,
which further parameters are needed to run the estimation.
In case of a partially linear model you will be asked to quote the
variable name for the linear part (named here the discrete variables).
You may, alternatively, leave it out, which means to run the
estimation on the linear part only and to switch back to an additive
(AM) or a generalized additive model (GAM).
Most quantlets of the quantlib gam
allow to use different estimation
procedures: local constant, local linear or local quadratic. Hence, they
are able to estimate the additive functions and its derivatives.
At least one vector of bandwidths is needed for all estimation
procedures. Most of them additionally ask for a second bandwidth for
the directions not of interest.
In case of the backfitting algorithm you need to specify the
kernel function.
For generalized models you are asked to select the distribution of the
dependent variable y and the link function.
At last, before starting the estimation, it is possible to change the
optional control parameters. It depends on the previous selections
which of them appear (for detailed description of the options see
Section 7.3). Some of them refer to the
graphical output, others allow to exclude variables, to supply a grid, to
produce an output with descriptive statistics and to display
the steps of the estimation process.
Subsequently a graphical output presents the estimation results for the
nonlinear and should the occasion arise also for the linear part. If
selected, descriptive statistics are shown additionally.
The following pictures were acquired using the data from
gam10.xpl
.
The resulting output is made globally available as a list object gamfit. It
contains:
- gamfit.m
-
matrix, the estimates for the nonlinear
part
- gamfit.opt
- internally used option list
and if given
- gamfit.b
-
vector, the coefficients of the linear
part
- gamfit.bv
-
covariance matrix for the estimated
coefficients of (GAPLM)
- const
- constant of the model
Although
gamfit
is an interactive tool, you are free to provide
initially any additional option or parameter needed for the estimation
of your model. The bandwidths h and g, the grid or the discrete
variable x are typical examples. Look up the options corresponding to
your model in Section 7.3. Section 7.5
gives instructions on optional parameters.