import static java.lang.System.out;
import java.util.*;
import javastat.*;
import javastat.regression.glm.*;
import static javastat.util.Argument.*;
import static javastat.util.Output.*;
import javastat.util.*;
/**
*
* <p>Example: class LogisticRegression.</p>
*/
public class LogisticRegressionExample
{
public
static void main(String[] args)
{
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"};
DataManager dm = new DataManager();
LogisticRegression testclass1 = new LogisticRegression(
stringBinaryResponse,
nominalCovariate);
double[] coefficients = testclass1.coefficients;
double[][] confidenceInterval =
testclass1.confidenceInterval;
double[] testStatistic =
testclass1.testStatistic;
double[]
pValue = testclass1.pValue;
double[][] devianceTable =
testclass1.devianceTable;
LogisticRegression
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);
Hashtable argument1 = new Hashtable();
StatisticalAnalysis testclass3 = new LogisticRegression(
argument1, stringBinaryResponse,
nominalCovariate).
statisticalAnalysis;
coefficients
= (double[]) testclass3.output.get(COEFFICIENTS);
confidenceInterval = (double[][])
testclass3.output.get(
CONFIDENCE_INTERVAL);
testStatistic = (double[])
testclass3.output.get(TEST_STATISTIC);
pValue = (double[])
testclass3.output.get(PVALUE);
devianceTable =
(double[][])
testclass3.output.get(DEVIANCE_TABLE);
Hashtable argument2 = new Hashtable();
LogisticRegression testclass4 =
new LogisticRegression(argument2,
null);
coefficients = testclass4.coefficients(argument2, stringBinaryResponse,
nominalCovariate);
argument2.put(ALPHA, 0.1);
confidenceInterval =
testclass4.confidenceInterval(argument2,
stringBinaryResponse,
nominalCovariate);
testStatistic =
testclass4.testStatistic(
argument2, stringBinaryResponse,
nominalCovariate);
pValue = testclass4.
pValue(argument2, stringBinaryResponse, nominalCovariate);
devianceTable =
testclass4.devianceTable(
argument2, stringBinaryResponse,
nominalCovariate);
}
}
Results:
The
estimated coefficients based on non-null constructor
= [-1.928 , 0.259 , 0.447 , 2.436]
The
t statistics based on non-null constructor
= [-1.118 , 0.135 , 0.269 , 1.594]
The
p-values for the t statistics based on non-null constructor
= [0.263 , 0.893 , 0.788 , 0.111]
The
95% confidence interval for parameter 1 based on non-null constructor
= [-5.306 , 1.451]
The
95% confidence interval for parameter 2 based on non-null constructor
= [-3.511 , 4.029]
The
95% confidence interval for parameter 3 based on non-null constructor
= [-2.81 , 3.704]
The
95% confidence interval for parameter 4 based on non-null constructor
= [-0.56 , 5.431]
D.F. Difference
Deviance Difference
D.F.
Deviance
Null
0.0
0.0
11.0
12.482
Factor
A
2.0
0.206
9.0
12.275
Factor
A+B
1.0
3.123
8.0
9.152
{CONFIDENCE_INTERVAL=[[D@
PEARSON_RESIDUALS=[D@
TEST_STATISTIC=[D@
DEVIANCE_RESIDUALS=[D@
MEANS=[D@665753,
FITTED_VALUES=[D@ef
COEFFICIENTS=[D@1e0cf70,
RESPONSE_RESIDUALS=[D@52fe85}
The estimated
coefficients based on null constructor
= [-1.928 , 0.259 , 0.447 , 2.436]
The z statistics
based on null constructor
= [-1.118 , 0.135 , 0.269 , 1.594]
The p-values for
the t statistics based on null constructor
= [0.263 , 0.893 , 0.788 , 0.111]
The 90% confidence
interval for parameter 1 based on null constructor
= [-4.763 , 0.907]
The 90% confidence
interval for parameter 2 based on null constructor
= [-2.905 , 3.423]
The 90% confidence
interval for parameter 3 based on null constructor
= [-2.286 , 3.18]
The 90% confidence
interval for parameter 4 based on null constructor
= [-0.078 , 4.95]
D.F. Difference Deviance Difference D.F.
Deviance
Null
0.0
0.0
11.0
12.482
Factor
A
2.0
0.206
9.0
12.275
Factor
A+B
1.0
3.123
8.0
9.152