import javastat.regression.glm.LogisticRegression;
/**
*
* <p>Example: class LogisticRegression.</p>
*/
String[][]
nominalCovariate = { {"a", "a",
"b", "b", "c", "c", "a",
"a",
"b", "c", "c",
"c"},
{"T",
"T", "T", "F", "T", "F",
"T", "F",
"F", "T", "F", "F"} };
String[]
stringBinaryResponse = {"s", "d",
"s", "d", "s", "d", "d",
"s", "d", "s",
"d", "d"};
testclass1
= new LogisticRegression(stringBinaryResponse, nominalCovariate);
coefficients = testclass1.coefficients;
confidenceInterval =
testclass1.confidenceInterval;
testStatistic =
testclass1.testStatistic;
pValue = testclass1.pValue;
devianceTable =
testclass1.devianceTable;
print("The estimated coefficients (non-null constructor)
= [" +
coefficients[0]
+ " , " + coefficients[1] + " , " +
coefficients[2]
+ " , " + coefficients[3] + "]");
testclass2
= new LogisticRegression();
coefficients = testclass2.coefficients(stringBinaryResponse,
nominalCovariate);
confidenceInterval =
testclass2.confidenceInterval(0.1, stringBinaryResponse,
nominalCovariate);
testStatistic =
testclass2.testStatistic(stringBinaryResponse,
nominalCovariate);
pValue = testclass2.pValue(stringBinaryResponse,
nominalCovariate);
devianceTable =
testclass2.devianceTable(stringBinaryResponse,
nominalCovariate);
print("The z statistics (null constructor) =
["
+ testStatistic[0] + " ,
" + testStatistic[1] + " , " +
testStatistic[2] + " ,
" + testStatistic[3] + "]");
print("The p-values for the z statistics (null constructor)
= ["
+ pValue[0] + " , "
+ pValue[1] + " , " +
pValue[2] + " , "
+ pValue[3] + "]");
Results:
The
estimate for the first observation (non-null constructor) = 0.885
The
confidence interval corresponding to the first observation (non-null
constructor) = [0.762, 1.0]
The
estimate for the first observation under proportional hazards assumption
=
0.952
The
estimated coefficients (non-null constructor) = [-1.928, 0.259, 0.447 , 2.436]
The
z statistics (null constructor)
= [-1.118,
0.135, 0.269, 1.594]
The
p-values for the z statistics (null constructor) = [0.263 , 0.893, 0.788 , 0.111]