Complementary lognormal_cdf(reals y, reals mu, reals sigma)

I want to customize my likelihood function. In my customized LL, I need the lognormal complementary cumulative distribution function of y. I cannot use lognormal_lccdf as it is the log of what I need. I cannot use 1-lognormal_cdf as I get an error as shown below:

target += 1 -lognormal_cdf(t_0_0_1 | mu_0_0_1, sigma1)

Error in stanc(filename, allow_undefined = TRUE) : 
  failed to parse Stan model '0 Copula-Base' due to the above error.

Would you please advise which function I can use?

Could you use exp(lognormal_lccdf)?

Thank you very much for your reply. I ended up doing that but I was wondering if a direct function is available? Is this method efficient?

No there isn’t a direct function available, so this is likely to be your best bet

Good to know. Thanks.

Would you please let me know why

target += 1 -lognormal_cdf(t_0_0_1 | mu_0_0_1, sigma1)

is not valid and results in the following error?

Error in stanc(filename, allow_undefined = TRUE) : 
  failed to parse Stan model '0 Copula-Base' due to the above error.

Just checking–it’s not a matter of missing a semicolon at the end of the line, is it?

Thank you for the reply. But, no it is not. The error occurs with and without the semicolon

That PARSER EXPECTED sounds like you’re using an older RStan. Vertical bar notation has not always been applied consistently, try with a comma instead.

target += 1 -lognormal_cdf(t_0_0_1, mu_0_0_1, sigma1)

Thank you for your response, @nhuurre.
You are absolutely right.

1 -lognormal_cdf

does not work with vertical bar notation, but it works with a comma.

Based on this I expect to see the same result by these two lines of code:

target += (1-lognormal_cdf(t_0_0_1 , mu_0_0_1, sigma1));
target += exp(lognormal_lccdf(t_0_0_1 | mu_0_0_1, sigma1));

However, based on my experiment they result in two different values. Here is how they are calculated:
The first one → calculates CDF for each row and then multiplies all of them. then, subtracts it from 1.
The second one → calculates log(1-CDF) for each row and sums all of them. Then, calculates the exp of it.

I understand how and why the second one works correctly (log(s1) + log(s2) = log(s1.s2)). However, I don’t understand why lognormal_cdf multiplies all CDF values and does not add them?

Would you please tell me how it works?

A CDF produces a probability and combining independent events to a joint event multiplies their probabilities. Why would you want to add probabilities?
And wait, why does your customized LL (log-likelihood) need a CDF instead of a log-CDF?

Thanks, @nhuurre

My likelihood function contains terms like: (S1+S2)^a, which makes Loglikelihood of a.log(S1+S2).

I think for what I want exp(lccdf(.)) is correct and not 1-cdf(.), right?

Maybe both are wrong and I should use a loop rather than vectorization?