where and correspond to dummy variables generated from classification variables in columns 5 and 6 of x
. Respectively, corresponds to column index 2, corresponds to column index 3, and corresponds to column index 4 of x
. Column 0 of x
contains the response and column 1 of x
contains the censoring code. Logging is used to print output statistics.
import com.imsl.stat.*; import com.imsl.math.PrintMatrix; import java.util.logging.*; public class ProportionalHazardsEx1 { public static void main(String args[]) throws Exception{ double[][] x = { {411, 0, 7, 64, 5, 1, 0}, {126, 0, 6, 63, 9, 1, 0}, {118, 0, 7, 65, 11, 1, 0}, { 92, 0, 4, 69, 10, 1, 0}, { 8, 0, 4, 63, 58, 1, 0}, { 25, 1, 7, 48, 9, 1, 0}, { 11, 0, 7, 48, 11, 1, 0}, { 54, 0, 8, 63, 4, 2, 0}, {153, 0, 6, 63, 14, 2, 0}, { 16, 0, 3, 53, 4, 2, 0}, { 56, 0, 8, 43, 12, 2, 0}, { 21, 0, 4, 55, 2, 2, 0}, {287, 0, 6, 66, 25, 2, 0}, { 10, 0, 4, 67, 23, 2, 0}, { 8, 0, 2, 61, 19, 3, 0}, { 12, 0, 5, 63, 4, 3, 0}, {177, 0, 5, 66, 16, 4, 0}, { 12, 0, 4, 68, 12, 4, 0}, {200, 0, 8, 41, 12, 4, 0}, {250, 0, 7, 53, 8, 4, 0}, {100, 0, 6, 37, 13, 4, 0}, {999, 0, 9, 54, 12, 1, 1}, {231, 1, 5, 52, 8, 1, 1}, {991, 0, 7, 50, 7, 1, 1}, { 1, 0, 2, 65, 21, 1, 1}, {201, 0, 8, 52, 28, 1, 1}, { 44, 0, 6, 70, 13, 1, 1}, { 15, 0, 5, 40, 13, 1, 1}, {103, 1, 7, 36, 22, 2, 1}, { 2, 0, 4, 44, 36, 2, 1}, { 20, 0, 3, 54, 9, 2, 1}, { 51, 0, 3, 59, 87, 2, 1}, { 18, 0, 4, 69, 5, 3, 1}, { 90, 0, 6, 50, 22, 3, 1}, { 84, 0, 8, 62, 4, 3, 1}, {164, 0, 7, 68, 15, 4, 1}, { 19, 0, 3, 39, 4, 4, 1}, { 43, 0, 6, 49, 11, 4, 1}, {340, 0, 8, 64, 10, 4, 1}, {231, 0, 7, 67, 18, 4, 1} }; int indef[] = {2, 3, 4, 5, 6}; int nvef[] = {1, 1, 1, 1, 1}; int indcl[] = {5, 6}; int maxcl = 6, icen = 1; double ratio = 10000.0; ProportionalHazards ph = new ProportionalHazards(x, nvef, indef); ph.setMaxClass(maxcl); ph.setCensorColumn(icen); ph.setClassVarColumns(indcl); ph.setStratumRatio(ratio); // Level.FINER prints most output statistics Logger logger = ph.getLogger(); ConsoleHandler ch = new ConsoleHandler(); // Set ConsoleHandler Level to ALL ch.setLevel(Level.ALL); logger.setLevel(Level.FINER); logger.addHandler(ch); ch.setFormatter(new com.imsl.IMSLFormatter()); double coef[][] = ph.getParameterStatistics(); new PrintMatrix("\nFinal Coefficient Matrix").print(coef); } }
Initial Estimates 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 Method Iteration Step Maximum scaled Log Size coef. update likelihood Q-N 0 -102.40056551567265 Q-N 1 1.0 0.503384047154466 -91.04395077806367 Q-N 2 1.0 0.5781995573157527 -88.06808499091763 N-R 3 1.0 0.11310452893592865 -87.92233446871525 N-R 4 1.0 0.0695795111007413 -87.88778754387496 N-R 5 1.0 8.149048655014991E-4 -87.88778009939108 Log-Likelihood = -87.888 Coefficient Statistics Coefficient Std. error Asymptotic z-stat Asymptotic p-value 0 -0.5846 0.1368 -4.2721 0 1 -0.0131 0.0206 -0.6342 0.526 2 0.0008 0.0118 0.0645 0.9486 3 -0.367 0.4848 -0.7572 0.449 4 -0.0077 0.5068 -0.0152 0.9878 5 1.1129 0.6331 1.758 0.0787 6 0.3797 0.4058 0.9357 0.3494 Asymptotic Coefficient Covariance 0 1 2 3 4 5 6 0 0.0187 0.0003 0.0003 0.0057 0.0097 0.0043 0.0021 1 0.0004 -0 -0.0017 -0.0008 -0.0031 -0.0029 2 0.0001 0.0008 -0.0018 0.0006 0.0017 3 0.235 0.098 0.1184 0.0373 4 0.2568 0.1253 -0.0194 5 0.4008 0.0629 6 0.1647 Case Analysis Survival Prob. Influence Residual Cumulative hazard Prop. constant 0 0.0022 0.0414 2.0531 6.1032 0.3364 1 0.2988 0.1088 0.7409 1.2078 0.6134 2 0.3424 0.1184 0.3576 1.0719 0.3336 3 0.4336 0.1554 1.5272 0.8357 1.8274 4 0.9555 0.5567 0.0933 0.0455 2.0499 5 0.7365 ? 0.1272 0.3058 0.4158 6 0.9204 0.3729 0.0346 0.083 0.4164 7 0.5876 0.2637 0.1446 0.5317 0.2719 8 0.2577 0.1173 1.196 1.3561 0.882 9 0.8457 0.1486 0.9656 0.1676 5.7608 10 0.5481 0.3133 0.2135 0.6012 0.3551 11 0.7365 0.2108 0.9551 0.3058 3.1232 12 0.0293 0.0602 3.018 3.5289 0.8552 13 0.9382 0.0935 0.173 0.0638 2.7135 14 0.9555 0.1595 1.3142 0.0455 28.8855 15 0.8854 0.2322 0.5864 0.1217 4.8164 16 0.1814 0.0918 2.6217 1.707 1.5358 17 0.8854 0.1869 0.3258 0.1217 2.6765 18 0.1414 0.2303 0.7187 1.9565 0.3673 19 0.0522 0.0943 1.6591 2.9529 0.5618 20 0.3899 0.2212 1.1745 0.9419 1.2469 21 0 0 1.7281 21.1049 0.0819 22 0.0806 ? 2.1865 2.5177 0.8684 23 0.0001 0.0049 2.4603 8.8921 0.2767 24 0.9892 0.3072 0.0462 0.0108 4.2758 25 0.1074 0.1724 0.3406 2.2311 0.1527 26 0.664 0.2513 0.1573 0.4095 0.3841 27 0.8655 0.2215 0.1472 0.1444 1.0196 28 0.3899 ? 0.4533 0.9419 0.4812 29 0.9781 0.2495 0.0561 0.0222 2.531 30 0.769 0.2556 1.0257 0.2627 3.9045 31 0.6291 0.3509 1.7991 0.4635 3.8817 32 0.8233 0.2598 1.0635 0.1944 5.4705 33 0.4739 0.26 1.6474 0.7468 2.2058 34 0.5104 0.3191 0.3886 0.6725 0.5779 35 0.2173 0.183 0.485 1.5267 0.3177 36 0.7979 0.2642 1.0764 0.2258 4.7675 37 0.7 0.16 0.2598 0.3567 0.7282 38 0.0094 0.2267 0.8668 4.6642 0.1858 39 0.0806 0.2045 0.8122 2.5177 0.3226 Last Coefficient Update 0 -5.835E-8 1 1.401E-9 2 -8.597E-9 3 -2.822E-7 4 -4.566E-8 5 1.256E-7 6 1.058E-8 Covariate Means 0 5.65 1 56.575 2 15.65 3 0.35 4 0.275 5 0.125 6 0.525 Distinct Values For Each Class Variable Variable 0: 1 2 3 4 Variable 1: 0 1 Stratum Numbers For Each Observation 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 Number of Missing Values = 0 Final Coefficient Matrix 0 1 2 3 0 -0.585 0.137 -4.272 0 1 -0.013 0.021 -0.634 0.526 2 0.001 0.012 0.064 0.949 3 -0.367 0.485 -0.757 0.449 4 -0.008 0.507 -0.015 0.988 5 1.113 0.633 1.758 0.079 6 0.38 0.406 0.936 0.349Link to Java source.