public static ILinkFunction GetLinkFunction(GlmDistributionFamily distribution) { switch (distribution) { case GlmDistributionFamily.Bernouli: case GlmDistributionFamily.Binomial: case GlmDistributionFamily.Categorical: case GlmDistributionFamily.Multinomial: return(new LogitLinkFunction()); case GlmDistributionFamily.Exponential: case GlmDistributionFamily.Gamma: return(new InverseLinkFunction()); case GlmDistributionFamily.InverseGaussian: return(new InverseSquaredLinkFunction()); case GlmDistributionFamily.Normal: return(new IdentityLinkFunction()); case GlmDistributionFamily.Poisson: return(new LogLinkFunction()); default: throw new NotImplementedException(); } }
public GlmIrls(GlmDistributionFamily distribution, double[,] A, double[] b) : base(distribution) { this.A = new SparseMatrix(A); this.b = new SparseVector(b); this.At = this.A.Transpose(); this.mStats = new Statistics.GlmStatistics(A.GetLength(1), b.Length); }
public GlmIrlsSvdNewton(GlmDistributionFamily distribution, ILinkFunction linkFunc, double[,] A, double[] b) : base(distribution, linkFunc, null, null, null) { this.A = new SparseMatrix(A); this.b = new SparseVector(b); this.At = this.A.Transpose(); this.mStats = new Statistics.GlmStatistics(A.GetLength(1), b.Length); }
public Glm(GlmDistributionFamily distribution, double[][] A, double[] b, SingleTrajectoryContinuousSolver solver) { this.solver = solver; this.mDistributionFamily = distribution; this.mLinkFunc = GetLinkFunction(distribution); this.A = A; this.b = b; this.mStats = new Statistics.GlmStatistics(A[0].Length, b.Length); }
/// <summary> /// Return the likelihood value of the fitted regression model /// </summary> /// <param name="data"></param> /// <param name="beta_hat">estimated predictor coefficient in the fitted regression model</param> /// <returns></returns> public static double GetLikelihood(GlmDistributionFamily distribution, List <RDataRecord> data, double[] beta_hat) { switch (distribution) { case GlmDistributionFamily.Normal: return(GetLikelihood_Normal(data, beta_hat)); default: throw new NotImplementedException(); } }
public Glm(GlmDistributionFamily distribution, double[,] A, double[] b, SingleTrajectoryContinuousSolver solver, int maxIters = -1) { this.solver = solver; this.mDistributionFamily = distribution; this.mLinkFunc = GetLinkFunction(distribution); this.A = new double[A.GetLength(0)][]; for (int i = 0; i < A.GetLength(0); i++) { this.A[i] = new double[A.GetLength(1)]; for (int j = 0; j < A.GetLength(1); j++) { this.A[i][j] = A[i, j]; } } this.b = b; if (maxIters > 0) { this.mMaxIters = maxIters; } this.mStats = new Statistics.GlmStatistics(A.GetLength(1), b.Length); }
public Glm(GlmDistributionFamily distribution) { this.mLinkFunc = GetLinkFunction(distribution); this.mDistributionFamily = distribution; }