Answered step by step
Verified Expert Solution
Question
1 Approved Answer
my.dgamma.log()generates the log of the probability density of the Gamma distribution. Use?lgammato understand what it does. Note that this is exactly equal to the functiondgamma(...,
my.dgamma.log()generates the log of the probability density of the Gamma distribution. Use?lgammato understand what it does. Note that this is exactly equal to the functiondgamma(..., log=TRUE)so use this to verify your answers.
The function to be debugged:
my.dgamma.log <- function(xx, shape, rate) { shape*log(rate) - lgamma(shape) + (shape-1)*xx - rate*xx }
The testing code:
my.dgamma.log(seq(0.2, 5, by=0.2), shape=0.2, rate=5) dgamma(seq(0.2, 5, by=0.2), shape=0.2, rate=5, log=TRUE) my.dgamma.log (seq(0.4, 10, by=0.4), shape=0.2, rate=5) my.dgamma.log (seq(1, 10, by=0.2), shape=2, rate=6)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started