yat/regression/Poisson.h

Code
Comments
Other
Rev Date Author Line
3614 06 Feb 17 peter 1 #ifndef theplu_yat_regression_poisson
3614 06 Feb 17 peter 2 #define theplu_yat_regression_poisson
3614 06 Feb 17 peter 3
3614 06 Feb 17 peter 4 // $Id$
3614 06 Feb 17 peter 5
3614 06 Feb 17 peter 6 /*
4207 26 Aug 22 peter 7   Copyright (C) 2017, 2022 Peter Johansson
3614 06 Feb 17 peter 8
3614 06 Feb 17 peter 9   This file is part of the yat library, http://dev.thep.lu.se/yat
3614 06 Feb 17 peter 10
3614 06 Feb 17 peter 11   The yat library is free software; you can redistribute it and/or
3614 06 Feb 17 peter 12   modify it under the terms of the GNU General Public License as
3614 06 Feb 17 peter 13   published by the Free Software Foundation; either version 3 of the
3614 06 Feb 17 peter 14   License, or (at your option) any later version.
3614 06 Feb 17 peter 15
3614 06 Feb 17 peter 16   The yat library is distributed in the hope that it will be useful,
3614 06 Feb 17 peter 17   but WITHOUT ANY WARRANTY; without even the implied warranty of
3614 06 Feb 17 peter 18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3614 06 Feb 17 peter 19   General Public License for more details.
3614 06 Feb 17 peter 20
3614 06 Feb 17 peter 21   You should have received a copy of the GNU General Public License
3614 06 Feb 17 peter 22   along with yat. If not, see <http://www.gnu.org/licenses/>.
3614 06 Feb 17 peter 23 */
3614 06 Feb 17 peter 24
3614 06 Feb 17 peter 25 #include "Multivariate.h"
3614 06 Feb 17 peter 26
3658 13 Jul 17 peter 27 #include "yat/utility/Matrix.h"
3615 06 Feb 17 peter 28 #include "yat/utility/Vector.h"
3615 06 Feb 17 peter 29
3614 06 Feb 17 peter 30 namespace theplu {
3614 06 Feb 17 peter 31 namespace yat {
3614 06 Feb 17 peter 32 namespace regression {
3614 06 Feb 17 peter 33
3614 06 Feb 17 peter 34   /**
3614 06 Feb 17 peter 35      Poisson regression models count data from a poisson distribution
3614 06 Feb 17 peter 36      \f$ y \in Po(m(x)) \f$ in which the the expectation value, \f$ m
3617 06 Feb 17 peter 37      \f$ is modeled as \f$ log(m) = \beta_0 + \beta_1 x_1 + ... +
3617 06 Feb 17 peter 38      \beta_p x_p \f$, or for a given model, \f$ \beta \f$, and input
3617 06 Feb 17 peter 39      vector \f$ x \f$, the expectation value \f$ E(Y | x, \beta) =
3617 06 Feb 17 peter 40      \exp(\beta'x) \f$
3614 06 Feb 17 peter 41
3614 06 Feb 17 peter 42      \since new in yat 0.15
3614 06 Feb 17 peter 43    */
3614 06 Feb 17 peter 44   class Poisson : public Multivariate
3614 06 Feb 17 peter 45   {
3614 06 Feb 17 peter 46   public:
3614 06 Feb 17 peter 47     /**
3662 19 Jul 17 peter 48        \brief Covariance of fit parameters
3662 19 Jul 17 peter 49      */
3662 19 Jul 17 peter 50     const utility::Matrix& covariance(void);
3662 19 Jul 17 peter 51
3662 19 Jul 17 peter 52     /**
3614 06 Feb 17 peter 53        \brief fit model
4130 20 Jan 22 peter 54
4130 20 Jan 22 peter 55        \since New in yat 0.20
3614 06 Feb 17 peter 56      */
4130 20 Jan 22 peter 57     void fit2(const utility::MatrixBase& x, const utility::VectorBase& y);
3614 06 Feb 17 peter 58
3614 06 Feb 17 peter 59     /**
4130 20 Jan 22 peter 60        Just kept for back compatibility with yat 0.19. Exactly the
4130 20 Jan 22 peter 61        same behaviour as for fit2.
4130 20 Jan 22 peter 62      */
4130 20 Jan 22 peter 63     void fit(const utility::Matrix& X, const utility::VectorBase& y);
4130 20 Jan 22 peter 64
4130 20 Jan 22 peter 65     /**
3658 13 Jul 17 peter 66        Number of parameters equals 1 + number of columns in A.
3658 13 Jul 17 peter 67
3617 06 Feb 17 peter 68        \return parameters \f$ \beta \f$
3614 06 Feb 17 peter 69      */
3614 06 Feb 17 peter 70     const utility::Vector& fit_parameters(void) const;
3614 06 Feb 17 peter 71
3614 06 Feb 17 peter 72     /**
3614 06 Feb 17 peter 73        Predicted value given \a x. The prediction is calculated as
3614 06 Feb 17 peter 74        \f$ \exp{\beta_0 + \beta_1 x_1 +...+\beta_p x_p} \f$
3614 06 Feb 17 peter 75      */
3614 06 Feb 17 peter 76     double predict(const utility::VectorBase& x) const;
3614 06 Feb 17 peter 77   private:
3615 06 Feb 17 peter 78     utility::Vector beta_;
3658 13 Jul 17 peter 79     utility::Matrix covariance_;
3614 06 Feb 17 peter 80   };
3614 06 Feb 17 peter 81
3614 06 Feb 17 peter 82 }}}
3614 06 Feb 17 peter 83
3614 06 Feb 17 peter 84 #endif