[R] rgamma function produces NaN values
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Fri Mar 6 16:45:17 CET 2020
Unless there is a good reason not to, always cc the list in your responses.
I am not your free private consultant.
Beause you use your own function, your result is not reproducible, so that
it is unlikely you can get useful help.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Fri, Mar 6, 2020 at 6:11 AM Sanna Soomro <s.soomro97 using gmail.com> wrote:
> Hi
>
>
>
> I apologize for the late response – I’ve been busy.
>
> I have attached my R code in the email but I don’t know if it gone
> through.
>
> The gibb_lasso function is what I created myself.
>
> The packages I am using are mvtnorm, GIGrvg, tmvtnorm, RGeode and
> truncnorm.
>
>
>
> Best regards
>
> Sanna
>
>
>
> *From: *Bert Gunter <bgunter.4567 using gmail.com>
> *Date: *Thursday, 5 March 2020 at 15:40
> *To: *Sanna Soomro <s.soomro97 using gmail.com>
> *Subject: *Re: [R] rgamma function produces NaN values
>
>
>
> What package are you using? -- this is requested by the posting guide.
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
>
>
>
> On Thu, Mar 5, 2020 at 12:50 AM Sanna Soomro <s.soomro97 using gmail.com> wrote:
>
> Hi,
>
> In my code, I want to sample from the posterior distribution to get
> estimates for each parameter via the Bayesian approach. My model has
> spatial coefficient and lasso penalty.
>
> When I run this line
>
> gibbs_lasso(y = Y, x= X, W=W.rook, tau = 0.5, M=2)
>
> It works, however, when I changed M from 2 to 5, I get the following error:
>
> Error in rgig(1, 0.5, (SIGMA[m, ]/theta2) * ((y[ik] - crossprod(x[ik, :
> invalid parameters for GIG distribution: lambda=0.5, chi=nan, psi=nan
> In addition: Warning message:
> In rgamma(1, shape = 1.5 * n + a0, rate = SIGMAgamma + b0) : NAs produced
>
> It makes sense that rgig cannot accept NaN values of sigma parameter in its
> computation. But why does rgamma produces NaN value for sigma? The gamma
> distribution require both shape and scale parameters to be positive and my
> R computations for both should always be positive then sigma can be sampled
> easily. So, what went wrong in my code?
>
> Best regards
> Sanna
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list