package com.imsl.test.example.stat;
import com.imsl.stat.*;
import com.imsl.math.*;
/**
*
* Fits a logit and probit categorical model to beetle mortality
* data.
*
* The first example is from Prentice (1976) and involves the mortality of
* beetles after exposure to various concentrations of carbon disulphide. Both a
* logit and a probit fit are produced for linear model \(\mu + \beta x\). The
* data is given as
*
*
* Concentration (x) | N | y |
* 1.690 | 59 | 6 |
* 1.724 | 60 | 13 |
* 1.755 | 62 | 18 |
* 1.784 | 56 | 28 |
* 1.811 | 63 | 52 |
* 1.836 | 59 | 53 |
* 1.861 | 62 | 61 |
* 1.883 | 60 | 60 |
*
*
*
* @see Code
* @see Output
*/
public class CategoricalGenLinModelEx1 {
public static void main(String argv[]) throws Exception {
// Set up a PrintMatrix object for later use.
PrintMatrixFormat mf;
PrintMatrix p;
p = new PrintMatrix();
mf = new PrintMatrixFormat();
mf.setNoRowLabels();
mf.setNoColumnLabels();
double[][] x = {
{1.690, 59.0, 6.0},
{1.724, 60.0, 13.0},
{1.755, 62.0, 18.0},
{1.784, 56.0, 28.0},
{1.811, 63.0, 52.0},
{1.836, 59.0, 53.0},
{1.861, 62.0, 61.0},
{1.883, 60.0, 60.0}
};
CategoricalGenLinModel CATGLM3, CATGLM4;
// MODEL3
CATGLM3 = new CategoricalGenLinModel(x, CategoricalGenLinModel.MODEL3);
CATGLM3.setLowerEndpointColumn(2);
CATGLM3.setOptionalDistributionParameterColumn(1);
CATGLM3.setInfiniteEstimateMethod(1);
CATGLM3.setModelIntercept(1);
int[] nvef = {1};
int[] indef = {0};
CATGLM3.setEffects(indef, nvef);
CATGLM3.setUpperBound(1);
System.out.println("MODEL3");
p.setTitle("Coefficient Statistics");
p.print(CATGLM3.solve());
System.out.println("Log likelihood " + CATGLM3.getOptimizedCriterion());
p.setTitle("Asymptotic Coefficient Covariance");
p.setMatrixType(1);
p.print(CATGLM3.getCovarianceMatrix());
p.setMatrixType(0);
p.setTitle("Case Analysis");
p.print(CATGLM3.getCaseAnalysis());
p.setTitle("Last Coefficient Update");
p.print(CATGLM3.getLastParameterUpdates());
p.setTitle("Covariate Means");
p.print(CATGLM3.getDesignVariableMeans());
p.setTitle("Observation Codes");
p.print(CATGLM3.getExtendedLikelihoodObservations());
System.out.println("Number of Missing Values "
+ CATGLM3.getNRowsMissing());
// MODEL4
CATGLM4 = new CategoricalGenLinModel(x, CategoricalGenLinModel.MODEL4);
CATGLM4.setLowerEndpointColumn(2);
CATGLM4.setOptionalDistributionParameterColumn(1);
CATGLM4.setInfiniteEstimateMethod(1);
CATGLM4.setModelIntercept(1);
CATGLM4.setEffects(indef, nvef);
CATGLM4.setUpperBound(1);
CATGLM4.solve();
System.out.println("MODEL4");
System.out.println("Log likelihood " + CATGLM4.getOptimizedCriterion());
p.setTitle("Coefficient Statistics");
p.print(CATGLM4.getParameters());
}
}