7.4 Interactive Quantlet GAMFIT


15039 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)
15043 XAGgam10.xpl

15048 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. 15051 gamfit starts with the model selection:

\includegraphics[scale=0.7]{gam_gamfit_1}
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.
\includegraphics[scale=0.7]{gam_gamfit_2}
Depending on these selections 15056 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).

\includegraphics[scale=0.7]{gam_gamfit_3}

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.

\includegraphics[scale=0.7]{gam_gamfit_4}

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.

\includegraphics[scale=0.7]{gam_gamfit_5}
In case of the backfitting algorithm you need to specify the kernel function.
\includegraphics[scale=0.7]{gam_gamfit_6}
For generalized models you are asked to select the distribution of the dependent variable y and the link function.
\includegraphics[scale=0.7]{gam_gamfit_7}\includegraphics[scale=0.7]{gam_gamfit_8}
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.
\includegraphics[scale=0.7]{gam_gamfit_9}

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 15068 XAGgam10.xpl .

\includegraphics[scale=0.5]{gam_gamfit_11}
\includegraphics[scale=0.5]{gam_gamfit_10}

The resulting output is made globally available as a list object gamfit. It contains:

gamfit.m
$ ng \times p$ matrix, the estimates for the nonlinear part
gamfit.opt
internally used option list

and if given

gamfit.b
$ d \times 1$ vector, the coefficients of the linear part
gamfit.bv
$ d\times d$ covariance matrix for the estimated coefficients of (GAPLM)
const
constant of the model

Although 15073 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.