Gadget
regressionline.h
Go to the documentation of this file.
1 #ifndef regressionline_h
2 #define regressionline_h
3 
4 #include "doublevector.h"
5 
7 
13 class Regression {
14 public:
18  Regression();
23  Regression(LineType ltype);
27  virtual ~Regression() {};
33  virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData) = 0;
37  void calcFit();
42  void setIntercept(double intercept) { a = intercept; };
47  void setSlope(double slope) { b = slope; };
52  void setWeights(const DoubleVector& weights);
57  int getError() { return error; };
62  double getSSE();
67  double getIntercept() { return a; };
72  double getSlope() { return b; };
77  LineType getType() const { return linetype; };
78 protected:
82  void calcSSE();
86  void calcSSEWeights();
90  void calcSlope();
94  void calcIntercept();
98  void calcSlopeIntercept();
102  int error;
110  double sse;
114  double a;
118  double b;
135 };
136 
141 class LinearRegression : public Regression {
142 public:
147  LinearRegression(LineType ltype);
157  virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
158 };
159 
165 public:
180  virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
181 };
182 
188 public:
193  WeightRegression(LineType ltype);
203  virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
204 };
205 
211 public:
226  virtual void storeVectors(const DoubleVector& modData, const DoubleVector& obsData);
227 };
228 
229 #endif
This class implements a dynamic vector of double values.
Definition: doublevector.h:11
This is the class used to fit a linear regression line to compare 2 vectors.
Definition: regressionline.h:141
virtual void storeVectors(const DoubleVector &modData, const DoubleVector &obsData)
This is the function that stores 2 vectors that will be compared using a linear regression line.
Definition: regressionline.cc:174
~LinearRegression()
This is the default LinearRegression destructor.
Definition: regressionline.h:151
LinearRegression(LineType ltype)
This is the default LinearRegression constructor.
Definition: regressionline.cc:171
This is the class used to fit a log linear regression line to compare 2 vectors.
Definition: regressionline.h:164
~LogLinearRegression()
This is the default LogLinearRegression destructor.
Definition: regressionline.h:174
LogLinearRegression(LineType ltype)
This is the default LogLinearRegression constructor.
Definition: regressionline.cc:188
virtual void storeVectors(const DoubleVector &modData, const DoubleVector &obsData)
This is the function that stores 2 vectors that will be compared using a log linear regression line.
Definition: regressionline.cc:191
This is the class used to fit a weighted log linear regression line to compare 2 vectors.
Definition: regressionline.h:210
~LogWeightRegression()
This is the default LogWeightRegression destructor.
Definition: regressionline.h:220
virtual void storeVectors(const DoubleVector &modData, const DoubleVector &obsData)
This is the function that stores 2 vectors that will be compared using a log linear regression line.
Definition: regressionline.cc:256
LogWeightRegression(LineType ltype)
This is the default LogWeightRegression constructor.
Definition: regressionline.cc:252
This is the base class used to fit a regression line to compare 2 vectors.
Definition: regressionline.h:13
void calcSSEWeights()
This function will calculate the weighted sum of squares of errors for the regession line.
Definition: regressionline.cc:84
int error
This is the flag to denote whether an error has occured.
Definition: regressionline.h:102
int getError()
This function will check to see if an error has occured.
Definition: regressionline.h:57
double sse
This is the sum of squares of errors from the regression line.
Definition: regressionline.h:110
void setWeights(const DoubleVector &weights)
This function will set the weights that can be used to fit the regression line.
Definition: regressionline.cc:24
double getSSE()
This function will return the sum of squares of errors calculated when fitting the regression line.
Definition: regressionline.cc:33
double b
This is the slope of the regression line.
Definition: regressionline.h:118
void calcIntercept()
This function will calculate the intercept of the regession line.
Definition: regressionline.cc:120
Regression()
This is the default Regression constructor.
Definition: regressionline.cc:10
DoubleVector w
This is the DoubleVector of weights that can be used to fit the regression line.
Definition: regressionline.h:122
double a
This is the intercept of the regression line.
Definition: regressionline.h:114
DoubleVector x
This is the DoubleVector that will contain the the modelled data to be used to fit the regression lin...
Definition: regressionline.h:126
double getIntercept()
This function will return the intercept of the regression line.
Definition: regressionline.h:67
virtual void storeVectors(const DoubleVector &modData, const DoubleVector &obsData)=0
This is the function that stores 2 vectors that will be compared using a regression line.
void calcFit()
This is the function that fits a regression line to compare the 2 vectors that have been stored,...
Definition: regressionline.cc:39
void setIntercept(double intercept)
This function will set the intercept of the regression line.
Definition: regressionline.h:42
void calcSlope()
This function will calculate the slope of the regession line.
Definition: regressionline.cc:97
int useweights
This is the flag to denote whether the weights should be used when calculating the fit to the regress...
Definition: regressionline.h:106
void calcSSE()
This function will calculate the sum of squares of errors for the regession line.
Definition: regressionline.cc:71
void calcSlopeIntercept()
This function will calculate both the slope and the intercept of the regession line.
Definition: regressionline.cc:134
LineType getType() const
This function will return the fit type for the regression line.
Definition: regressionline.h:77
double getSlope()
This function will return the slope of the regression line.
Definition: regressionline.h:72
void setSlope(double slope)
This function will set the slope of the regression line.
Definition: regressionline.h:47
DoubleVector y
This is the DoubleVector that will contain the the observed data to be used to fit the regression lin...
Definition: regressionline.h:130
LineType linetype
This denotes what type of line fit is to be used for the regression line.
Definition: regressionline.h:134
virtual ~Regression()
This is the default Regression destructor.
Definition: regressionline.h:27
This is the class used to fit a weighted linear regression line to compare 2 vectors.
Definition: regressionline.h:187
~WeightRegression()
This is the default WeightRegression destructor.
Definition: regressionline.h:197
virtual void storeVectors(const DoubleVector &modData, const DoubleVector &obsData)
This is the function that stores 2 vectors that will be compared using a linear regression line.
Definition: regressionline.cc:241
WeightRegression(LineType ltype)
This is the default WeightRegression constructor.
Definition: regressionline.cc:237
LineType
Definition: regressionline.h:6
@ FIXED
Definition: regressionline.h:6
@ FIXEDINTERCEPT
Definition: regressionline.h:6
@ FREE
Definition: regressionline.h:6
@ FIXEDSLOPE
Definition: regressionline.h:6