public static double meanVariance ( AssociativeArray2D survivalFunction ) { double meanVariance = 0 ; int m = 0 ; int n = 0 ; for ( Map . Entry < Object , AssociativeArray > entry : survivalFunction . entrySet ( ) ) { //Object ti = entry.getKey(); AssociativeArray row = entry . getValue ( ) ; Number mi = ( Number ) row . get ( "mi" ) ; n += mi . intValue ( ) ; if ( row . get ( "Sti" ) == null ) { //if censored internalData m += mi . intValue ( ) ; } } for ( Map . Entry < Object , AssociativeArray > entry : survivalFunction . entrySet ( ) ) { //Object ti = entry.getKey(); AssociativeArray row = entry . getValue ( ) ; if ( row . get ( "Sti" ) == null ) { continue ; //skip censored internalData } Number mi = ( Number ) row . get ( "mi" ) ; Number r = ( Number ) row . get ( "r" ) ; double Ar = ar ( survivalFunction , r . intValue ( ) ) ; if ( n - r . intValue ( ) > 0 ) { meanVariance += mi . intValue ( ) * ( Ar * Ar ) / ( ( n - r . intValue ( ) ) * ( n - r . intValue ( ) + 1.0 ) ) ; } } meanVariance *= m / ( m - 1.0 ) ; return meanVariance ; }
Calculates the Variance of Mean .