Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: gplm
See also: gplmopt gplmcore gplmest

Quantlet: gplminit
Description: gplminit checks the validity of input and performs the initial calculations for an GPLM fit (inclusive sorting). The output is ready to be used with gplmcore.

Link:
Usage: init = gplminit(code,x,t,y,h{,opt})
Input:
code text string, the short code for the model (e.g. "bilo" for logit or "noid" for ordinary PLM).
x n x p matrix, the discrete predictor variables.
t n x q matrix, the continuous predictor variables.
y n x 1 vector, the response variables.
h q x 1 vector, the bandwith.
opt optional, a list with optional input. "gplmopt" can be used to set up this parameter. The order of the list elements is not important.
opt.b0 p x 1 vector, the initial coefficients. If not given, all coefficients are put =0 initially.
opt.m0 n x 1 vector, the initial values for the nonparametric part. If not given, a default is used.
opt.tg ng x 1 vector, a grid for continuous part. If tg is given, the nonparametric function will also be computed on this grid.
opt.m0g ng x 1 vector, the initial values for the nonparametric part on the grid. These values are ignored if direct update for nonparametric function is possible. Otherwise, if not given, it is approximated from m0.
opt.weights string, type of observation weights. Can be "frequency" for replication counts, or "prior" (default) for prior weights in weighted regression.
opt.wx scalar or n x 1 vector, frequency or prior weights. If not given, set to 1.
opt.wc n x 1 vector, weights for convergence criterion, w.r.t. m(t) only. If not given, opt.wt is used.
opt.wt n x 1 vector, weights for t (trimming factors). If not given, all set to 1.
opt.off scalar or n x 1 vector, offset. Can be used for constrained estimation. If not given, set to 0.
opt.meth integer, if -1, a backfitting is performed, if 1 a profile likelihood method is used, and 0 a simple profile likelihood is used. The default is 0.
opt.fscor integer, if exists and =1, a Fisher scoring is performed (instead of the default Newton-Raphson procedure). This parameter is ignored for canonical links.
opt.miter integer, maximal number of iterations. The default is 10.
opt.cnv integer, convergence criterion. The default is 0.0001.
opt.shf integer, if exists and =1, some output is produced which indicates how the iteration is going on.
opt.nosort integer, if exists and =1, the continuous variables t and the grid tg are assumed to be sorted by the 1st column. Sorting is required by the algorithm, hence you should switch if off only when the data are already sorted.
opt.pow optional, power for power link.
opt.nbk scalar, extra parameter k for negative binomial distribution. If not given, set to 1 (geometric distribution).
Output:
init.xs n x p matrix, x sorted according to 1st column of t.
init.ts n x q matrix, t sorted according to its 1st column.
init.ys n x 1 vector, x sorted according to 1st column of t.
init.wx n x 1 vector or scalar, prior weights.
init.wt n x 1 vector or scalar, weights for t (trimming factors).
init.wc n x 1 vector or scalar, weights for convergence criterion.
opt.wr n x 1 vector, weights for test statistics. If not given, set to 1.
opt.tdesign n x r matrix, design for parametric fit for m(t) in gplmbootstratest.
init.b0 p x 1 vector, the initial coefficients.
init.m0 n x 1 vector or scalar, the initial values for the nonparametric part. Set =NaN if direct update for nonparametric function is possible (code="noid").
init.off n x 1 vector or scalar, offset.
init.ctrl 7 x 1 vector or scalar, contains control parameters shf, miter, cnv, fscor, pow (for the power link function), nbk (for negative binomial distribution) and meth (parameter for backfitting/profile). They correspond to the optional parameters which can be given in gplmest. Defaults are 0|10|0.0001|0|0|1|0.
init.tg ng x 1 vector, a grid for continuous part. Is =NaN, if opt.tg was empty or unusable.
init.m0g ng x 1 vector or scalar, the initial values for the nonparametric part on the grid. Is =NaN, if opt.tg was empty.
init.tro n x 1 vector, "re"order index for t. Is =NaN, if opt.nosort was 1 or empty.
init.tgro ng x 1 vector, "re"order index for tg. Is =NaN, if opt.tg was empty or if opt.nosort was 1 or empty.

Example:
library("gplm")
;==========================
;  simulate data
;==========================
n=100
b=1|2
p=rows(b)
x=2.*uniform(n,p)-1
t=sort(2.*uniform(n)-1,1)
m=cos(pi.*t)
y=( 1./(1+exp(-x*b-m)).>uniform(n) )
;==========================
;  semiparametric fit
;==========================
h=0.6
opt=gplmopt("shf",1)
{xs,ts,ys,wx,wt,wc,b0,m0,off,ctrl,tg,m0g,ro,rgo}=gplminit("bilo",x,t,y,h,opt)
sf=gplmcore("bilo",xs,ts[,1],ys,h,wx,wt,wc,b0,m0,off,ctrl,1,tg,m0g)
;==========================
;  plot
;==========================
library("plot")
true=setmask(t~m,"line","thin")
estm=setmask(t~sf.m,"line","blue")
plot(true,estm)

Result:
A generalized partially linear logit fit for E[y|x,t] is
computed. sf.b contains the coefficients for the linear
part. sf.m contains the estimated nonparametric part
evaluated at observations t. The example gives the
true b together with the GPLM estimate sf.b. Also, the
estimated function sf.m is displayed together with the
true fit m.



Author: M. Mueller, 20010228
(C) MD*TECH Method and Data Technologies, 05.02.2006