R/est.sxy.r

Defines functions est.sxy

#' @export
est.sxy<-function(dat,mdf=1,n=dat$n)
{
  #  if(!is.subsample(dat)) stop("Argument 'dat' must be of class 'subsample'")
  if(is.null(dat$x.value)) stop("No auxiliary (x) data in 'dat'")
  if(is.null(dat$y.value)) stop("No response (y) data in 'dat'")
  if(n-mdf<1) stop("Sample size too small to estimate Sxy")
  xy<-dat$x.value*dat$y.value
  meanx<-apply(dat$x.value,1,mean)
  meany<-apply(dat$y.value,1,mean)
  (apply(xy,1,sum)-n*meanx*meany)/(n-mdf)
#  yres = dat$y.value - meany
#  xres = dat$x.value - meanx
#  (apply(yres^2,1,sum) - apply(xres*yres,1,sum)/apply(xres^2,1,sum))/(n-mdf)
}
david-borchers/sampling documentation built on Sept. 17, 2022, 7:54 a.m.