-
Notifications
You must be signed in to change notification settings - Fork 607
/
Copy pathdgampois.Rd
58 lines (55 loc) · 1.88 KB
/
dgampois.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
\name{dgampois}
\alias{dgampois}\alias{rgampois}
\title{Gamma-Poisson probability density}
\description{
Functions for computing density and producing random samples from a gamma-Poisson (negative-binomial) probability distribution.
}
\usage{
dgampois( x , mu , scale , log=FALSE )
rgampois( n , mu , scale )
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x}{Integer values to compute probabilies of}
\item{mu}{Mean of gamma distribution}
\item{scale}{Scale parameter of gamma distribution}
\item{log}{If \code{TRUE}, returns log-probability instead of probability}
\item{n}{Number of random observations to sample}
}
\details{
These functions provide density and random number calculations for gamma-Poisson observations. These functions use \code{dnbinom} and \code{rnbinom} internally, but convert the parameters from the \code{mu} and \code{scale} form. The \code{size} parameter of the negative-binomial is defined by \code{mu/scale}, and the \code{prob} parameter of the negative-binomial is the same as \code{1/(1+scale)}.
}
\references{}
\author{Richard McElreath}
\seealso{}
\examples{
\dontrun{
data(Hurricanes)
# map model fit
# note exp(log_scale) to constrain scale to positive reals
m <- map(
alist(
deaths ~ dgampois( mu , exp(log_scale) ),
log(mu) <- a + b*femininity,
a ~ dnorm(0,100),
b ~ dnorm(0,1),
log_scale ~ dnorm(1,10)
),
data=Hurricanes )
# map2stan model fit
# constraint on scale is passed via contraints list
m.stan <- map2stan(
alist(
deaths ~ dgampois( mu , scale ),
log(mu) <- a + b*femininity,
a ~ dnorm(0,100),
b ~ dnorm(0,1),
scale ~ dcauchy(0,2)
),
data=Hurricanes,
constraints=list(scale="lower=0"),
start=list(scale=2) )
}}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ }