Library: | gam |
See also: | intest backfit |
Quantlet: | fastint | |
Description: | fastint estimates the additive components and their derivatives of an additive model using a modification of the integration estimator plus a one step backfit, see Kim, Linton and Hengartner (1997) and Linton (1996) |
Usage: | m = fastint(x,y,h1,h2,loc{,xg}) | |
Input: | ||
x | n x p matrix, the observed continuous explanatory variable, see also xg. | |
y | n x q matrix, the observed response variables | |
h1 | p x 1 vector or scalar, bandwidth for the pilot estimator. It is recommended to undersmooth here. | |
h2 | pg x 1 vector or scalar, bandwidth for the backfit step. Here you should smooth in an optimal way. | |
loc | {0,1,2}, degree of the local polynomial smoother used in the backfit step: 0 for Nadaraya Watson, 1 local linear, 2 local quadratic | |
xg | ng x pg matrix, optional, the points on which the estimates shall be calculated. the columns of t and tg must have the same order up to column pg < = p. If grid is used, the results won t get centered! | |
Output: | ||
m | ng x pp matrix, where pp is pg*(loc+1). Estimates of the additive functions in column 1 to pg, the first derivatives in column (pg+1) to (2*pg) and the second derivatives in column (2*pg+1) to (3*pg). |
library("gam") randomize(1234) n = 100 d = 2 ; generate a correlated design: var = 1.0 cov = 0.4 *(matrix(d,d)-unit(d)) + unit(d)*var {eval, evec} = eigsm(cov) t = normal(n,d) t = t*((evec.*sqrt(eval)')*evec') g1 = 2*t[,1] g2 = t[,2]^2 -mean(t[,2]^2) y = g1 + g2 + normal(n,1) * sqrt(0.5) h1 = 0.5 h2 = 0.7 loc = 0 gest = fastint(t,y,h1,h2,loc) library("graphic") pic = createdisplay(1,2) dat11 = t[,1]~g1 dat12 = t[,1]~gest[,1] dat21 = t[,2]~g2 dat22 = t[,2]~gest[,2] setmaskp(dat12,4,4,8) setmaskp(dat22,4,4,8) show(pic,1,2,dat11,dat12) show(pic,1,1,dat21,dat22)
estimates of the additive functions