1 | #ifndef theplu_yat_regression_poisson |
---|

2 | #define theplu_yat_regression_poisson |
---|

3 | |
---|

4 | // $Id: Poisson.h 3615 2017-02-06 02:31:36Z 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 "Multivariate.h" |
---|

26 | |
---|

27 | #include "yat/utility/Vector.h" |
---|

28 | |
---|

29 | namespace theplu { |
---|

30 | namespace yat { |
---|

31 | namespace regression { |
---|

32 | |
---|

33 | /** |
---|

34 | Poisson regression models count data from a poisson distribution |
---|

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

36 | \f$ is modeled as \f$ log(m) = \Beta_0 + \Beta_1 x_1 + ... + |
---|

37 | \Beta_p x_p \f$, or for a given model, \f$ \Beta \f$, and input |
---|

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

39 | \exp(\Beta'x) \f$ |
---|

40 | |
---|

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

42 | */ |
---|

43 | class Poisson : public Multivariate |
---|

44 | { |
---|

45 | public: |
---|

46 | /** |
---|

47 | \brief fit model |
---|

48 | */ |
---|

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

50 | |
---|

51 | /** |
---|

52 | \return parameters \f$ \Beta \f$ |
---|

53 | */ |
---|

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

55 | |
---|

56 | /** |
---|

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

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

59 | */ |
---|

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

61 | private: |
---|

62 | utility::Vector beta_; |
---|

63 | }; |
---|

64 | |
---|

65 | }}} |
---|

66 | |
---|

67 | #endif |
---|