/// <summary> /// Creates a new Generalized Linear Regression Model. /// </summary> /// /// <param name="function">The link function to use.</param> /// <param name="coefficients">The coefficient vector.</param> /// <param name="standardErrors">The standard error vector.</param> /// public GeneralizedLinearRegression(ILinkFunction function, double[] coefficients, double[] standardErrors) { this.linkFunction = function; this.coefficients = coefficients; this.standardErrors = standardErrors; }
/// <summary> /// Creates a new Generalized Linear Regression Model. /// </summary> /// /// <param name="function">The link function to use.</param> /// public GeneralizedLinearRegression(ILinkFunction function) { this.linear = new MultipleLinearRegression(); this.linkFunction = function; this.NumberOfOutputs = 1; this.NumberOfInputs = 1; }
public static ILinkFunction Get(LinkFunctionType link) { ILinkFunction result = null; switch (link) { case LinkFunctionType.Absolute: result = new AbsoluteLinkFunction(); break; case LinkFunctionType.Cauchit: result = new CauchitLinkFunction(); break; case LinkFunctionType.Identity: result = new IdentityLinkFunction(); break; case LinkFunctionType.Inverse: result = new InverseLinkFunction(); break; case LinkFunctionType.InverseSquared: result = new InverseSquaredLinkFunction(); break; case LinkFunctionType.Logit: result = new LogitLinkFunction(); break; case LinkFunctionType.Log: result = new LogLinkFunction(); break; case LinkFunctionType.LogLog: result = new LogLogLinkFunction(); break; case LinkFunctionType.Probit: result = new ProbitLinkFunction(); break; case LinkFunctionType.Sin: result = new SinLinkFunction(); break; case LinkFunctionType.Threshold: result = new ThresholdLinkFunction(); break; } return(result); }
/// <summary> /// Constructs a <see cref="GaussianDistribution"/>. /// </summary> /// <param name="mean"> /// The mean of the distribution. Defaults to zero. /// </param> /// <param name="standardDeviation"> /// The standard deviation of the distribution. Defaults to 1.0. /// </param> /// <param name="linkFunction"> /// The link function. /// </param> /// <param name="random"> /// A random number generator for the distribution. Defaults to <see cref="Random"/>. /// </param> public GaussianDistribution([NotNull] ILinkFunction linkFunction, double mean = 0.0, double standardDeviation = 1.0, [CanBeNull] Random random = null) { Mean = mean; StandardDeviation = standardDeviation; LinkFunction = linkFunction; _random = random ?? new Random(); }
public GeneralizedLinearRegression(ILinkFunction function, double[] coefficients, double[] standardErrors) : this() { this.linkFunction = function; this.Weights = coefficients.Get(1, 0); this.StandardErrors = standardErrors; }
/// <summary> /// Creates a new Generalized Linear Regression Model. /// </summary> /// /// <param name="function">The link function to use.</param> /// <param name="inputs">The number of input variables for the model.</param> /// public GeneralizedLinearRegression(ILinkFunction function, int inputs) { this.linkFunction = function; this.coefficients = new double[inputs + 1]; this.standardErrors = new double[inputs + 1]; this.NumberOfInputs = inputs; this.NumberOfOutputs = 1; }
public GlmIrls(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> /// Creates a new GeneralizedLinearRegression that is a copy of the current instance. /// </summary> /// public object Clone() { ILinkFunction function = (ILinkFunction)linkFunction.Clone(); var regression = new GeneralizedLinearRegression(function, coefficients.Length); regression.coefficients = (double[])this.coefficients.Clone(); regression.standardErrors = (double[])this.standardErrors.Clone(); return(regression); }
/// <summary> /// Constructs a <see cref="PoissonDistribution"/>. /// </summary> /// <param name="linkFunction"> /// The link function. /// </param> /// <param name="mean"> /// A <paramref name="mean"/> value for the distribution. Defaults to 1.0. /// </param> /// <param name="random"> /// A random number generator for the distribution. Defaults to <see cref="Random"/>. /// </param> public PoissonDistribution([NotNull] ILinkFunction linkFunction, double mean = 1.0, [CanBeNull] Random random = default) { if (mean <= 0) { throw new ArgumentOutOfRangeException(nameof(mean), "Argument must be greater than zero."); } Mean = mean; _random = random ?? new Random(); LinkFunction = linkFunction; _smallSampleEnumerator = SmallSamples(); _largeSampleEnumerator = LargeSamples(); }
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; }
//--------------------------------------------- #region Constructor /// <summary> /// Creates a new Generalized Linear Regression Model. /// </summary> /// /// <param name="function">The link function to use.</param> /// <param name="inputs">The number of input variables for the model.</param> /// public GeneralizedLinearRegression(ILinkFunction function, int inputs) { this.linkFunction = function; this.coefficients = new double[inputs + 1]; this.standardErrors = new double[inputs + 1]; }
/// <summary> /// Creates a new Generalized Linear Regression Model. /// </summary> /// /// <param name="function">The link function to use.</param> /// <param name="inputs">The number of input variables for the model.</param> /// <param name="intercept">The starting intercept value. Default is 0.</param> /// public GeneralizedLinearRegression(ILinkFunction function, int inputs, double intercept) : this(function, inputs) { this.coefficients[0] = intercept; }
public GeneralizedLinearRegression(ILinkFunction function, int inputs) : this(function) { this.NumberOfInputs = inputs; }
public GeneralizedLinearRegression(ILinkFunction function, int inputs, double intercept) : this(function) { this.NumberOfInputs = inputs; this.Intercept = intercept; }