import javastat.regression.SelectionCriterion;

import javastat.regression.WeightedSelectionCriterion;

import javastat.util.BasicStatistics;

import javastat.util.DataManager;

 

/**

 *

 * <p>Example: class WeightedSelectionCriterion. </p>

 */

 

dm = new DataManager();

bs = new BasicStatistics();

double[][] covariate = { {0.907, 0.761, 1.108, 1.016, 1.189, 1.001, 1.231,

                     1.123, 1.042, 1.215, 0.930, 1.152, 1.138, 0.601,

                     0.696, 0.686, 1.072, 1.074, 0.934, 0.808, 1.071,

                     1.009, 1.142, 1.229, 1.175, 0.568, 0.977, 0.767,

                     1.006, 0.893, 1.152, 0.693, 1.232, 1.036, 1.125,

                     1.081, 0.868, 0.762, 1.144, 1.045, 0.797, 1.115,

                     1.070, 1.219, 0.637, 0.733, 0.715, 0.872, 0.765,

                     0.878, 0.811, 0.676, 1.045, 0.968, 0.846, 0.684,

                     0.729, 0.911, 0.808, 1.168, 0.749, 0.892, 1.002,

                     0.812, 1.230, 0.804, 0.813, 1.002, 0.696, 1.199,

                     1.030, 0.602, 0.694, 0.816, 1.037, 1.181, 0.899,

                     1.227, 1.180, 0.795, 0.990, 1.201, 0.629, 0.608,

                     0.584, 0.562, 0.535, 0.655} };

double[] response = {3.741, 2.295, 1.498, 2.881, 0.760, 3.120, 0.638,

                  1.170, 2.358, 0.606, 3.669, 1.000, 0.981, 1.192,

                  0.926, 1.590, 1.806, 1.962, 4.028, 3.148, 1.836,

                  2.845, 1.013, 0.414, 0.812, 0.374, 3.623, 1.869,

                  2.836, 3.567, 0.866, 1.369, 0.542, 2.739, 1.200,

                  1.719, 3.423, 1.634, 1.021, 2.157, 3.361, 1.390,

                  1.947, 0.962, 0.571, 2.219, 1.419, 3.519, 1.732,

                  3.206, 2.471, 1.777, 2.571, 3.952, 3.931, 1.587,

                  1.397, 3.536, 2.202, 0.756, 1.620, 3.656, 2.964,

                  3.760, 0.672, 3.677, 3.517, 3.290, 1.139, 0.727,

                  2.581, 0.923, 1.527, 3.388, 2.085, 0.966, 3.488,

                  0.754, 0.797, 2.064, 3.732, 0.586, 0.561, 0.563,

                  0.678, 0.370, 0.530, 1.900};

weightMatrix = dm.inverse(bs.covarianceAR1(response.length, 0.2, 1));

 

aic = new WeightedSelectionCriterion(weightMatrix, response, covariate).

        weightedSelectionCriterion;

gcv = new WeightedSelectionCriterion(SelectionCriterion.GCV, weightMatrix,

        response, covariate).weightedSelectionCriterion;

t = new WeightedSelectionCriterion(SelectionCriterion.T, weightMatrix,

        response, covariate).weightedSelectionCriterion;

fpe = new WeightedSelectionCriterion(SelectionCriterion.FPE, weightMatrix,

        response, covariate).weightedSelectionCriterion;

ns = new WeightedSelectionCriterion(SelectionCriterion.nS, weightMatrix,

        response, covariate).weightedSelectionCriterion;

u = new WeightedSelectionCriterion(SelectionCriterion.U, weightMatrix,

        response, covariate).weightedSelectionCriterion;

print("AIC: " + aic + " GCV: " + gcv + " T  : " + t +

     " FPE: " + fpe + " nS : " + ns + " U  : " + u);

 

criterion = new WeightedSelectionCriterion();

aic = criterion.weightedSelectionCriterion(weightMatrix, response, covariate);

gcv = criterion.weightedSelectionCriterion(SelectionCriterion.GCV, weightMatrix, response, covariate);

t = criterion.weightedSelectionCriterion(SelectionCriterion.T, weightMatrix,

        response, covariate);

fpe = criterion.weightedSelectionCriterion(SelectionCriterion.FPE, weightMatrix,

        response, covariate);

ns = criterion.weightedSelectionCriterion(SelectionCriterion.nS, weightMatrix,

        response, covariate);

u = criterion.weightedSelectionCriterion(SelectionCriterion.U, weightMatrix,

        response, covariate);

print("AIC: " + aic + " GCV: " + gcv + " T  : " + t +

     " FPE: " + fpe + " nS : " + ns + " U  : " + u);

 

wRSS = criterion.weightedRSS(weightMatrix, response, covariate);

print("Weighted Residual Sum of Squares: " + wRSS);

 

Results:

AIC: 1.545  

GCV: 1.547

T   : 1.548

FPE : 1.545

nS  : 1.543

U   : 1.547

Weighted Residual Sum of Squares: 109.890