Example 1

In the following example, there are two classification variables, A and B , with two and three values, respectively. Regressors for a one-way model (the default model order) are generated using the the default dummy method. The five regressors generated are A_1, A_2, B_1, B_2 and B_3.
using System;
using Imsl.Stat;
using Imsl.Math;


public class RegressorsForGLMEx1
{
    public static void Main(String[] args)
    {
        double[,] x = {
                {10.0,  5.0},
                {20.0, 15.0},
                {20.0, 10.0},
                {10.0, 10.0},
                {10.0, 15.0},
                {20.0,  5.0}
        };

        RegressorsForGLM r = new RegressorsForGLM(x, 2);
        double[,] regressors = r.GetRegressors();
        int n = r.NumberOfRegressors;
        Console.WriteLine("Number of regressors = "+n);
        Console.WriteLine();
        new PrintMatrix("Regressors").Print(regressors);
    }
}

Output

Number of regressors = 5

    Regressors
   0  1  2  3  4  
0  1  0  1  0  0  
1  0  1  0  0  1  
2  0  1  0  1  0  
3  1  0  0  1  0  
4  1  0  0  0  1  
5  0  1  1  0  0  


Link to C# source.