KrisLibrary  1.0.0
OLS.h
1 #ifndef STATISTICS_OLS_H
2 #define STATISTICS_OLS_H
3 
4 #include "statistics.h"
5 
6 namespace Statistics {
7 
13 {
14  public:
15  LeastSquares1D(const Vector& x,const Vector& y);
16  LeastSquares1D(const Vector& x,const Vector& y,const Vector& weights);
17  bool Solve();
18  bool SolveUnweighted();
19  bool SolveWeighted();
20  bool SolvePerpendicular();
21 
22  const Vector &x, &y;
23  const Vector* w;
24  Real a,b;
25  Real stda,stdb;
26  Real corrCoeff;
27 };
28 
29 
36 bool LeastSquares(const Matrix& data,const Vector& outcome,
37  Vector& coeffs,Real& offset);
38 
45 bool LeastSquares(const std::vector<Vector>& data,int dependentVariable,
46  Vector& coeffs);
47 
55 bool LeastSquaresPickDependent(const std::vector<Vector>& data,
56  int& dependentVariable,Vector& coeffs);
57 
58 } //namespace Statistics
59 
60 #endif
61 
bool SolveUnweighted()
ignores weights w, if defined
Definition: OLS.cpp:24
bool SolveWeighted()
weighted least-squares
Definition: OLS.cpp:57
bool LeastSquares(const Matrix &data, const Vector &outcome, Vector &coeffs, Real &offset)
Calculate a least squares fit of the outcome given data.
Definition: OLS.cpp:121
Real b
coefficients a,b
Definition: OLS.h:24
Contains all definitions in the statistics directory.
Definition: BernoulliDistribution.h:6
Basic statistical utilities.
Real stdb
standard errors for a,b
Definition: OLS.h:25
1-D least squares y = ax+b
Definition: OLS.h:12
bool SolvePerpendicular()
perpendicular least-squares
Definition: OLS.cpp:94
Real corrCoeff
correlation coefficient
Definition: OLS.h:26
bool Solve()
standard least-squares, y as fn of x
Definition: OLS.cpp:18
bool LeastSquaresPickDependent(const vector< Vector > &data, int &dependentVariable, Vector &coeffs)
Calculate a least squares fit and pick some dependent variable.
Definition: OLS.cpp:195