import static java.lang.System.out;

import java.util.*;

 

import javastat.*;

import javastat.survival.regression.*;

import static javastat.util.Argument.*;

import static javastat.util.Output.*;

import javastat.util.*;

 

/**

 *

 * <p>Example: class CoxRegression.</p>

 * <p>Data Source: Collett, D. (1994). Modelling Survival Data in Medical

 *    Research. New York: Chapman and Hall, pp. 290-291. </p>

 */

 

public class CoxRegressionExample

{

 

    public static void main(String arg[])

    {

        double[] time = {156, 1040, 59, 421, 329, 769, 365, 770, 1227, 268,

475, 1129, 464, 1206, 638, 563, 1106, 431, 855, 803,

115, 744, 477, 448, 353, 377};

        double[] censor = {1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1,

                        0, 0, 1, 0, 0, 0, 1, 0};

        double[][] covariate = { {1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1,

                             2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2},

                            {66, 38, 72, 53, 43, 59, 64, 57, 59, 74, 59,

                             53, 56, 44, 56, 55, 44, 50, 43, 39, 74, 50,

                             64, 56, 63, 58} };

        DataManager dm = new DataManager();

 

        CoxRegression testclass1 = new CoxRegression(0.05, time, censor,

                covariate[0], covariate[1]);

        double[] coefficients = testclass1.coefficients;

        double[][] variance =

{testclass1.variance[0], testclass1.variance[1]};

        double[] testStatistic = testclass1.testStatistic;

        double[] pValue = testclass1.pValue;

        double[][] confidenceInterval = {testclass1.confidenceInterval[0],

testclass1.confidenceInterval[1]};

 

        CoxRegression testclass2 = new CoxRegression();

        coefficients = testclass2.coefficients(time, censor, covariate);

        testStatistic = testclass2.testStatistic(time, censor, covariate);

        pValue = testclass2.pValue(time, censor, covariate);

        confidenceInterval = testclass2.

confidenceInterval(0.1, time, censor, covariate);

 

        Hashtable argument1 = new Hashtable();

        argument1.put(ALPHA, 0.05);

        StatisticalAnalysis testclass3 =

new CoxRegression(argument1, time, censor, covariate[0],

covariate[1]).statisticalAnalysis;

        coefficients = (double[]) testclass3.output.get(COEFFICIENTS);

        variance =

(double[][]) testclass3.output.get(COEFFICIENT_VARIANCE);

        testStatistic = (double[]) testclass3.output.get(TEST_STATISTIC);

        pValue = (double[]) testclass3.output.get(PVALUE);

        confidenceInterval = (double[][]) testclass3.output.get(

                CONFIDENCE_INTERVAL);

 

        Hashtable argument2 = new Hashtable();

        CoxRegression testclass4 = new CoxRegression(argument2, null);

        coefficients = testclass4.

coefficients(argument2, time, censor, covariate);

        testStatistic = testclass4.testStatistic(argument2, time, censor,

                                       covariate);

        pValue = testclass4.pValue(argument2, time, censor, covariate);

        argument2.put(ALPHA, 0.1);

        confidenceInterval = testclass4.

confidenceInterval(argument2, time, censor, covariate);

    }

 

}

 

Results:

The estimated coefficients based on non-null constructor   = [-0.796 , 0.147]

The variances of the parameter estimates based on non-null constructor =

 [0.401 , 0.0020]

The test statistics based on non-null constructor           = [-1.258 , 3.196]

The p-values for the test based on non-null constructor     = [0.209 , 0.0010]

The confidence interval for the first parameter based on non-null constructor  = [-2.036  0.445]

The confidence interval for the second parameter based on non-null constructor = [0.057  0.236]

 

{TEST_STATISTIC=[D@1bf216a, COEFFICIENT_VARIANCE=[[D@12ac982,

COEFFICIENTS=[D@1389e4, CONFIDENCE_INTERVAL=[[D@c20e24,

PVALUE=[D@2e7263}

 

The estimated coefficients based on null constructor        = [-0.796 , 0.147]

The test statistics based on null constructor               = [-1.258  3.196]

The p-values for the test based on null constructor         = [0.209 , 0.0010]

The confidence interval for the first parameter based on null constructor  = [-1.837 , 0.245]

The confidence interval for the second parameter based on null constructor     = [0.071  0.222]

 

{TEST_STATISTIC=[D@157f0dc, COEFFICIENT_VARIANCE=[[D@863399,

COEFFICIENTS=[D@a59698, CONFIDENCE_INTERVAL=[[D@141d683,

PVALUE=[D@16a55fa}