R/IPSWeights.R

Defines functions IPSWeights

Documented in IPSWeights

#' Inverse probability sampling weight
#' 
#' Calculate IPS weights
#' @param pi1 sampling probability of category 1
#' @param pi2 sampling probability of catagory 2
#' @param n1 size of category 1
#' @param n2 size of category 2
#' @export
#' @return length n1+n2 vector of corresponding weights

IPSWeights = function(pi1,pi2,n1,n2){
  w1 = 1/pi1
  w2 = 1/pi2
  w = c(rep(w1,n1),rep(w2,n2))
  #w = w/sum(w)
  return(w)
}
hsong1/PUlearning documentation built on May 16, 2017, 11:27 p.m.