forked from stephens999/ashr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed51fee
commit 42207cb
Showing
4 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#' @title Performs adaptive shrinkage on Poisson data | ||
#' @description Uses Empirical Bayes to fit the model \deqn{y_j | \lambda_j ~ Poi(c_j \lambda_j)} with \deqn{h(lambda_j) ~ g()} | ||
#' where \eqn{h} is a specified link function (either "identity" or "log" are permitted). | ||
|
||
#' @details The model is fit in two stages: i) estimate \eqn{g} by maximum likelihood (over the set of symmetric | ||
#' unimodal distributions) to give estimate \eqn{\hat{g}}; | ||
#' ii) Compute posterior distributions for \eqn{\lambda_j} given \eqn{y_j,\hat{g}}. | ||
#' Note that the link function \eqn{h} affects the prior assumptions (because, e.g., assuming a unimodal prior on \eqn{\lambda} is | ||
#' different from assuming unimodal on \eqn{\log\lambda}), but posterior quantities are always computed for the | ||
#' for \eqn{\lambda} and *not* \eqn{h(\lambda)}. | ||
#' @param y vector of Poisson observations. | ||
#' @param scale vector of scale factors for Poisson observations: the model is \eqn{y[j]~Pois(scale[j]*lambda[j])}. | ||
#' @param link string, either "identity" or "log", indicating the link function. | ||
#' | ||
#' @examples | ||
#' beta = c(rep(0,50),rexp(50)) | ||
#' y = rpois(100,beta) # simulate Poisson observations | ||
#' y.ash = ash_pois(y,scale=1) | ||
#' @export | ||
ash_pois = function(y, scale=1, link=c("identity","log"), ...){ | ||
link = match.arg(link) | ||
ash(rep(0,length(y)),1,lik=lik_pois(y,scale,link)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.