```
#' 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)
}
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.