I am having trouble trying to figure to create a 95% confidence interval for this gamma distribution and calculating the miss right and miss left and their percentages for the sims. From reading User's Guide, I don't know if i should use prov unvariate or the gamma shape parameter. I would appreciate it if someone could help me.
data sample (keep=i x);
sims=10000;
size= 20;
a=3;
do i=1 to sims;
do k=1 to size;
x=RAND('GAMMA',a);
output;
end;
end;
run;
proc sgplot data=sample;
WHERE i=1; /* plot first sample */
histogram x;
run;
proc sgplot data=sample;
WHERE i=2; /* plot second sample */
histogram x;
run;
proc iml;
nsim=3;
do i=1 to nsim;
free x;
x = j(20,1,.);
call randgen(x,'GAMMA',3);
xbar=mean(x);
s=std(x);
k3=kurtosis(x);
print xbar, s,k3;
end;
run;quit;
The original assignment says "compute a 95% CI for mu" [for each sample]. That is not related to quantiles of the gamma distribution.
You might want to review your class notes and carefully study the article "Coverage probability of confidence intervals: A simulation approach"
It is your job to ask your teacher if you have questions about the assignment. We weren't in your class. That said, when I read your assignment, I think your teacher wants the following:
1. Generate the simulated data. (DATA step)
2. Compute the confidence interval of the mean based on the sample (PROC MEANS)
3. The problem says that theta=4 is the mean to use in the null hypothesis. For each sample, compute two indicator variables: missLeft is a binary variable which is 1 if theta is less than the lower endpoint of the CI. Similarly, missRight is a binary variable which is 1 if theta is greater than the upper endpoint of the CI.
HINT: Can you do steps 1-4 for ONE sample?
4. Summarize the percentage of times that theta=4 was "to the left" (of the CI) and to the right (of the CI).
I am having trouble trying to figure to create a 95% confidence interval for this gamma distribution
Are you talking about confidence intervals for the mean of a gamma distribution (which can probably be calculated from the CDF function)? The phrase "confidence interval" only makes sense if you are talking about a specific statistic, such as the mean, but you haven't mentioned any statistic.
Or are you talking about the upper and lower 95 percentile points of a gamma distribution, which I believe can be easily computed from the QUANTILE function in SAS (see https://blogs.sas.com/content/iml/2011/10/19/four-essential-functions-for-statistical-programmers.ht...)
I am talking about the upper and lower 95 percentile points of the gamma distribution. so i would do
data sample;
y=quantile("GAMMA", 0.975,3)
run;
Im sorry, Im very new to the SAS program so I'm not that good on writing codes
@mickir1 wrote:
I am talking about the upper and lower 95 percentile points of the gamma distribution. so i would do
data sample;
y=quantile("GAMMA", 0.975,3)
run;
Im sorry, Im very new to the SAS program so I'm not that good on writing codes
That's the upper limit. The lower limit would use 0.025 in the 2nd argument.
I want this code instead because i have to using sims=1000
%let n=20
%let p=.05;
%let sims=1000;
data sample;
do j=1 to &sims;
y=quantile("GAMMA",&n,&p);
output;
end;
proc print;
run;
Original post and background information at
The original assignment says "compute a 95% CI for mu" [for each sample]. That is not related to quantiles of the gamma distribution.
You might want to review your class notes and carefully study the article "Coverage probability of confidence intervals: A simulation approach"
It is your job to ask your teacher if you have questions about the assignment. We weren't in your class. That said, when I read your assignment, I think your teacher wants the following:
1. Generate the simulated data. (DATA step)
2. Compute the confidence interval of the mean based on the sample (PROC MEANS)
3. The problem says that theta=4 is the mean to use in the null hypothesis. For each sample, compute two indicator variables: missLeft is a binary variable which is 1 if theta is less than the lower endpoint of the CI. Similarly, missRight is a binary variable which is 1 if theta is greater than the upper endpoint of the CI.
HINT: Can you do steps 1-4 for ONE sample?
4. Summarize the percentage of times that theta=4 was "to the left" (of the CI) and to the right (of the CI).
This course has been very challenging, there are no test or quizzes or homework. Just 3 assignments. In the beginning of the semester, my teacher told me not to get the recommended book for the class because most of the information was on the powerpoint slides he will show us. I asked my teacher if he could send me the powerpoint slides so I could take better notes and have a better understanding of the course, however my teacher said he would not because he created these powerpoints and that he is using them for his dissertation. I have asked my teacher for assistance and he's tells me to look at the word documents or "notes" that he has sent for this last assignment, which are not helpful at. I reported him the dean of the college and the dean advised me to go to the sas communities to seek a better understanding and help. I'm not asking you to do my assignment, I'm only seeking some sort of guidance so that I can do well in this class.
I will look at the article you recommended. Thank you.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.