/[pspp]/pspp/src/oneway.q
ViewVC logotype

Diff of /pspp/src/oneway.q

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by jmd, Fri Apr 29 01:02:15 2005 UTC revision 1.17 by jmd, Tue May 3 08:26:22 2005 UTC
# Line 373  show_descriptives(void) Line 373  show_descriptives(void)
373        
374    int n_rows = 2 ;    int n_rows = 2 ;
375    
   
   
376    for ( v = 0 ; v < n_vars ; ++v )    for ( v = 0 ; v < n_vars ; ++v )
377      n_rows += group_proc_get (vars[v])->n_groups + 1;      n_rows += group_proc_get (vars[v])->n_groups + 1;
378    
# Line 422  show_descriptives(void) Line 420  show_descriptives(void)
420                
421        struct group_proc *gp = group_proc_get (vars[v]);        struct group_proc *gp = group_proc_get (vars[v]);
422    
       struct hsh_iterator g;  
423        struct group_statistics *gs;        struct group_statistics *gs;
424        struct group_statistics *totals = &gp->ugs;        struct group_statistics *totals = &gp->ugs;
425    
       int count = 0 ;        
426        const char *s = var_to_string(vars[v]);        const char *s = var_to_string(vars[v]);
427    
428        struct hsh_table *group_hash = gp->group_hash;        struct group_statistics **gs_array = hsh_sort(gp->group_hash);
429          int count = 0;
430    
431        tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);        tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s);
432        if ( v > 0)        if ( v > 0)
433          tab_hline(t, TAL_1, 0, n_cols - 1 , row);          tab_hline(t, TAL_1, 0, n_cols - 1 , row);
434    
435          for (count = 0 ; count < hsh_count(gp->group_hash) ; ++count)
       for (gs =  hsh_first (group_hash,&g);  
            gs != 0;  
            gs = hsh_next(group_hash,&g))  
436          {          {
437              gs = gs_array[count];
438    
439            tab_text (t, 1, row + count,            tab_text (t, 1, row + count,
440                      TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));                      TAB_LEFT | TAT_TITLE ,value_to_string(&gs->id,indep_var));
441    
# Line 471  show_descriptives(void) Line 466  show_descriptives(void)
466            tab_float(t, 8, row + count, 0,  gs->minimum, 8, 2);            tab_float(t, 8, row + count, 0,  gs->minimum, 8, 2);
467            tab_float(t, 9, row + count, 0,  gs->maximum, 8, 2);            tab_float(t, 9, row + count, 0,  gs->maximum, 8, 2);
468    
           count++ ;  
469          }          }
470    
471        tab_text (t, 1, row + count,        tab_text (t, 1, row + count,
# Line 580  show_contrast_coeffs(short *bad_contrast Line 574  show_contrast_coeffs(short *bad_contrast
574  {  {
575    int n_cols = 2 + ostensible_number_of_groups;    int n_cols = 2 + ostensible_number_of_groups;
576    int n_rows = 2 + cmd.sbc_contrast;    int n_rows = 2 + cmd.sbc_contrast;
   struct hsh_iterator g;  
577    union value *group_value;    union value *group_value;
578    int count = 0 ;          int count = 0 ;      
579      void **group_values ;
580    
581    struct tab_table *t;    struct tab_table *t;
582    
   
583    t = tab_create (n_cols,n_rows,0);    t = tab_create (n_cols,n_rows,0);
584    tab_headers (t, 2, 0, 2, 0);    tab_headers (t, 2, 0, 2, 0);
585    tab_dim (t, tab_natural_dimensions);    tab_dim (t, tab_natural_dimensions);
# Line 599  show_contrast_coeffs(short *bad_contrast Line 591  show_contrast_coeffs(short *bad_contrast
591             0, 0,             0, 0,
592             n_cols - 1, n_rows - 1);             n_cols - 1, n_rows - 1);
593    
   
594    tab_box (t,    tab_box (t,
595             -1,-1,             -1,-1,
596             TAL_0, TAL_0,             TAL_0, TAL_0,
# Line 612  show_contrast_coeffs(short *bad_contrast Line 603  show_contrast_coeffs(short *bad_contrast
603             0,0,             0,0,
604             1,1);             1,1);
605    
   
606    tab_hline(t, TAL_1, 2, n_cols - 1, 1);    tab_hline(t, TAL_1, 2, n_cols - 1, 1);
   
   
607    tab_hline(t, TAL_2, 0, n_cols - 1, 2);    tab_hline(t, TAL_2, 0, n_cols - 1, 2);
   tab_vline(t, TAL_2, 2, 0, n_rows - 1);  
608    
609      tab_vline(t, TAL_2, 2, 0, n_rows - 1);
610    
611    tab_title (t, 0, _("Contrast Coefficients"));    tab_title (t, 0, _("Contrast Coefficients"));
612    
613    tab_text (t,  0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));    tab_text (t,  0, 2, TAB_LEFT | TAT_TITLE, _("Contrast"));
614    
615    
   
616    tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,    tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE,
617                    var_to_string(indep_var));                    var_to_string(indep_var));
618    
619    for (group_value =  hsh_first (global_group_hash,&g);    group_values = hsh_sort(global_group_hash);
620         group_value != 0;    for (count = 0 ;
621         group_value = hsh_next(global_group_hash,&g))         count < hsh_count(global_group_hash) ;
622           ++count)
623      {      {
624        int i;        int i;
625          group_value = group_values[count];
626    
627        tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,        tab_text (t, count + 2, 1, TAB_CENTER | TAT_TITLE,
628                  value_to_string(group_value,indep_var));                  value_to_string(group_value, indep_var));
629    
630        for (i = 0 ; i < cmd.sbc_contrast ; ++i )        for (i = 0 ; i < cmd.sbc_contrast ; ++i )
631          {          {
   
632            tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);            tab_text(t, 1, i + 2, TAB_CENTER | TAT_PRINTF, "%d", i + 1);
633    
634            if ( bad_contrast[i] )            if ( bad_contrast[i] )
635              tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );              tab_text(t, count + 2, i + 2, TAB_RIGHT, "?" );
636            else            else
637              tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",              tab_text(t, count + 2, i + 2, TAB_RIGHT | TAT_PRINTF, "%g",
638                       subc_list_double_at(&cmd.dl_contrast[i],count)                       subc_list_double_at(&cmd.dl_contrast[i], count)
639                       );                       );
640          }          }
             
       count++ ;  
641      }      }
642      
643    tab_submit (t);    tab_submit (t);
   
644  }  }
645    
646    
# Line 715  show_contrast_tests(short *bad_contrast) Line 700  show_contrast_tests(short *bad_contrast)
700            double coef_msq = 0.0;            double coef_msq = 0.0;
701            struct group_proc *grp_data = group_proc_get (vars[v]);            struct group_proc *grp_data = group_proc_get (vars[v]);
702            struct hsh_table *group_hash = grp_data->group_hash;            struct hsh_table *group_hash = grp_data->group_hash;
           struct hsh_iterator g;  
703            struct group_statistics *gs;            struct group_statistics *gs;
704              void **group_stat_array;
705    
706            double T;            double T;
707            double std_error_contrast ;            double std_error_contrast ;
# Line 724  show_contrast_tests(short *bad_contrast) Line 709  show_contrast_tests(short *bad_contrast)
709            double sec_vneq=0.0;            double sec_vneq=0.0;
710    
711    
712            /* Note: The calculation of the degrees of freedom in the variances            /* Note: The calculation of the degrees of freedom in the
713               not  equal case is painfull!!               "variances not equal" case is painfull!!
714               The following formula may help to understand it:               The following formula may help to understand it:
715               \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}               \frac{\left(\sum_{i=1}^k{c_i^2\frac{s_i^2}{n_i}}\right)^2}
716               {               {
# Line 737  show_contrast_tests(short *bad_contrast) Line 722  show_contrast_tests(short *bad_contrast)
722    
723            double df_denominator = 0.0;            double df_denominator = 0.0;
724            double df_numerator = 0.0;            double df_numerator = 0.0;
   
             
725            if ( i == 0 )            if ( i == 0 )
726              {              {
727                tab_text (t,  1, (v * lines_per_variable) + i + 1,                tab_text (t,  1, (v * lines_per_variable) + i + 1,
# Line 761  show_contrast_tests(short *bad_contrast) Line 744  show_contrast_tests(short *bad_contrast)
744            if ( bad_contrast[i])            if ( bad_contrast[i])
745              continue;              continue;
746    
747            /* FIXME: Potential danger here.            group_stat_array = hsh_sort(group_hash);
748               We're ASSUMING THE array is in the order corresponding to the            
749               hash order. */            for (ci = 0 ; ci < hsh_count(group_hash) ;  ++ci)
           for (ci = 0, gs = hsh_first (group_hash,&g);    
                gs != 0;  
                ++ci, gs = hsh_next(group_hash,&g))  
750              {              {
751                  gs = group_stat_array[ci];
752                  
753                const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);                const double coef = subc_list_double_at(&cmd.dl_contrast[i],ci);
754                const double winv = (gs->std_dev * gs->std_dev) / gs->n;                const double winv = (gs->std_dev * gs->std_dev) / gs->n;
755    
# Line 780  show_contrast_tests(short *bad_contrast) Line 761  show_contrast_tests(short *bad_contrast)
761    
762                df_numerator += (coef * coef) * winv;                df_numerator += (coef * coef) * winv;
763                df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);                df_denominator += pow2((coef * coef) * winv) / (gs->n - 1);
   
764              }              }
765            sec_vneq = sqrt(sec_vneq);            sec_vneq = sqrt(sec_vneq);
766    

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26