Sebastiano Putoto
2011-Sep-19 20:17 UTC
[R] Poisson-Gamma computation (parameters and likelihood)
Good afternoon/morning readers. This is the first time I am trying to run
some Bayesian computation in R, and am experiencing a few problems.
I am working on a Poisson model for cancer rates which has a conjugate Gamma
prior.
1) The first question is precisely how I work out the parameters.
#Suppose I assign values to theta with *seq()*
*theta<-seq(0,1,len=500)*
#Then I try out the parameters that seem to fit with a certain prior idea on
theta (see next)
*a=182*
*b=3530*
*gaprior<-dgamma(theta,a,b)*
*
*
It should work by trial-and-error (according to "Bayesian Computation with
R") , but how can I check the parameters turned out well: should I just
look
at the plot, or evaluate it through the *1 - pgamma(x,a,b) *function, having
knowledge of the 5th percentile (data from US Cancer Statistics)?
2) Then, the next problem I have regards the likelihood distribution.
#Having the *react* table, I name the columns (with y=deaths, and
x=exposures)
*
react
x y
1 6 15
2 5 16
3 3 12
4 4 6
5 27 77
6 7 17
7 4 11
8 5 10
9 23 63
10 11 29
*
*yr <- react[,2]*
*xr <- react[,1]*
#I then compute the likelihood
*poislike=dpois(yr, theta*xr)*
#And this is what I come up with, which I really don't understand.
*poislike*
*[1] 0 0 0 0 0 0 0 0 0 0*
The values shouldn't be all null, otherwise my posterior cannot be computed
properly. Does anyone have any idea on where I could possibly have messed it
up?
Thank you very much for your attention.
Regards,
Sebastiano Putoto (University of Pavia, Italy)
[[alternative HTML version deleted]]
Sebastiano Putoto
2011-Sep-20 13:19 UTC
[R] Poisson-Gamma computation (parameters and likelihood)
Good afternoon/morning readers. This is the first time I am trying to run
some Bayesian computation in R, and am experiencing a few problems.
I am working on a Poisson model for cancer rates which has a conjugate Gamma
prior.
1) The first question is precisely how I work out the parameters.
#Suppose I assign values to theta with *seq()*
*theta<-seq(0,1,len=500)*
#Then I try out the parameters that seem to fit with a certain prior idea on
theta (see next)
*a=182*
*b=3530*
*gaprior<-dgamma(theta,a,b)*
*
*
It should work by trial-and-error (according to "Bayesian Computation with
R") , but how can I check the parameters turned out well: should I just
look
at the plot, or evaluate it through the *1 - pgamma(x,a,b) *function, having
knowledge of the 5th percentile (data from US Cancer Statistics)?
2) Then, the next problem I have regards the likelihood distribution.
#Having the *react* table, I name the columns (with y=deaths, and
x=exposures)
*
react
x y
1 6 15
2 5 16
3 3 12
4 4 6
5 27 77
6 7 17
7 4 11
8 5 10
9 23 63
10 11 29
*
*yr <- react[,2]*
*xr <- react[,1]*
#I then compute the likelihood
*poislike=dpois(yr, theta*xr)*
#And this is what I come up with, which I really don't understand.
*poislike*
*[1] 0 0 0 0 0 0 0 0 0 0*
The values shouldn't be all null, otherwise my posterior cannot be computed
properly. Does anyone have any idea on where I could possibly have messed it
up?
Thank you very much for your attention.
Regards,
Sebastiano Putoto (University of Pavia, Italy)
[[alternative HTML version deleted]]
Sebastiano Putoto
2011-Sep-21 09:25 UTC
[R] Poisson-Gamma computation (parameters and likelihood)
Good afternoon/morning readers. This is the first time I am trying to run
some Bayesian computation in R, and am experiencing a few problems.
I am working on a Poisson model for cancer rates which has a conjugate Gamma
prior.
1) The first question is precisely how I work out the parameters.
#Suppose I assign values to theta with seq()
theta<-seq(0,1,len=500)
#Then I try out the parameters that seem to fit with a certain prior idea on
theta (see next)
a=182
b=3530
gaprior<-dgamma(theta,a,b)
It should work by trial-and-error (according to "Bayesian Computation with
R") , but how can I check the parameters turned out well: should I just
look
at the plot, or evaluate it through the 1 - pgamma(x,a,b) function, having
knowledge of the 5th percentile (data from US Cancer Statistics)?
2) Then, the next problem I have regards the likelihood distribution.
#Having the react table, I name the columns (with y=deaths, and x=exposures)
react
x y
1 6 15
2 5 16
3 3 12
4 4 6
5 27 77
6 7 17
7 4 11
8 5 10
9 23 63
10 11 29
yr <- react[,2]
xr <- react[,1]
#I then compute the likelihood
poislike=dpois(yr, theta*xr)
#And this is what I come up with, which I really don't understand.
poislike
[1] 0 0 0 0 0 0 0 0 0 0
The values shouldn't be all null, otherwise my posterior cannot be computed
properly. Does anyone have any idea on where I could possibly have messed it
up?
Thank you very much for your attention.
Regards,
Sebastiano Putoto (University of Pavia, Italy)
[[alternative HTML version deleted]]