/* nag_2_sample_t_test (g07cac) Example Program.
*
* Copyright 2017 Numerical Algorithms Group.
*
* Mark 26.2, 2017.
*
*/
#include <nag.h>
#include <stdio.h>
#include <nag_stdlib.h>
#include <nagg07.h>
int main(void)
{
/* Local variables */
double prob, xstd, ystd;
double t;
double xmean, ymean, df, dl, du;
double clevel;
Integer exit_status = 0, nx, ny;
NagError fail;
INIT_FAIL(fail);
printf("nag_2_sample_t_test (g07cac) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n]");
scanf("%" NAG_IFMT " %" NAG_IFMT "", &nx, &ny);
scanf("%lf %lf %lf %lf", &xmean, &ymean, &xstd, &ystd);
scanf("%lf", &clevel);
/* nag_2_sample_t_test (g07cac).
* Computes t-test statistic for a difference in means
* between two Normal populations, confidence interval
*/
nag_2_sample_t_test(Nag_TwoTail, Nag_PopVarEqual, nx, ny, xmean, ymean,
xstd, ystd, clevel, &t, &df, &prob, &dl, &du, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_2_sample_t_test (g07cac).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
printf("\nAssuming population variances are equal.\n\n");
printf("t test statistic = %10.4f\n", t);
printf("Degrees of freedom = %8.1f\n", df);
printf("Significance level = %8.4f\n", prob);
printf("Lower confidence limit for difference in means = %10.4f\n", dl);
printf("Upper confidence limit for difference in means = %10.4f\n\n", du);
/* nag_2_sample_t_test (g07cac), see above. */
nag_2_sample_t_test(Nag_TwoTail, Nag_PopVarNotEqual, nx, ny, xmean, ymean,
xstd, ystd, clevel, &t, &df, &prob, &dl, &du, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_2_sample_t_test (g07cac).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
printf("\nNo assumptions about population variances.\n\n");
printf("t test statistic = %10.4f\n", t);
printf("Degrees of freedom = %8.4f\n", df);
printf("Significance level = %8.4f\n", prob);
printf("Lower confidence limit for difference in means = %10.4f\n", dl);
printf("Upper confidence limit for difference in means = %10.4f\n", du);
END:
return exit_status;
}