R/Hajekestimator.r

Defines functions Hajekestimator

Documented in Hajekestimator

Hajekestimator<-function(y,pik,N=NULL,type=c("total","mean")) 
{
if(any(is.na(pik))) stop("there are missing values in pik")
if(any(is.na(y))) stop("there are missing values in y")
if(length(y)!=length(pik)) stop("y and pik have different sizes")
if(missing(type) | is.null(N)) {
                   if(missing(type)) warning("the type estimator is missing")
                   warning("by default the mean estimator is computed")
                   est<-crossprod(y,1/pik)/sum(1/pik)}
else if(type=="total") est<-N*crossprod(y,1/pik)/sum(1/pik) 
est
}

Try the sampling package in your browser

Any scripts or data that you put into this service are public.

sampling documentation built on Nov. 2, 2023, 6:26 p.m.