R/runYhat.R

runYhat <-
function(x,y,pts=x,est=tmean,fr=1,nmin=1,xout=FALSE,outfun=outpro,...){
#
# Fit a running interval smoother using the data in x and y
# Use the fit to estimate the typical value of Y
# corresponding to the covariates values in pts  
#
x=as.matrix(x)
if(xout){
flag<-outfun(x,plotit=FALSE,...)$keep
x<-x[flag,]
y<-y[flag]
x<-as.matrix(x)
}
if(ncol(x)==1){
vals=runhat(x[,1],y,pts=pts,est=est,fr=fr,nmin=nmin,...)
nvals=1
for(i in 1:length(pts)){
nvals[i]<-length(y[near(x,pts[i],fr=fr)])
}
}
if(ncol(x)>1){
temp=rung3hat(x,y,pts=pts,est=est,fr=fr,...)
vals=temp$rmd
nvals=temp$nval
}
list(Y.hat=vals,nvals=nvals)
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.