1 | #ifndef theplu_yat_regression_negative_binomial |
---|

2 | #define theplu_yat_regression_negative_binomial |
---|

3 | |
---|

4 | // $Id: NegativeBinomial.h 3617 2017-02-06 22:50:07Z peter $ |
---|

5 | |
---|

6 | /* |
---|

7 | Copyright (C) 2017 Peter Johansson |
---|

8 | |
---|

9 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|

10 | |
---|

11 | The yat library is free software; you can redistribute it and/or |
---|

12 | modify it under the terms of the GNU General Public License as |
---|

13 | published by the Free Software Foundation; either version 3 of the |
---|

14 | License, or (at your option) any later version. |
---|

15 | |
---|

16 | The yat library is distributed in the hope that it will be useful, |
---|

17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|

18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|

19 | General Public License for more details. |
---|

20 | |
---|

21 | You should have received a copy of the GNU General Public License |
---|

22 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|

23 | */ |
---|

24 | |
---|

25 | #include <yat/utility/Matrix.h> |
---|

26 | #include <yat/utility/Vector.h> |
---|

27 | |
---|

28 | namespace theplu { |
---|

29 | namespace yat { |
---|

30 | namespace regression { |
---|

31 | |
---|

32 | /** |
---|

33 | Models count data from a negative binomial distribution |
---|

34 | \f$ y \in NB(m(x)) \f$ in which the the expectation value, \f$ m |
---|

35 | \f$ is modeled as \f$ log(m) = \beta_0 + \beta_1 x_1 + ... + |
---|

36 | \beta_p x_p \f$, or for a given model, \f$ \beta \f$, and input |
---|

37 | vector \f$ x \f$, the expectation value \f$ E(Y | x, \beta) = |
---|

38 | \exp(\beta'x) \f$ |
---|

39 | |
---|

40 | \since new in yat 0.15 |
---|

41 | */ |
---|

42 | class NegativeBinomial |
---|

43 | { |
---|

44 | public: |
---|

45 | /** |
---|

46 | \brief fit model parameters |
---|

47 | */ |
---|

48 | void fit(const utility::Matrix& x, const utility::VectorBase& y); |
---|

49 | |
---|

50 | /** |
---|

51 | \return model parameters |
---|

52 | */ |
---|

53 | const utility::Vector& fit_parameters(void) const; |
---|

54 | |
---|

55 | /** |
---|

56 | Predicted value given \a x. The prediction is calculated as |
---|

57 | \f$ \exp{\beta_0 + \beta_1 x_1 +...+\beta_p x_p} \f$ |
---|

58 | */ |
---|

59 | double predict(const utility::VectorBase& x) const; |
---|

60 | }; |
---|

61 | |
---|

62 | }}} |
---|

63 | |
---|

64 | #endif |
---|