Example: Mortality of beetles.

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
Covariate(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


import java.io.*;
import com.imsl.stat.*;
import com.imsl.math.*; 

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());
    }
}

Output

MODEL3
    Coefficient Statistics
      0       1       2     3  
0  -60.757  5.188  -11.712  0  
1   34.299  2.916   11.761  0  

Log likelihood -18.77817904233396
Asymptotic Coefficient Covariance
      0        1     
0   26.912  -15.124  
1             8.505  

             Case Analysis
     0      1       2      3      4     
0  0.058   2.593  1.792  0.267   1.448  
1  0.164   3.139  2.871  0.347   1.093  
2  0.363  -4.498  3.786  0.311  -1.188  
3  0.606  -5.952  3.656  0.232  -1.628  
4  0.795   1.89   3.202  0.269   0.59   
5  0.902  -0.195  2.288  0.238  -0.085  
6  0.956   1.743  1.619  0.198   1.077  
7  0.979   1.278  1.119  0.138   1.143  

Last Coefficient Update
   0  
0  0  
1  0  

Covariate Means
     0    
0  1.793  
1  0      

Observation Codes
   0  
0  0  
1  0  
2  0  
3  0  
4  0  
5  0  
6  0  
7  0  

Number of Missing Values 0
MODEL4
Log likelihood -18.232354574384562
    Coefficient Statistics
      0       1       2     3  
0  -34.944  2.641  -13.231  0  
1   19.737  1.485   13.289  0  

Link to Java source.