<?xml-stylesheet type="text/xsl" href="../styles/pmathml.xsl"?>
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dsi="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xml:space="preserve"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"/><title>G07CAF : NAG Library, Mark 22</title><link rel="stylesheet" href="../styles/libdoc.css" type="text/css"/><script type="text/javascript">
   function showLevel(_levelId){
    var thisLevel = document.getElementById(_levelId);
    var thisplus = document.getElementById( _levelId.concat('plus'));
    var thisminus = document.getElementById( _levelId.concat('minus'));
    if(thisLevel.style.display != "block"){
     thisLevel.style.display = "block";
     thisplus.style.display = "none";
     thisminus.style.display = "inline";
     }
    else{
     thisLevel.style.display = "none";
     thisminus.style.display = "none";
     thisplus.style.display = "inline";
     }
    }
  </script></head><body><hr/><div><a class="rout" href="../../pdf/G07/g07caf.pdf">G07CAF (PDF version)</a></div><div><a class="chap" href="g07conts.xml">G07 Chapter Contents</a></div><div><a class="chapint" href="g07intro.xml">G07 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Library Routine Document<br/><br/>G07CAF</h1><div class="paramtext"><div class="header"><b>Note:</b>&#160; before using this routine, please read the Users' Note for your implementation to check the interpretation of <span class="bitalic">bold italicised</span> terms and other implementation-dependent details.</div></div> 
<div class="htmltoc">
<h2 class="htmltoc"><span class="htmltochead" onclick="showLevel('htmltoc');"><span class="htmltocplus" id="htmltocplus">+</span><span class="htmltocminus" id="htmltocminus">&#8722;</span></span>&#160;Contents</h2>
<div class="htmltocitem" id="htmltoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#purpose">1&#160;&#160;<b>Purpose</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">3&#160;&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">4&#160;&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">5&#160;&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">6&#160;&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">7&#160;&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocexample');"><span class="htmltocplus" id="tocexampleplus">+</span><span class="htmltocminus" id="tocexampleminus">&#8722;</span></span>
<a class="htmltoc" href="#example">9&#160;&#160;<b>Example</b></a>
<div class="htmltocitem" id="tocexample">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examtext">9.1&#160;&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">9.2&#160;&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">9.3&#160;&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2>
<div class="paramtext">G07CAF computes a <m:math><m:mi>t</m:mi></m:math>-test statistic to test for a difference in means between two Normal populations, together with a confidence interval for the difference between the means.</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;G07CAF&#160;(</td><td class="tdfspec2"><a class="arg" href="#TAIL">TAIL</a>, <a class="arg" href="#EQUAL">EQUAL</a>, <a class="arg" href="#NX">NX</a>, <a class="arg" href="#NY">NY</a>, <a class="arg" href="#XMEAN">XMEAN</a>, <a class="arg" href="#YMEAN">YMEAN</a>, <a class="arg" href="#XSTD">XSTD</a>, <a class="arg" href="#YSTD">YSTD</a>, <a class="arg" href="#CLEVEL">CLEVEL</a>, <a class="arg" href="#T">T</a>, <a class="arg" href="#DF">DF</a>, <a class="arg" href="#PROB">PROB</a>, <a class="arg" href="#DL">DL</a>, <a class="arg" href="#DU">DU</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NX, NY, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XMEAN, YMEAN, XSTD, YSTD, CLEVEL, T, DF, PROB, DL, DU</td></tr><tr><td class="tdfspec1">CHARACTER*1</td><td class="tdfspec2">TAIL, EQUAL</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">Consider two independent samples, denoted by <m:math><m:mi>X</m:mi></m:math>&#160;and <m:math><m:mi>Y</m:mi></m:math>, of size <m:math><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub></m:math>&#160;drawn from two Normal populations with means <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>, and variances <m:math><m:msubsup><m:mi>&#963;</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup></m:math>&#160;and <m:math><m:msubsup><m:mi>&#963;</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup></m:math>&#160;respectively.  Denote the sample means by <m:math><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover></m:math>&#160;and <m:math><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:math>&#160;and the sample variances by <m:math><m:msubsup><m:mi>s</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup></m:math>&#160;and <m:math><m:msubsup><m:mi>s</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup></m:math>&#160;respectively.</div><div class="paramtext">G07CAF calculates a test statistic and its significance level to test the null hypothesis <m:math><m:msub><m:mi>H</m:mi><m:mn>0</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>=</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>, together with upper and lower confidence limits for <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>.  The test used depends on whether or not the two population variances are assumed to be equal.
<ol class="listnumber"><li class="listnumber">It is assumed that the two variances are equal, that is <m:math><m:msubsup><m:mi>&#963;</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup><m:mo>=</m:mo><m:msubsup><m:mi>&#963;</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup></m:math>.
 <div class="paramtext">The test used is the two sample <m:math><m:mi>t</m:mi></m:math>-test.  The test statistic <m:math><m:mi>t</m:mi></m:math>&#160;is defined by;

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msub><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi></m:msub><m:mo>=</m:mo><m:mfrac><m:mrow><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mrow>
  <m:mrow><m:mi>s</m:mi><m:msqrt><m:mfenced separators=""><m:mn>1</m:mn><m:mo>/</m:mo><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub></m:mfenced><m:mo>+</m:mo><m:mfenced separators=""><m:mn>1</m:mn><m:mo>/</m:mo><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub></m:mfenced></m:msqrt></m:mrow>
 </m:mfrac>
</m:math></td><td class="formula2"/></tr></table></div>

where 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msup><m:mi>s</m:mi><m:mn>2</m:mn></m:msup>
 <m:mo>=</m:mo>
 <m:mfrac>
  <m:mrow>
   <m:mfenced separators=""><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
   <m:msubsup><m:mi>s</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup>
   <m:mo>+</m:mo>
   <m:mfenced separators=""><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
   <m:msubsup><m:mi>s</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup>
  </m:mrow>
  <m:mrow>
   <m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub>
   <m:mo>+</m:mo>
   <m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub>
   <m:mo>-</m:mo>
   <m:mn>2</m:mn>
  </m:mrow>
 </m:mfrac>
</m:math></td><td class="formula2"/></tr></table></div>
 
is the pooled variance of the two samples.</div>
 <div class="paramtext">Under the null hypothesis <m:math><m:msub><m:mi>H</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;this test statistic has a <m:math><m:mi>t</m:mi></m:math>-distribution with <m:math><m:mfenced separators=""><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub><m:mo>+</m:mo><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub><m:mo>-</m:mo><m:mn>2</m:mn></m:mfenced></m:math>&#160;degrees of freedom.</div>
 <div class="paramtext">The test of <m:math><m:msub><m:mi>H</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;is carried out against one of three possible alternatives;
 <ul class="listind"><li class="listind"><m:math><m:msub><m:mi>H</m:mi><m:mn>1</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>&#8800;</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>; the significance level, <m:math><m:mi>p</m:mi><m:mo>=</m:mo><m:mi>P</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>&#8805;</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi></m:msub></m:mfenced></m:mfenced></m:math>, i.e., a two tailed probability.</li><li class="listind"><m:math><m:msub><m:mi>H</m:mi><m:mn>1</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>&gt;</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>; the significance level, <m:math><m:mi>p</m:mi><m:mo>=</m:mo><m:mi>P</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>&#8805;</m:mo><m:msub><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi></m:msub></m:mfenced></m:math>, i.e., an upper tail probability.</li><li class="listind"><m:math><m:msub><m:mi>H</m:mi><m:mn>1</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>&lt;</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>; the significance level, <m:math><m:mi>p</m:mi><m:mo>=</m:mo><m:mi>P</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>&#8804;</m:mo><m:msub><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi></m:msub></m:mfenced></m:math>, i.e., a lower tail probability.</li></ul>
</div>
<div class="paramtext">Upper and lower <m:math><m:mn>100</m:mn><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi></m:mfenced><m:mo>%</m:mo></m:math>&#160;confidence limits for <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>&#160;are calculated as:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mfenced separators=""><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mfenced><m:mo>&#177;</m:mo><m:msub><m:mi>t</m:mi><m:mrow><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:msub><m:mi>s</m:mi><m:msqrt><m:mfenced separators=""><m:mn>1</m:mn><m:mo>/</m:mo><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub></m:mfenced><m:mo>+</m:mo><m:mfenced separators=""><m:mn>1</m:mn><m:mo>/</m:mo><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub></m:mfenced></m:msqrt><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:msub><m:mi>t</m:mi><m:mrow><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:msub></m:math>&#160;is the <m:math><m:mn>100</m:mn><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mfenced></m:math>&#160;percentage point of the <m:math><m:mi>t</m:mi></m:math>-distribution with (<m:math><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub><m:mo>+</m:mo><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub><m:mo>-</m:mo><m:mn>2</m:mn></m:math>) degrees of freedom.</div></li><li class="listnumber">It is not assumed that the two variances are equal.
 <div class="paramtext">If the population variances are not equal the usual two sample <m:math><m:mi>t</m:mi></m:math>-statistic no longer has a <m:math><m:mi>t</m:mi></m:math>-distribution and an approximate test is used.</div>
 <div class="paramtext">This problem is often referred to as the Behrens&#8211;Fisher problem, see <a class="ref" href="#ref238">Kendall and Stuart (1969)</a>.  The test used here is based on Satterthwaites procedure.  To test the null hypothesis the test statistic <m:math><m:msup><m:mi>t</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;is used where

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msubsup><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi><m:mo>&#8242;</m:mo></m:msubsup><m:mo>=</m:mo><m:mfrac><m:mrow><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mrow>
  <m:mrow><m:mi>se</m:mi><m:mfenced separators=""><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mfenced></m:mrow>
 </m:mfrac>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mrow><m:mi>se</m:mi><m:mfenced separators=""><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mfenced></m:mrow><m:mo>=</m:mo><m:msqrt><m:mfrac other="display">
  <m:msubsup><m:mi>s</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub></m:mfrac><m:mo>+</m:mo><m:mfrac other="display">
  <m:msubsup><m:mi>s</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub></m:mfrac></m:msqrt></m:math>.</div>
 <div class="paramtext">A <m:math><m:mi>t</m:mi></m:math>-distribution with <m:math><m:mi>f</m:mi></m:math>&#160;degrees of freedom is used to approximate the distribution of <m:math><m:msup><m:mi>t</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;where

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>f</m:mi>
 <m:mo>=</m:mo>
 <m:mfrac>
  <m:mrow><m:mi>se</m:mi><m:mo>&#8289;</m:mo><m:msup>
     <m:mfenced separators="">
      <m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover>
      <m:mo>-</m:mo>
      <m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover>
     </m:mfenced>
     <m:mn>4</m:mn>
    </m:msup></m:mrow>
  <m:mrow>
   <m:mfrac other="display">
    <m:msup>
     <m:mfenced separators="">
      <m:msubsup><m:mi>s</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup>
      <m:mo>/</m:mo>
      <m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub>
     </m:mfenced>
     <m:mn>2</m:mn>
    </m:msup>
    <m:mfenced separators=""><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
   </m:mfrac>
   <m:mo>+</m:mo>
   <m:mfrac other="display">
    <m:msup>
     <m:mfenced separators="">
      <m:msubsup><m:mi>s</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup>
      <m:mo>/</m:mo>
      <m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub>
     </m:mfenced>
     <m:mn>2</m:mn>
    </m:msup>
    <m:mfenced separators=""><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
   </m:mfrac>
  </m:mrow>
 </m:mfrac>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

The test of <m:math><m:msub><m:mi>H</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;is carried out against one of the three alternative hypotheses described above, replacing <m:math><m:mi>t</m:mi></m:math>&#160;by <m:math><m:msup><m:mi>t</m:mi><m:mo>&#8242;</m:mo></m:msup></m:math>&#160;and <m:math><m:msub><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi></m:msub></m:math>&#160;by <m:math><m:msubsup><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi><m:mo>&#8242;</m:mo></m:msubsup></m:math>.</div>
 <div class="paramtext">Upper and lower <m:math><m:mn>100</m:mn><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi></m:mfenced><m:mo>%</m:mo></m:math>&#160;confidence limits for <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>&#160;are calculated as:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mfenced separators=""><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mfenced><m:mo>&#177;</m:mo><m:msub><m:mi>t</m:mi><m:mrow><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:msub><m:mrow><m:mi>se</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>-</m:mo><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:mfenced></m:mrow><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:msub><m:mi>t</m:mi><m:mrow><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mrow></m:msub></m:math>&#160;is the <m:math><m:mn>100</m:mn><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:mfenced></m:math>&#160;percentage point of the <m:math><m:mi>t</m:mi></m:math>-distribution with <m:math><m:mi>f</m:mi></m:math>&#160;degrees of freedom.</div></li></ol>
</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref414" id="ref414"/>Johnson M G and Kotz A (1969)  <i>The Encyclopedia of Statistics</i> <b>2</b> Griffin </div>
<div class="paramtext"><a name="ref238" id="ref238"/>Kendall M G and Stuart A (1969)  <i>The Advanced Theory of Statistics (Volume 1)</i> (3rd Edition) Griffin </div>
<div class="paramtext"><a name="ref409" id="ref409"/>Snedecor G W and Cochran W G (1967)  <i>Statistical Methods</i> Iowa State University Press </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="TAIL" id="TAIL"/>1: &#160;&#160;&#8194; TAIL &#8211; CHARACTER*1<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates which tail probability is to be calculated, and thus which alternative hypothesis is to be used.

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">TAIL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'T'</m:mtext></m:math></dt>
<dd>The two tail probability, i.e., <m:math><m:msub><m:mi>H</m:mi><m:mn>1</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>&#8800;</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">TAIL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'U'</m:mtext></m:math></dt>
<dd>The upper tail probability, i.e., <m:math><m:msub><m:mi>H</m:mi><m:mn>1</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>&gt;</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">TAIL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'L'</m:mtext></m:math></dt>
<dd>The lower tail probability, i.e., <m:math><m:msub><m:mi>H</m:mi><m:mn>1</m:mn></m:msub><m:mo>:</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>&lt;</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">TAIL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'T'</m:mtext></m:math>, <m:math><m:mtext>'U'</m:mtext></m:math>&#160;or <m:math><m:mtext>'L'</m:mtext></m:math>.
</div></dd><dt class="paramhead"><a name="EQUAL" id="EQUAL"/>2: &#160;&#160;&#8194; EQUAL &#8211; CHARACTER*1<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates whether the population variances are assumed to be equal or not.

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EQUAL"><m:mi mathcolor="#EE0000" mathvariant="bold">EQUAL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'E'</m:mtext></m:math></dt>
<dd>The population variances are assumed to be equal, that is <m:math><m:msubsup><m:mi>&#963;</m:mi><m:mi>x</m:mi><m:mn>2</m:mn></m:msubsup><m:mo>=</m:mo><m:msubsup><m:mi>&#963;</m:mi><m:mi>y</m:mi><m:mn>2</m:mn></m:msubsup></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EQUAL"><m:mi mathcolor="#EE0000" mathvariant="bold">EQUAL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'U'</m:mtext></m:math></dt>
<dd>The population variances are not assumed to be equal.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EQUAL"><m:mi mathcolor="#EE0000" mathvariant="bold">EQUAL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'E'</m:mtext></m:math>&#160;or <m:math><m:mtext>'U'</m:mtext></m:math>.
</div></dd><dt class="paramhead"><a name="NX" id="NX"/>3: &#160;&#160;&#8194; NX &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>n</m:mi><m:mi>x</m:mi></m:msub></m:math>, the size of the <m:math><m:mi>X</m:mi></m:math>&#160;sample.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NX"><m:mi mathcolor="#EE0000" mathvariant="bold">NX</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>2</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="NY" id="NY"/>4: &#160;&#160;&#8194; NY &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>n</m:mi><m:mi>y</m:mi></m:msub></m:math>, the size of the <m:math><m:mi>Y</m:mi></m:math>&#160;sample.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NY"><m:mi mathcolor="#EE0000" mathvariant="bold">NY</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>2</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="XMEAN" id="XMEAN"/>5: &#160;&#160;&#8194; XMEAN &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mover><m:mi>x</m:mi><m:mo>-</m:mo></m:mover></m:math>, the mean of the <m:math><m:mi>X</m:mi></m:math>&#160;sample.</div></dd><dt class="paramhead"><a name="YMEAN" id="YMEAN"/>6: &#160;&#160;&#8194; YMEAN &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mover><m:mi>y</m:mi><m:mo>-</m:mo></m:mover></m:math>, the mean of the <m:math><m:mi>Y</m:mi></m:math>&#160;sample.</div></dd><dt class="paramhead"><a name="XSTD" id="XSTD"/>7: &#160;&#160;&#8194; XSTD &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>s</m:mi><m:mi>x</m:mi></m:msub></m:math>, the standard deviation of the <m:math><m:mi>X</m:mi></m:math>&#160;sample.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#XSTD"><m:mi mathcolor="#EE0000" mathvariant="bold">XSTD</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>0.0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="YSTD" id="YSTD"/>8: &#160;&#160;&#8194; YSTD &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>s</m:mi><m:mi>y</m:mi></m:msub></m:math>, the standard deviation of the <m:math><m:mi>Y</m:mi></m:math>&#160;sample.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#YSTD"><m:mi mathcolor="#EE0000" mathvariant="bold">YSTD</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>0.0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="CLEVEL" id="CLEVEL"/>9: &#160;&#160;&#8194; CLEVEL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the confidence level, <m:math><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#945;</m:mi></m:math>, for the specified tail. For example <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#CLEVEL"><m:mi mathcolor="#EE0000" mathvariant="bold">CLEVEL</m:mi></m:maction><m:mo>=</m:mo><m:mn>0.95</m:mn></m:math>&#160;will give a <m:math><m:mn>95</m:mn><m:mo>%</m:mo></m:math>&#160;confidence interval.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mn>0.0</m:mn><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#CLEVEL"><m:mi mathcolor="#EE0000" mathvariant="bold">CLEVEL</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1.0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="T" id="T"/>10: &#8194; T &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: contains the test statistic, <m:math><m:msub><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi></m:msub></m:math>&#160;or <m:math><m:msubsup><m:mi>t</m:mi><m:mi mathvariant="normal">obs</m:mi><m:mo>&#8242;</m:mo></m:msubsup></m:math>.</div></dd><dt class="paramhead"><a name="DF" id="DF"/>11: &#8194; DF &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: contains the degrees of freedom for the test statistic.</div></dd><dt class="paramhead"><a name="PROB" id="PROB"/>12: &#8194; PROB &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: contains the significance level, that is the tail probability, <m:math><m:mi>p</m:mi></m:math>, as defined by <a class="arg" href="#TAIL">TAIL</a>.</div></dd><dt class="paramhead"><a name="DL" id="DL"/>13: &#8194; DL &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: contains the lower confidence limit for <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>.</div></dd><dt class="paramhead"><a name="DU" id="DU"/>14: &#8194; DU &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: contains the upper confidence limit for <m:math><m:msub><m:mi>&#956;</m:mi><m:mi>x</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>&#956;</m:mi><m:mi>y</m:mi></m:msub></m:math>.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>15: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>). <div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, if you are not familiar with this parameter, the recommended value is <m:math><m:mn>0</m:mn></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn mathvariant="bold">1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div></div></dd></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">-1</m:mn></m:maction></m:math>, explanatory error messages are output on the current error message unit (as defined by <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">TAIL</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mtext>'T'</m:mtext></m:math>, <m:math><m:mtext>'U'</m:mtext></m:math>&#160;or <m:math><m:mtext>'L'</m:mtext></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EQUAL"><m:mi mathcolor="#EE0000" mathvariant="bold">EQUAL</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mtext>'E'</m:mtext></m:math>&#160;or <m:math><m:mtext>'U'</m:mtext></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NX"><m:mi mathcolor="#EE0000" mathvariant="bold">NX</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>2</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NY"><m:mi mathcolor="#EE0000" mathvariant="bold">NY</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>2</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#XSTD"><m:mi mathcolor="#EE0000" mathvariant="bold">XSTD</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0.0</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#YSTD"><m:mi mathcolor="#EE0000" mathvariant="bold">YSTD</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0.0</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#CLEVEL"><m:mi mathcolor="#EE0000" mathvariant="bold">CLEVEL</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0.0</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#CLEVEL"><m:mi mathcolor="#EE0000" mathvariant="bold">CLEVEL</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>1.0</m:mn></m:math>.</td></tr></table>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The computed probability and the confidence limits should be accurate to approximately five significant figures.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The sample means and standard deviations can be computed using <a class="rout" href="../G01/g01aaf.xml">G01AAF</a>.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example reads the two sample sizes and the sample means and standard deviations for two independent samples.  The data is taken from page 116 of <a class="ref" href="#ref409">Snedecor and Cochran (1967)</a> from a test to compare two methods of estimating the concentration of a chemical in a vat.  A test of the equality of the means is carried out first assuming that the two population variances are equal and then making no assumption about the equality of the population variances.</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<p><a class="verbatimref" href="../../examples/source/g07cafe.f">Program Text (g07cafe.f)</a></p><h3 class="standard"><a class="sec" name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3>
<p><a class="verbatimref" href="../../examples/data/g07cafe.d">Program&#160;Data (g07cafe.d)</a></p><h3 class="standard"><a class="sec" name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3>
<p><a class="verbatimref" href="../../examples/baseresults/g07cafe.r">Program Results (g07cafe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/G07/g07caf.pdf">G07CAF (PDF version)</a></div><div><a class="chap" href="g07conts.xml">G07 Chapter Contents</a></div><div><a class="chapint" href="g07intro.xml">G07 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div>
<div><hr/><a class="genint" href="../FRONTMATTER/copyright.xml">&#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2009</a></div></body></html>
