Skip to content

Commit 1e386ec

Browse files
authored
Merge pull request #504 from spsanderson/development
fixes pre cran submission
2 parents 01b41cf + 6a083c3 commit 1e386ec

20 files changed

+25
-25
lines changed

R/est-param-gen-pareto.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ util_generalized_pareto_param_estimate <- function(.x, .auto_gen_empirical = TRU
7474
initial_params <- c(shape1 = 1, shape2 = 1, scale = 1)
7575

7676
# Optimize to minimize the negative log-likelihood
77-
opt_result <- optim(
77+
opt_result <- stats::optim(
7878
par = initial_params,
7979
fn = genpareto_lik,
8080
data = x_term,

R/est-param-inv-pareto.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ util_inverse_pareto_param_estimate <- function(.x, .auto_gen_empirical = TRUE) {
7474
initial_params <- c(shape = 1, scale = min(x_term))
7575

7676
# Optimize to minimize the negative log-likelihood
77-
opt_result <- optim(
77+
opt_result <- stats::optim(
7878
par = initial_params,
7979
fn = neg_log_lik_invpareto,
8080
data = x_term,

R/est-param-inv-weibull.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ util_inverse_weibull_param_estimate <- function(.x, .auto_gen_empirical = TRUE)
6868
initial_params <- c(shape = 1, scale = 1)
6969

7070
# Optimize to minimize the negative log-likelihood
71-
opt_result <- optim(
71+
opt_result <- stats::optim(
7272
par = initial_params,
7373
fn = neg_log_lik,
7474
data = x_term,

R/est-param-negative-binomial.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ util_negative_binomial_param_estimate <- function(.x, .size = 1,
112112
nll_func <- function(params) {
113113
size <- params[1]
114114
mu <- params[2]
115-
-sum(dnbinom(x_term, size = size, mu = mu, log = TRUE))
115+
-sum(stats::dnbinom(x_term, size = size, mu = mu, log = TRUE))
116116
}
117117

118118
# Initial parameter guesses (you might need to adjust these based on your data)
119119
initial_params <- c(size = 1, mu = mean(x_term))
120120

121121
# Optimize using optim()
122-
optim_result <- optim(initial_params, nll_func)
122+
optim_result <- stats::optim(initial_params, nll_func)
123123

124124
# Extract estimated parameters
125125
mle_size <- optim_result$par[1]

R/est-param-zt-binom.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ util_zero_truncated_binomial_param_estimate <- function(.x, .auto_gen_empirical
7777
initial_params <- c(size = max(x_term), prob = 0.5) # Adjust based on your data
7878

7979
# Optimization using optim()
80-
optim_result <- optim(
80+
optim_result <- stats::optim(
8181
par = initial_params,
8282
fn = nll_func
8383
) |>

R/est-param-ztn-binmoial.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ util_zero_truncated_negative_binomial_param_estimate <- function(.x, .auto_gen_e
7676
initial_params <- c(size = 1, prob = 0.5) # Adjust based on your data
7777

7878
# Optimization using optim()
79-
optim_result <- optim(initial_params, nll_func) |>
79+
optim_result <- stats::optim(initial_params, nll_func) |>
8080
suppressWarnings()
8181

8282
# Extract estimated parameters

R/stats-inv-weibull-tbl.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ util_inverse_weibull_stats_tbl <- function(.data) {
6464
initial_params <- c(shape = t, scale = q)
6565

6666
# Optimize to minimize the negative log-likelihood
67-
opt_result <- optim(
67+
opt_result <- stats::optim(
6868
par = initial_params,
6969
fn = neg_log_lik,
7070
data = data_tbl$y,
@@ -78,7 +78,7 @@ util_inverse_weibull_stats_tbl <- function(.data) {
7878

7979
# Compute statistics
8080
stat_mean <- mean(actuar::rinvweibull(1e5, shape = iw_shape, scale = iw_scale))
81-
stat_median <- quantile(data_tbl$y, 0.5)
81+
stat_median <- stats::quantile(data_tbl$y, 0.5)
8282
stat_mode <- iw_scale * (1 - 1 / iw_shape)^(1 / iw_shape)
8383
stat_sd <- sqrt(var(actuar::rinvweibull(1e5, shape = iw_shape, scale = iw_scale)))
8484
stat_coef_var <- stat_sd / stat_mean

R/utils-aic-inv-weibull.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ util_inverse_weibull_aic <- function(.x) {
6161
initial_params <- c(shape = 1, scale = 1)
6262

6363
# Fit inverse Weibull distribution using optim
64-
fit_invweibull <- optim(
64+
fit_invweibull <- stats::optim(
6565
par = initial_params,
6666
fn = neg_log_lik_invweibull,
6767
data = x,

R/utils-aic-negative-binomial.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ util_negative_binomial_aic <- function(.x) {
5858

5959
# Calculate AIC
6060
k_negative_binomial <- 2 # Number of parameters for negative binomial distribution (r and prob)
61-
logLik_negative_binomial <- sum(dnbinom(x, size = r, prob = prob, log = TRUE))
61+
logLik_negative_binomial <- sum(stats::dnbinom(x, size = r, prob = prob, log = TRUE))
6262
AIC_negative_binomial <- 2 * k_negative_binomial - 2 * logLik_negative_binomial
6363

6464
# Return AIC

R/utils-aic-zt-binom.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ util_zero_truncated_binomial_aic <- function(.x) {
7777
pe <- util_zero_truncated_binomial_param_estimate(x)$parameter_tbl
7878

7979
# Fit zero-truncated binomial distribution to data
80-
fit_rztbinom <- optim(
80+
fit_rztbinom <- stats::optim(
8181
par = c(size = round(pe$size, 3), prob = round(pe$prob, 3)),
8282
fn = neg_log_lik_rztbinom,
8383
data = x

R/utils-aic-ztn-binomial.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ util_zero_truncated_negative_binomial_aic <- function(.x) {
7474
}
7575

7676
# Fit zero-truncated negative binomial distribution to data
77-
fit_rztnbinom <- optim(
77+
fit_rztnbinom <- stats::optim(
7878
par = c(size = round(pe$size, 3), prob = round(pe$prob, 3)),
7979
fn = neg_log_lik_rztnbinom,
8080
data = x

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ library(ggplot2)
5050

5151
tidy_normal()
5252
#> # A tibble: 50 × 7
53-
#> sim_number x y dx dy p q
54-
#> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
55-
#> 1 1 1 0.227 -2.97 0.000238 0.590 0.227
56-
#> 2 1 2 1.12 -2.84 0.000640 0.869 1.12
57-
#> 3 1 3 1.26 -2.71 0.00153 0.897 1.26
58-
#> 4 1 4 0.204 -2.58 0.00326 0.581 0.204
59-
#> 5 1 5 1.04 -2.44 0.00620 0.852 1.04
60-
#> 6 1 6 -0.180 -2.31 0.0106 0.429 -0.180
61-
#> 7 1 7 0.299 -2.18 0.0167 0.618 0.299
62-
#> 8 1 8 1.73 -2.04 0.0243 0.959 1.73
63-
#> 9 1 9 -0.770 -1.91 0.0338 0.221 -0.770
64-
#> 10 1 10 0.385 -1.78 0.0463 0.650 0.385
53+
#> sim_number x y dx dy p q
54+
#> <fct> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
55+
#> 1 1 1 0.991 -3.18 0.000487 0.839 0.991
56+
#> 2 1 2 -0.163 -3.05 0.00163 0.435 -0.163
57+
#> 3 1 3 2.19 -2.92 0.00454 0.986 2.19
58+
#> 4 1 4 -0.226 -2.78 0.0106 0.411 -0.226
59+
#> 5 1 5 -1.07 -2.65 0.0208 0.141 -1.07
60+
#> 6 1 6 -0.708 -2.52 0.0345 0.239 -0.708
61+
#> 7 1 7 0.343 -2.39 0.0488 0.634 0.343
62+
#> 8 1 8 0.264 -2.26 0.0600 0.604 0.264
63+
#> 9 1 9 -0.0531 -2.13 0.0667 0.479 -0.0531
64+
#> 10 1 10 0.444 -2.00 0.0705 0.671 0.444
6565
#> # ℹ 40 more rows
6666
```
6767

516 Bytes
Loading
142 Bytes
Loading
Loading
-790 Bytes
Loading

man/figures/README-plot_density-1.png

109 Bytes
Loading

man/figures/README-plot_density-2.png

244 Bytes
Loading

man/figures/README-plot_density-3.png

346 Bytes
Loading

man/figures/README-plot_density-4.png

572 Bytes
Loading

0 commit comments

Comments
 (0)