Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
hi guys,
 
 
 
       i have some doubts in Regression format by using Group:
 
 
   Assume:if i have  3 groups 0,1,2
 
  group 0:Represent the Whole match
 
 group1 : first expression grouping
 
 group2 : second expression grouping
 
 Please give me the By using any link or url for this
 , 


What I have tried:

C#
How to do this in my text box .
 
 
 
Please help for this

C#
Please give me the By using any link or url for this
Posted
Updated 27-Dec-16 18:31pm
Comments
OriginalGriff 23-Dec-16 7:39am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Andy Lanng 23-Dec-16 7:44am    
Sorry, but we can't answer such a vague question.
Try writing some code (or psudo code) of what you need
deepankarbhatnagar 23-Dec-16 7:51am    
Please elaborate your question what exactly you need?

1 solution

Got you
I think you need to do this in combination with SQL as well

but see this link if it helps

Multiple Regression - Free Statistics and Forecasting Software (Calculators) v.1.1.23-r7[^]

but if it doesn't then, see the code below

Have you tried Matrix logic -

C#
Matrix y = new Matrix(
    new double[,]{{745},
                  {895},
                  {442},
                  {440},
                  {1598}});

Matrix x = new Matrix(
     new double[,]{{1, 36, 66},
                 {1, 37, 68},
                 {1, 47, 64},
                 {1, 32, 53},
                 {1, 1, 101}});

Matrix b = (x.Transpose() * x).Inverse() * x.Transpose() * y;

for (int i = 0; i < b.Rows; i++)
{
  Trace.WriteLine("INFO: " + b[i, 0].ToDouble());
}


_StatConn.EvaluateNoReturn(string.Format("output <- lm({0})", equation));
object intercept = _StatConn.Evaluate("coefficients(output)['(Intercept)']");
parameters[0] = (double)intercept;
for (int i = 0; i < xColCount; i++)
{
  object parameter = _StatConn.Evaluate(string.Format("coefficients(output)['x{0}']", i));
  parameters[i + 1] = (double)parameter;
}

public void Foo(List<Sample> samples)
{
  int nAttributes = 3; // 3min, 2min, 1min
  int nSamples = samples.Count;
  double[,] tsData = new double[nSamples, nAttributes];
  double[] resultData = new double[nSamples];

  for (int i = 0; i < samples.Count; i++)
  {
    tsData[i, 0] = samples[i].Tminus1min;
    tsData[i, 1] = samples[i].Tminus2min;
    tsData[i, 2] = samples[i].Tminus3min;

    resultData[i] = samples[i].Final;
  }

  double[] weights = null;
  int fitResult = 0;
  alglib.lsfit.lsfitreport rep = new alglib.lsfit.lsfitreport();
  alglib.lsfit.lsfitlinear(resultData, tsData, nSamples, nAttributes, ref fitResult, ref weights, rep);

  Dictionary<string, double> labelsAndWeights = new Dictionary<string, double>();
  labelsAndWeights.Add("1min", weights[0]);
  labelsAndWeights.Add("2min", weights[1]);
  labelsAndWeights.Add("3min", weights[2]);
}
 
Share this answer
 
v2
Comments
Member 11183217 5-Jan-17 4:45am    
Thanks Burm . i got it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900