public void testEapEST_and_EapSEM_D()
        {
            resultFlag = true;

            REngine.SetEnvironmentVariables();

            REngine engineObj = REngine.GetInstance();

            // Loading a library from R
            engineObj.Evaluate("library(catR)");

            // Test for item banks with different number of items

            for (int i1 = 0; i1 < numberOfItems.Length; i1++)
            {
                // Dichotomous Items
                DataFrame DichoItems = engineObj.Evaluate("DichoItems <- genDichoMatrix(items = " + numberOfItems[i1] + ")").AsDataFrame();
                engineObj.SetSymbol("DichoItems", DichoItems);

                // Adapting with the existing "CAT-Items" type (Wrapper)
                CATItems itemBank = new CATItems(DichoItems[0].Select(y => (double)y).ToArray(), DichoItems[1].Select(y => (double)y).ToArray(),
                                                 DichoItems[2].Select(y => (double)y).ToArray(), DichoItems[3].Select(y => (double)y).ToArray());

                // test for different theta values
                double[] th = CatRcs.Utils.CommonHelper.Sequence(-6, 6, length: 11);

                var stopwatch = new Stopwatch();
                stopwatch.Restart();

                for (int i2 = 0; i2 < th.Length; i2++)
                {
                    string temp = th[i2].ToString(nfi);

                    //Creation of a response pattern for theta value
                    NumericVector x_val = engineObj.Evaluate("x_val <- genPattern(" + th[i2].ToString(nfi) + ", DichoItems)").AsNumeric();

                    int[] x = x_val.Select(y => (int)y).ToArray();

                    // Call "EapEST" function from R
                    NumericVector r_eapEst = engineObj.Evaluate("result_Eap <- eapEst(DichoItems, x_val)").AsNumeric();

                    // Call "EapSEM" function from R
                    NumericVector r_eapSem = engineObj.Evaluate("result_EapSem <- eapSem(result_Eap, DichoItems, x_val)").AsNumeric();

                    stopwatch.Restart();

                    // Call "EapEST" function from CatRCS
                    double cs_eapEst = CatRLib.EapEST(itemBank, x, "");

                    // Call "EapSEM" function from CatRCS
                    double cs_eapSem = CatRLib.EapSEM(cs_eapEst, itemBank, x, "");

                    Console.WriteLine("Time: " + stopwatch.ElapsedMilliseconds);

                    if (r_eapEst[0] - cs_eapEst > testEpsilon ||
                        r_eapSem[0] - cs_eapSem > testEpsilon)
                    {
                        resultFlag = false;
                    }
                }
            }

            Assert.IsTrue(resultFlag, "Test Passed!");
        }
        public void testEapEST_and_EapSEM_P(int NumOfItems, ModelNames.Models paramModel)
        {
            resultFlag = true;

            REngine.SetEnvironmentVariables();

            REngine engineObj = REngine.GetInstance();

            // Loading a library from R
            engineObj.Evaluate("library(catR)");

            // Polytomous Items
            CharacterVector modelName = engineObj.CreateCharacterVector(new string[] { paramModel.EnumToString() });

            engineObj.SetSymbol("modelName", modelName);
            DataFrame PolyItems = engineObj.Evaluate("PolyItems <- genPolyMatrix(" + NumOfItems + ", 5, model = modelName, same.nrCat = TRUE)").AsDataFrame();

            engineObj.SetSymbol("PolyItems", PolyItems);

            // Adapting with the existing "CAT-Items" type (Wrapper)

            Console.WriteLine("*******************************************");
            Console.WriteLine("Polytomous Items, Model : " + paramModel.EnumToString());
            Console.WriteLine("*******************************************");

            CATItems itemBank = new CATItems(PolyItems[0].Length, paramModel.EnumToString(), 5);

            Tuple <CATItems.ColumnNames, int>[] cols = itemBank.GetKeys();

            for (int i = 0; i < cols.Length; i++)
            {
                itemBank.SetItemParamter(cols[i], PolyItems[i].Select(y => (double)y).ToArray());
            }

            #region "Test block for Ability Values (th)"

            double[] th = CatRcs.Utils.CommonHelper.Sequence(-6, 6, length: 11);

            for (int j = 0; j < th.Length; j++)
            {
                string temp = th[j].ToString(nfi);

                //Creation of a response pattern for theta value
                engineObj.Evaluate("set.seed(1)");
                NumericVector x_val = engineObj.Evaluate("x_val <- genPattern(" + "th = " + th[j].ToString(nfi) + ", PolyItems, " + "model = modelName)").AsNumeric();
                engineObj.SetSymbol("x_val", x_val);

                int[] x = x_val.Select(y => (int)y).ToArray();

                // Call "EapEST" function from R
                NumericVector r_eapEst = engineObj.Evaluate("result_Eap <- eapEst(PolyItems, x_val, model = modelName)").AsNumeric();

                // Call "EapEST" function from CatRCS
                double cs_eapEst = CatRLib.EapEST(itemBank, x, paramModel.EnumToString());


                /* EapEst function, line 111 needs to be optimized for passing the Test
                 * Check EapSEM function too !! */

                // Call "EapSEM" function from R
                NumericVector r_eapSem = engineObj.Evaluate("result_EapSem <- eapSem(result_Eap, PolyItems, x_val, model = modelName)").AsNumeric();

                // Call "EapSEM" function from CatRCS
                double cs_eapSem = CatRLib.EapSEM(cs_eapEst, itemBank, x, paramModel.EnumToString());

                if (r_eapEst[0] - cs_eapEst > testEpsilon ||
                    r_eapSem[0] - cs_eapSem > testEpsilon)
                {
                    resultFlag = false;
                }
            }

            Assert.IsTrue(resultFlag);

            #endregion
        }