Skip to content

Commit 0d842a0

Browse files
committed
fix docu
1 parent cbc4b70 commit 0d842a0

File tree

2 files changed

+131
-131
lines changed

2 files changed

+131
-131
lines changed

R/families.R

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,47 @@ tfmult <- function(x,y) tf$math$multiply(x,y)
2525
#' with parameters (and corresponding inverse link function in brackets):
2626
#'
2727
#' \itemize{
28-
#' \item{\code{"normal": }}{normal distribution with location (identity), scale (exp)}
29-
#' \item{\code{"bernoulli": }}{bernoulli distribution with logits (identity)}
30-
#' \item{\code{"bernoulli_prob": }}{bernoulli distribution with probabilities (sigmoid)}
31-
#' \item{\code{"beta": }}{beta with concentration 1 = alpha (exp) and concentration
32-
#' 0 = beta (exp)}
33-
#' \item{\code{"betar": }}{beta with mean (sigmoid) and scale (sigmoid)}
34-
#' \item{\code{"cauchy": }}{location (identity), scale (exp)}
35-
#' \item{\code{"chi2": }}{cauchy with df (exp)}
36-
#' \item{\code{"chi": }}{cauchy with df (exp)}
37-
#' \item{\code{"exponential": }}{exponential with lambda (exp)}
38-
#' \item{\code{"gamma": }}{gamma with concentration (exp) and rate (exp)}
39-
#' \item{\code{"gammar": }}{gamma with location (exp) and scale (exp), following
28+
#' \item \code{"normal"} : normal distribution with location (identity), scale (exp)
29+
#' \item \code{"bernoulli"} : bernoulli distribution with logits (identity)
30+
#' \item \code{"bernoulli_prob"} : bernoulli distribution with probabilities (sigmoid)
31+
#' \item \code{"beta"} : beta with concentration 1 = alpha (exp) and concentration
32+
#' 0 = beta (exp)
33+
#' \item \code{"betar"} : beta with mean (sigmoid) and scale (sigmoid)
34+
#' \item \code{"cauchy"} : location (identity), scale (exp)
35+
#' \item \code{"chi2"} : cauchy with df (exp)
36+
#' \item \code{"chi"} : cauchy with df (exp)
37+
#' \item \code{"exponential"} : exponential with lambda (exp)
38+
#' \item \code{"gamma"} : gamma with concentration (exp) and rate (exp)
39+
#' \item \code{"gammar"} : gamma with location (exp) and scale (exp), following
4040
#' \code{gamlss.dist::GA}, which implies that the expectation is the location,
41-
#' and the variance of the distribution is the \code{location^2 scale^2}}
42-
#' \item{\code{"gumbel": }}{gumbel with location (identity), scale (exp)}
43-
#' \item{\code{"half_cauchy": }}{half cauchy with location (identity), scale (exp)}
44-
#' \item{\code{"half_normal": }}{half normal with scale (exp)}
45-
#' \item{\code{"horseshoe": }}{horseshoe with scale (exp)}
46-
#' \item{\code{"inverse_gamma": }}{inverse gamma with concentation (exp) and rate (exp)}
47-
#' \item{\code{"inverse_gamma_ls": }}{inverse gamma with location (exp) and variance (1/exp)}
48-
#' \item{\code{"inverse_gaussian": }}{inverse Gaussian with location (exp) and concentation
49-
#' (exp)}
50-
#' \item{\code{"laplace": }}{Laplace with location (identity) and scale (exp)}
51-
#' \item{\code{"log_normal": }}{Log-normal with location (identity) and scale (exp) of
52-
#' underlying normal distribution}
53-
#' \item{\code{"logistic": }}{logistic with location (identity) and scale (exp)}
54-
#' \item{\code{"negbinom": }}{neg. binomial with count (exp) and prob (sigmoid)}
55-
#' \item{\code{"negbinom_ls": }}{neg. binomail with mean (exp) and clutter factor (exp)}
56-
#' \item{\code{"pareto": }}{Pareto with concentration (exp) and scale (1/exp)}
57-
#' \item{\code{"pareto_ls": }}{Pareto location scale version with mean (exp)
41+
#' and the variance of the distribution is the \code{location^2 scale^2}
42+
#' \item \code{"gumbel"} : gumbel with location (identity), scale (exp)
43+
#' \item \code{"half_cauchy"} : half cauchy with location (identity), scale (exp)
44+
#' \item \code{"half_normal"} : half normal with scale (exp)
45+
#' \item \code{"horseshoe"} : horseshoe with scale (exp)
46+
#' \item \code{"inverse_gamma"} : inverse gamma with concentation (exp) and rate (exp)
47+
#' \item \code{"inverse_gamma_ls"} : inverse gamma with location (exp) and variance (1/exp)
48+
#' \item \code{"inverse_gaussian"} : inverse Gaussian with location (exp) and concentation
49+
#' (exp)
50+
#' \item \code{"laplace"} : Laplace with location (identity) and scale (exp)
51+
#' \item \code{"log_normal"} : Log-normal with location (identity) and scale (exp) of
52+
#' underlying normal distribution
53+
#' \item \code{"logistic"} : logistic with location (identity) and scale (exp)
54+
#' \item \code{"negbinom"} : neg. binomial with count (exp) and prob (sigmoid)
55+
#' \item \code{"negbinom_ls"} : neg. binomail with mean (exp) and clutter factor (exp)
56+
#' \item \code{"pareto"} : Pareto with concentration (exp) and scale (1/exp)
57+
#' \item \code{"pareto_ls"} : Pareto location scale version with mean (exp)
5858
#' and scale (exp), which corresponds to a Pareto distribution with parameters scale = mean
59-
#' and concentration = 1/sigma, where sigma is the scale in the pareto_ls version}
60-
#' \item{\code{"poisson": }}{poisson with rate (exp)}
61-
#' \item{\code{"poisson_lograte": }}{poisson with lograte (identity))}
62-
#' \item{\code{"student_t": }}{Student's t with df (exp)}
63-
#' \item{\code{"student_t_ls": }}{Student's t with df (exp), location (identity) and
64-
#' scale (exp)}
65-
#' \item{\code{"uniform": }}{uniform with upper and lower (both identity)}
66-
#' \item{\code{"zinb": }}{Zero-inflated negative binomial with mean (exp),
67-
#' variance (exp) and prob (sigmoid)}
68-
#' \item{\code{"zip": }}{Zero-inflated poisson distribution with mean (exp) and prob (sigmoid)}
59+
#' and concentration = 1/sigma, where sigma is the scale in the pareto_ls version
60+
#' \item \code{"poisson"} : poisson with rate (exp)
61+
#' \item \code{"poisson_lograte"} : poisson with lograte (identity))
62+
#' \item \code{"student_t"} : Student's t with df (exp)
63+
#' \item \code{"student_t_ls"} : Student's t with df (exp), location (identity) and
64+
#' scale (exp)
65+
#' \item \code{"uniform"} : uniform with upper and lower (both identity)
66+
#' \item \code{"zinb"} : Zero-inflated negative binomial with mean (exp),
67+
#' variance (exp) and prob (sigmoid)
68+
#' \item \code{"zip": } Zero-inflated poisson distribution with mean (exp) and prob (sigmoid)
6969
#' }
7070
#' @param add_const small positive constant to stabilize calculations
7171
#' @param trafo_list list of transformations for each distribution parameter.
@@ -552,59 +552,59 @@ tfd_mvr <- function(loc, scale,
552552

553553
}
554554

555-
#'
556-
#' # Implementation of a distribution-like layer for (Quasi-)Tweedie
557-
#' tfd_tweedie <- function(loc, phi, p = 1.5, quasi = FALSE,
558-
#' validate_args = FALSE,
559-
#' allow_nan_stats = TRUE,
560-
#' name = "Tweedie")
561-
#' {
562-
#'
563-
#' args <- list(
564-
#' loc = loc,
565-
#' scale = phi,
566-
#' var_power = p,
567-
#' quasi = quasi,
568-
#' validate_args = validate_args,
569-
#' allow_nan_stats = allow_nan_stats,
570-
#' name = name
571-
#' )
572-
#'
573-
#' python_path <- system.file("python", package = "deepregression")
574-
#' distributions <- reticulate::import_from_path("distributions", path = python_path)
575-
#'
576-
#' return(do.call(distributions$Tweedie, args))
577-
#'
578-
#' }
579-
#'
580-
#' #' tfd_distfun for (Quasi-)Tweedie to allow for flexible p
581-
#' #' @param p integer; defines distribution
582-
#' #' @param quasi logical; whether to use quasi-likelihood or deviance resids
583-
#' #' @param output_dim integer; currently only univariate responses supported
584-
#' #' @export
585-
#' #'
586-
#' tweedie <- function(p, quasi = FALSE, output_dim = 1L,
587-
#' linkfun_mean = function(x) tf$add(1e-8, tf$math$exp(x)),
588-
#' linkfun_phi = function(x) tf$add(1e-8, tf$math$exp(x)))
589-
#' {
590-
#'
591-
#' tfd_dist <- function(l, s) tfd_tweedie(loc = l, phi = s, p = p, quasi = quasi)
592-
#' trafo_list <- list(linkfun_mean, linkfun_phi)
593-
#' dist_dim <- 2L
594-
#' ret_fun <- function(x)
595-
#' do.call(tfd_dist,
596-
#' lapply(1:(x$shape[[2]]/output_dim),
597-
#' function(i)
598-
#' trafo_list[[i]](
599-
#' tf_stride_cols(x,(i-1L)*output_dim+1L,
600-
#' (i-1L)*output_dim+output_dim)))
601-
#' )
602-
#' attr(ret_fun, "nrparams_dist") <- 2L
603-
#'
604-
#' return(ret_fun)
605-
#'
606-
#' }
607-
#'
555+
#
556+
# # Implementation of a distribution-like layer for (Quasi-)Tweedie
557+
# tfd_tweedie <- function(loc, phi, p = 1.5, quasi = FALSE,
558+
# validate_args = FALSE,
559+
# allow_nan_stats = TRUE,
560+
# name = "Tweedie")
561+
# {
562+
#
563+
# args <- list(
564+
# loc = loc,
565+
# scale = phi,
566+
# var_power = p,
567+
# quasi = quasi,
568+
# validate_args = validate_args,
569+
# allow_nan_stats = allow_nan_stats,
570+
# name = name
571+
# )
572+
#
573+
# python_path <- system.file("python", package = "deepregression")
574+
# distributions <- reticulate::import_from_path("distributions", path = python_path)
575+
#
576+
# return(do.call(distributions$Tweedie, args))
577+
#
578+
# }
579+
#
580+
# #' tfd_distfun for (Quasi-)Tweedie to allow for flexible p
581+
# #' @param p integer; defines distribution
582+
# #' @param quasi logical; whether to use quasi-likelihood or deviance resids
583+
# #' @param output_dim integer; currently only univariate responses supported
584+
# #' @export
585+
# #'
586+
# tweedie <- function(p, quasi = FALSE, output_dim = 1L,
587+
# linkfun_mean = function(x) tf$add(1e-8, tf$math$exp(x)),
588+
# linkfun_phi = function(x) tf$add(1e-8, tf$math$exp(x)))
589+
# {
590+
#
591+
# tfd_dist <- function(l, s) tfd_tweedie(loc = l, phi = s, p = p, quasi = quasi)
592+
# trafo_list <- list(linkfun_mean, linkfun_phi)
593+
# dist_dim <- 2L
594+
# ret_fun <- function(x)
595+
# do.call(tfd_dist,
596+
# lapply(1:(x$shape[[2]]/output_dim),
597+
# function(i)
598+
# trafo_list[[i]](
599+
# tf_stride_cols(x,(i-1L)*output_dim+1L,
600+
# (i-1L)*output_dim+output_dim)))
601+
# )
602+
# attr(ret_fun, "nrparams_dist") <- 2L
603+
#
604+
# return(ret_fun)
605+
#
606+
# }
607+
#
608608

609609

610610
#' For using mean squared error via TFP

man/dr_families.Rd

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)