// g02qf Example Program Text // C# version, NAG Copyright 2012 using System; using NagLibrary; using System.Globalization; namespace NagDotNetExamples { public class G02QFE { static string datafile = "ExampleData/g02qfe.d"; // Specify data file as a command line argument. // It defaults to the named file specified below otherwise. static void Main(String[] args) { if (args.Length == 1) { datafile = args[0]; } StartExample(); } public static void StartExample() { try { DataReader sr = new DataReader(datafile); // g02qf Example Program Text // Mark 24 Release. NAG Copyright 2012. double df; int i = 0, ifail = 0, j = 0, l = 0, m = 0, n = 0, ntau = 0; double[,] b; double[,] bl; double[,] bu; double[] tau; double[,] x; double[] y; int[] info; Console.WriteLine(" {0}", "G02QFF Example Program Results"); Console.WriteLine(""); // Skip heading in data file sr.Reset(); // Read in the problem size sr.Reset(); n = int.Parse(sr.Next()); m = int.Parse(sr.Next()); ntau = int.Parse(sr.Next()); b = new double[ntau, m]; info = new int[ntau]; bl = new double[ntau,m]; bu= new double[ntau,m]; x= new double[n,m]; y= new double[n]; tau = new double[ntau]; // Read in the data // allocate sr.Reset(); for (i = 1; i <= n; i++) { for (j = 1; j <= m; j++) { x[i - 1, j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } y[i - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // Read in the quantiles required sr.Reset(); for (j = 1; j <= ntau; j++) { tau[j - 1] = double.Parse(sr.Next(), CultureInfo.InvariantCulture); } // Allocate memory for output arrays // allocate // Call the model fitting routine ifail = -1; G02.g02qf(n, m, x, y, ntau, tau, out df, b, bl, bu, info, out ifail); if (ifail != 0) { if (ifail == 111) {for (j = 1; j <= ntau; j++) { Console.WriteLine(" {0} {1}", "Additional error information (INFO): ", info[j - 1]); } } else { goto L100; } } // Display the parameter estimates for (l = 1; l <= ntau; l++) { Console.WriteLine(" {0}{1,6:f3}", "Quantile: ", tau[l - 1]); Console.WriteLine(""); Console.WriteLine(" {0}", " Lower Parameter Upper"); Console.WriteLine(" {0}", " Limit Estimate Limit"); for (j = 1; j <= m; j++) { Console.WriteLine(" {0,3} {1,7:f3} {2,7:f3} {3,7:f3}", j, bl[l - 1, j - 1], b[l - 1, j - 1], bu[l - 1, j - 1]); } Console.WriteLine(""); Console.WriteLine(""); } L100: ; } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Exception Raised"); } } } }