Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Sample size calculations for a one-sided tolerance limit

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-06-2023 09:05 AM
(385 views)

I need to determine the minimum sample size/create a power curve for computing a 95%-95% upper tolerance limit. I see that proc power has functionality for many power computations but not for tolerance intervals. From what I have investigated thus far, I would need to set up monte carlo simulations to create the power curve. Is there an easier way? Minitab and other packages have this functionality through menu driven platforms so I am hoping that with the inclusiveness of SAS procedures there is a way to perform this task.

Any advice would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello @djgetty and welcome to the SAS Support Communities!

Looking at the formulas in the Minitab® 20 documentation Methods and formulas for Sample Size for Tolerance Intervals, I think you can compute the sample size in a DATA step. You can also define a function (PROC FCMP) for this purpose. The latter will be particularly convenient when it comes to creating graphs visualizing the relationship between sample size and other statistics in the context of tolerance intervals. (How do you define a "power curve" for a tolerance interval rather than a hypothesis test?)

Here is an example for the case of a normal distribution: The DATA step below simply passes through the sample sizes n=2, 3, 4, ..., until the criterion for the one-sided tolerance interval is met (see the Minitab documentation linked above; I denote their parameters a, a* and e by a, ax and e, respectively).

```
data want;
a=0.05;
p=0.95;
e=0.03;
ax=0.05;
do n=2 to 1e6 until(q1<=q2);
q1=quantile('t',1-a,n-1,probit(p)*sqrt(n));
q2=quantile('t',ax,n-1,probit(p+e)*sqrt(n));
end;
put n=;
run;
```

The same result, n=177, can be obtained with the user-defined function ntolu defined below:

```
proc fcmp outlib=work.funcs.test;
function f(a,p,e,ax,n);
return(quantile('t', ax,n-1,sqrt(n)*probit(p+e))
-quantile('t',1-a,n-1,sqrt(n)*probit(p)));
endsub;
function ntolu(a,p,e,ax,init);
n=ceil(solve('f',{init},0,a,p,e,ax,.));
return(n);
endsub;
run;
options cmplib=work.funcs;
data _null_;
n=ntolu(0.05,0.95,0.03,0.05,100);
put n=;
run;
```

For other parameter values you may or may not need to adjust the initial value (init=100) in the last argument of the function.

Simulated data could be used to *verify* that the sample size is sufficient to achieve the target values specified in the parameters.

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

I believe in JMP you can also do this through a menu driven platform.

(JMP is a wholly owned subsidiary of SAS --> https://community.jmp.com/)

In SAS, you will need some programming.

Start here :

- Using simulation to estimate the power of a statistical test

By Rick Wicklin on The DO Loop May 30, 2013

https://blogs.sas.com/content/iml/2013/05/30/simulation-power.html - Using simulation to compute a
**power curve**

By Rick Wicklin on The DO Loop June 5, 2013

https://blogs.sas.com/content/iml/2013/06/05/simulation-power-curve.html - Estimate a
**power curve**in parallel in SAS Viya

By Rick Wicklin on The DO Loop August 17, 2020

https://blogs.sas.com/content/iml/2020/08/17/power-curve-parallel-sas-viya.html

Koen

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hello @djgetty and welcome to the SAS Support Communities!

Looking at the formulas in the Minitab® 20 documentation Methods and formulas for Sample Size for Tolerance Intervals, I think you can compute the sample size in a DATA step. You can also define a function (PROC FCMP) for this purpose. The latter will be particularly convenient when it comes to creating graphs visualizing the relationship between sample size and other statistics in the context of tolerance intervals. (How do you define a "power curve" for a tolerance interval rather than a hypothesis test?)

Here is an example for the case of a normal distribution: The DATA step below simply passes through the sample sizes n=2, 3, 4, ..., until the criterion for the one-sided tolerance interval is met (see the Minitab documentation linked above; I denote their parameters a, a* and e by a, ax and e, respectively).

```
data want;
a=0.05;
p=0.95;
e=0.03;
ax=0.05;
do n=2 to 1e6 until(q1<=q2);
q1=quantile('t',1-a,n-1,probit(p)*sqrt(n));
q2=quantile('t',ax,n-1,probit(p+e)*sqrt(n));
end;
put n=;
run;
```

The same result, n=177, can be obtained with the user-defined function ntolu defined below:

```
proc fcmp outlib=work.funcs.test;
function f(a,p,e,ax,n);
return(quantile('t', ax,n-1,sqrt(n)*probit(p+e))
-quantile('t',1-a,n-1,sqrt(n)*probit(p)));
endsub;
function ntolu(a,p,e,ax,init);
n=ceil(solve('f',{init},0,a,p,e,ax,.));
return(n);
endsub;
run;
options cmplib=work.funcs;
data _null_;
n=ntolu(0.05,0.95,0.03,0.05,100);
put n=;
run;
```

For other parameter values you may or may not need to adjust the initial value (init=100) in the last argument of the function.

Simulated data could be used to *verify* that the sample size is sufficient to achieve the target values specified in the parameters.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

What is ANOVA?

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.