regressionWithoutIntercept.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_REGRESSIONWITHOUTINTERCEPT_HPP
2 #define JULIAN_REGRESSIONWITHOUTINTERCEPT_HPP
3 
5 #include <iostream>
6 #include <vector>
7 #include <string>
8 #include <gsl/gsl_fit.h>
9 
10 namespace julian {
11 
29  class RegressionWithoutIntercept : public DeeplyCopyableRegression<RegressionWithoutIntercept> {
30  public:
31  RegressionWithoutIntercept(): chi_sq_(0.0), cov00_(0.0), cov01_(0.0), cov11_(0.0), c1_(0.0) {};
32 
33  void estimate(const std::vector<double>& x,const std::vector<double>& y);
34  void estimate(const std::vector<double>& x,const std::vector<double>& y,const std::vector<double>& w);
35 
36  std::vector<double> getCoefficient() const;
37  double operator()(double) const;
38 
39  friend std::ostream& operator<<(std::ostream& s, julian::RegressionWithoutIntercept& r);
40 
41  private:
42  double chi_sq_;
43  double cov00_;
44  double cov01_;
45  double cov11_;
46  double c1_;
47  };
48 } // namespace julian
49 
50 #endif
Definition: cadHoliday.cpp:3
friend std::ostream & operator<<(std::ostream &s, julian::RegressionWithoutIntercept &r)
Overloads stream operator.
Definition: regressionWithoutIntercept.cpp:36
Class implements simple linear regression without intercept.
Definition: regressionWithoutIntercept.hpp:29
double cov11_
Variance of the intercept estimate.
Definition: regressionWithoutIntercept.hpp:45
void estimate(const std::vector< double > &x, const std::vector< double > &y)
estimates the slope parameters (intercept = 0) basing on provided data
Definition: regressionWithoutIntercept.cpp:15
double operator()(double) const
evaluates the linear regression model for x
Definition: regressionWithoutIntercept.cpp:8
double cov00_
Variance of the slope estimate.
Definition: regressionWithoutIntercept.hpp:43
double c1_
Slope of linear regression.
Definition: regressionWithoutIntercept.hpp:46
double cov01_
Covariance of the slope/intercept estimates.
Definition: regressionWithoutIntercept.hpp:44
Class uses Curiously Recurring Template Pattern to implement polymorphic copy construction in every d...
Definition: regression.hpp:60
double chi_sq_
The sum of squares of the residuals from the best-fit line.
Definition: regressionWithoutIntercept.hpp:42
std::vector< double > getCoefficient() const
return coefficients of the regression
Definition: regressionWithoutIntercept.cpp:27
File contains interface of regressions.