I'm trying to fit finite binomial mixture with 4 components. I have problem with the plot of the gradient function which must be equal or less than 1 in the interval of possible support points but equal to one for the identified support points of the components. Number is the size of the trial and ntarget are the cured patients. The trick here is the different size of each trial.
This was my code for the gradient function (with support points and their weights in the mixture):
data data1; set data; do p=0 to 1 by 0.01; output; end; run;
data data2; set data1;
gradient4 = pdf('BINOM', ntarget, p,number) /
(0.263327842*pdf('BINOM', ntarget, 0.7978980, number) + 0.005551754*pdf('BINOM', ntarget, 0.5080765, number)+0.050572356*pdf('BINOM', ntarget, 0.5080765, number)+ 0.680548048*pdf('BINOM', ntarget, 0.6291304, number));
run;
I get this message which I don't understand:
and the plot for the gradient function which does not prove that the 4 components are NPML :
Could you please explain the error I got up there and if the gradient function is correctly specified.
Thank you
I can't guarantee that this is the issue but the syntax should be:
value = pdf('BINOMIAL', number_of_successes, probability_of_success, number_of_independent_trials)
Just looking at the values in the NOTEs, I would guess that you have switched the first and last values, as the line of data always has Number strictly greater than Ntarget. Try exchanging the two variables in your call to the PDF function.:
SteveDenham
I interchanged those values but I got nothing. I see the gradient function is correctly specified. I think the errors are results of zero in denominator. For certain values the probability of assigning the successes to each component is zero . I run an equivalent code in R and I got the entire output for the numerator and denominator. I can see there are several zeros for the dominators. R stops there but SAS treats errors as missing values and imput them.
What function you are trying to compute the gradient of? And which parameters are you using to compute the gradient?
Often we use a log-likelihood function and compute the gradient with respect to the parameters of the distribution that we are fitting, but I cannot tell what you are computing here.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.