Library: | gplm |
See also: | gplmopt gplmnoid gplmnoidtest glmnoid |
Macro: | gplmnoidbiased | |
Description: | biased LM -- gplmnoidbiased computes the biased linear model for the test of a linear model versus a PLM. This is a fast routine using the command sker to obtain kernel estimates. |
Usage: | myfit = gplmnoidbiased(x,t,y,h,b{,opt}) | |
Input: | ||
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. | |
b | p x 1 vector, coefficients b from parametric fit. | |
opt | optional, a list with optional input. The macro "gplmopt" can be used to set up this parameter. The order of the list elements is not important. Parameters which are not given are replaced by defaults (see below). | |
opt.wx | scalar or n x 1 vector, prior weights. If not given, set to 1. | |
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.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 this option should be given only when data are sorted. | |
opt.off | scalar or n x 1 vector, offset in predictor. | |
Output: | ||
myfit.m | n x 1 vector, biased version of m0 | |
myfit.mg | ng x 1 vector, biased version of m0g |
library("glm") 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=0.5*cos(pi.*t)+0.5*t y=x*b+m+normal(n)./2 ;========================== ; parametric (ls) fit ;========================== pf=glmnoid(x~t~matrix(n),y) b0 =pf.b[1:p] gamma0 =pf.b[p+1:rows(pf.b)] m0 =(t~matrix(n))*gamma0 ;========================== ; semiparametric fit ;========================== h=0.6 yb=x*b0+m0 bf=gplmnoidbiased(x,t,yb,h,b0) pic=createdisplay(1,1) show(pic,1,1,t~m,t~m0,t~bf.m)
A biased linear fit for E[y|x,t] is computed. bf.m contains the biased linear fit evaluated at observations t. This is needed for the test of a linear model vs. a partially linear. bf.m is displayed together with the true and the linear fit.
Library: | gplm |
See also: | gplmopt gplmnoid gplmnoidtest glmnoid |