Skip to content

Commit

Permalink
Started work on Inverse Gaussian for alm(), #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Svetunkov committed Nov 24, 2019
1 parent 3502542 commit c002d72
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 47 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: greybox
Type: Package
Title: Toolbox for Model Building and Forecasting
Version: 0.5.7.41002
Date: 2019-11-23
Version: 0.5.7.41003
Date: 2019-11-24
Authors@R: person("Ivan", "Svetunkov", email = "ivan@svetunkov.ru", role = c("aut", "cre"),
comment="Lecturer at Centre for Marketing Analytics and Forecasting, Lancaster University, UK")
URL: https://github.com/config-i1/greybox
Expand Down
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
greybox v0.5.7 (Release data: 2019-11-23)
greybox v0.5.7 (Release data: 2019-11-24)
==============

Changes:
* plot.greybox() now also produces LOWESS lines on the scatterplots. There is a parameters that regulates this.
* A bit of tuning of plot.greybox() graphs.
* Started work on Inverse Gaussian distribution for alm().


greybox v0.5.6 (Release data: 2019-10-29)
Expand Down
45 changes: 23 additions & 22 deletions R/alm.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@
#' This is a function, similar to \link[stats]{lm}, but for the cases of several
#' non-normal distributions. These include:
#' \enumerate{
#' \item Normal distribution, \link[stats]{dnorm},
#' \item Logistic Distribution, \link[stats]{dlogis},
#' \item Laplace distribution, \link[greybox]{dlaplace},
#' \item Asymmetric Laplace distribution, \link[greybox]{dalaplace},
#' \item T-distribution, \link[stats]{dt},
#' \item S-distribution, \link[greybox]{ds},
#' \item Folded normal distribution, \link[greybox]{dfnorm},
#' \item Log normal distribution, \link[stats]{dlnorm},
#' \item Chi-Squared Distribution, \link[stats]{dchisq},
#' \item Beta distribution, \link[stats]{dbeta},
#' \item Poisson Distribution, \link[stats]{dpois},
#' \item Negative Binomial Distribution, \link[stats]{dnbinom},
#' \item Cumulative Logistic Distribution, \link[stats]{plogis},
#' \item Cumulative Normal distribution, \link[stats]{pnorm}.
#' \item \link[stats]{dnorm} - Normal distribution,
#' \item \link[stats]{dlogis} - Logistic Distribution,
#' \item \link[greybox]{dlaplace} - Laplace distribution,
#' \item \link[greybox]{dalaplace} - Asymmetric Laplace distribution,
#' \item \link[stats]{dt} - T-distribution,
#' \item \link[greybox]{ds} - S-distribution,
#' \item \link[greybox]{dfnorm} - Folded normal distribution,
#' \item \link[stats]{dlnorm} - Log normal distribution,
#' \item \link[greybox]{dbcnorm} - Box-Cox normal distribution,
#' \item \link[stats]{dchisq} - Chi-Squared Distribution,
# \item \link[statmod]{dinvgauss} - Inverse Gaussian distribution,
#' \item \link[stats]{dbeta} - Beta distribution,
#' \item \link[stats]{dpois} - Poisson Distribution,
#' \item \link[stats]{dnbinom} - Negative Binomial Distribution,
#' \item \link[stats]{plogis} - Cumulative Logistic Distribution,
#' \item \link[stats]{pnorm} - Cumulative Normal distribution.
#' }
#'
#' This function can be considered as an analogue of \link[stats]{glm}, but with the
#' focus on time series. This is why, for example, the function has \code{ar} and
#' \code{i} parameters and produces time series analysis plots with \code{plot(alm(...))}.
#'
#' This function is slower than \code{lm}, because it relies on likelihood estimation
#' of parameters, hessian calculation and matrix multiplication. So think twice when
#' using \code{distribution="dnorm"} here.
#'
#' Probably some other distributions will be added to this function at some point...
#'
#' The estimation is done using likelihood of respective distributions.
#'
#' ALM function currently does not work with factors and does not accept
#' transformations of variables in the formula. So you need to do transformations
#' separately before using the function.
#'
#' See more details and examples in the vignette "ALM":
#' \code{vignette("alm","greybox")}
#'
Expand Down Expand Up @@ -196,7 +196,7 @@
#' @export alm
alm <- function(formula, data, subset, na.action,
distribution=c("dnorm","dlogis","dlaplace","dalaplace","ds","dt",
"dfnorm","dlnorm","dchisq","dbcnorm",
"dfnorm","dlnorm","dbcnorm","dinvgauss",
"dpois","dnbinom",
"dbeta",
"plogis","pnorm"),
Expand All @@ -212,7 +212,8 @@ alm <- function(formula, data, subset, na.action,
fast <- depricator(fast, list(...));

distribution <- distribution[1];
if(all(distribution!=c("dnorm","dlogis","dlaplace","dalaplace","ds","dt","dfnorm","dlnorm","dchisq","dbcnorm",
if(all(distribution!=c("dnorm","dlogis","dlaplace","dalaplace","ds","dt","dfnorm","dlnorm",
"dchisq","dbcnorm","dinvgauss",
"dpois","dnbinom","dbeta","plogis","pnorm"))){
if(any(distribution==c("norm","fnorm","lnorm","laplace","s","chisq","logis"))){
warning(paste0("You are using the old value of the distribution parameter.\n",
Expand Down
43 changes: 21 additions & 22 deletions man/alm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c002d72

Please sign in to comment.