double critchi (int df, double p)
/* Perlman.  arguments interchanged */
{
	double	minchisq = 0.0;
	double	maxchisq = 100.0*p;
	double	chisqval, z, y ;;
	
	if (p <= 0.0)
		return (maxchisq);
	else if (p >= 1.0)
		return (0.0);

        if (df==1) {  
         z = zprob(0.5*p) ;  
         return z*z ;
        }

        if (df==2) {  
         y = -log(p) ;       
         return 2*y ;
        }
	
	chisqval = df / sqrt (p);    /* fair first value */
	while (maxchisq - minchisq > CHI_EPSILON)
		{
		if (rtlchsq (df, chisqval) < p)
			maxchisq = chisqval;
		else
			minchisq = chisqval;
		chisqval = (maxchisq + minchisq) * 0.5;
		}
	return (chisqval);
}
Beispiel #2
0
void
publishit (char *sss, int df, double chi)
{
  double tail;
  char sshit[4];
  char ss2[MAXSTR];
  int i, n;
  char cblank, cunder;
  static int ncall = 0;

  ++ncall;
  cblank = ' ';
  cunder = '_';
  n = strlen (sss);

  strcpy (ss2, sss);
  for (i = 0; i < n; ++i)
    {
      if (ss2[i] == cblank)
        ss2[i] = cunder;
    }

  if (chisqmode)
    {
      if (ncall == 1)
        printf (
            "## Anova statistics for population differences along each eigenvector:\n");
      if (ncall == 1)
        printf ("%40s %6s %9s %12s\n", "", "dof", "chisq", "p-value");
      printf ("%40s %6d %9.3f", ss2, df, chi);
      tail = rtlchsq (df, chi);
      printf (" %12.6g", tail);
    }
  else
    {
      if (ncall == 1)
        printf (
            "## Anova statistics for population differences along each eigenvector:\n");
      if (ncall == 1)
        printf ("%40s %12s\n", "", "p-value");
      printf ("%40s ", ss2);
      tail = chi;
      printf (" %12.6g", tail);
    }
  strcpy (sshit, "");
  if (tail < pvhit)
    strcpy (sshit, "***");
  if (tail < pvjack)
    strcpy (sshit, "+++");
  printf (" %s", sshit);
  printf ("\n");
}