Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in vignettes: Error: make_d_fn requires the distribution to be continuous, but a discrete component was detected #36

Open
barracuda156 opened this issue Sep 15, 2024 · 0 comments

Comments

@barracuda156
Copy link

--->  Testing R-distfromq
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-distfromq/R-distfromq/work/distfromq" && /opt/local/bin/R CMD check ./distfromq_1.0.4.tar.gz --no-manual --no-build-vignettes 
* using log directory ‘/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-distfromq/R-distfromq/work/distfromq/distfromq.Rcheck’
* using R version 4.4.1 (2024-06-14)
* using platform: powerpc-apple-darwin10.0.0d2 (32-bit)
* R was compiled by
    gcc-mp-13 (MacPorts gcc13 13.3.0_0+stdlib_flag) 13.3.0
    GNU Fortran (MacPorts gcc13 13.3.0_0+stdlib_flag) 13.3.0
* running under: OS X Snow Leopard 10.6
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘distfromq/DESCRIPTION’ ... OK
* this is package ‘distfromq’ version ‘1.0.4’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘distfromq’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking ‘build’ directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking code files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking files in ‘vignettes’ ... OK
* checking examples ... NONE
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ...
  Running ‘testthat.R’
 OK
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes ... OK
* checking running R code from vignettes ...
  ‘distfromq.Rmd’ using ‘UTF-8’... failed
 ERROR
Errors in running code in vignettes:
when running code in ‘distfromq.Rmd’
  ...
+     bins = 100) + theme_bw()

> mean(sampled_values_df$x == 0)
[1] 0.1989

> d_fn_lnorm <- make_d_fn(ps = ps, qs = qs, tail_dist = "lnorm")

  When sourcing ‘distfromq.R’:
Error: make_d_fn requires the distribution to be continuous, but a discrete component was detected
Execution halted

* checking re-building of vignette outputs ... SKIPPED
* DONE

Status: 1 ERROR
See
  ‘/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-distfromq/R-distfromq/work/distfromq/distfromq.Rcheck/00check.log’
for details.

Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-distfromq/R-distfromq/work/distfromq" && /opt/local/bin/R CMD check ./distfromq_1.0.4.tar.gz --no-manual --no-build-vignettes 
Exit code: 1

> knitr::opts_chunk$set(collapse = TRUE, comment = "#>", 
+     fig.width = 8, fig.height = 8, out.width = "100%")

> library(distfromq)

> library(ggplot2)

> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union


> quantile_probs <- seq(from = 0.1, to = 0.9, by = 0.1)

> meanlog <- 4

> sdlog <- 0.5

> q_lognormal <- qlnorm(quantile_probs, meanlog = meanlog, 
+     sdlog = sdlog)

> x <- seq(from = 0, to = 400, length = 501)

> cdf_lognormal <- plnorm(x, meanlog = meanlog, sdlog = sdlog)

> p_lognormal_approx <- make_p_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "lnorm")

> cdf_lognormal_approx <- p_lognormal_approx(x)

> p_normal_approx <- make_p_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "norm")

> cdf_normal_approx <- p_normal_approx(x)

> p_cauchy_approx <- make_p_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "cauchy")

> cdf_cauchy_approx <- p_cauchy_approx(x)

> dplyr::bind_rows(data.frame(x = x, y = cdf_lognormal, 
+     dist = "Log normal"), data.frame(x = x, y = cdf_lognormal_approx, 
+     dist = "Spline ..." ... [TRUNCATED] 
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.

> d_lognormal_approx <- make_d_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "lnorm")

> d_normal_approx <- make_d_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "norm")

> d_cauchy_approx <- make_d_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "cauchy")

> pdf_lognormal <- dlnorm(x, meanlog = meanlog, sdlog = sdlog)

> pdf_lognormal_approx <- d_lognormal_approx(x)

> pdf_normal_approx <- d_normal_approx(x)

> pdf_cauchy_approx <- d_cauchy_approx(x)

> dplyr::bind_rows(data.frame(x = x, y = pdf_lognormal, 
+     dist = "Log normal"), data.frame(x = x, y = pdf_lognormal_approx, 
+     dist = "Spline ..." ... [TRUNCATED] 

> d_lognormal_approx_n_grid_1 <- make_d_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "lnorm", interior_args = list(n_grid = 1))

> pdf_lognormal_approx_n_grid_1 <- d_lognormal_approx_n_grid_1(x)

> dplyr::bind_rows(data.frame(x = x, y = pdf_lognormal_approx, 
+     dist = "Spline interpolation,\n n_grid = 20"), data.frame(x = x, 
+     y = pdf_ .... [TRUNCATED] 

> r_normal_approx <- make_r_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "norm")

> r_lognormal_approx <- make_r_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "lnorm")

> r_cauchy_approx <- make_r_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "cauchy")

> normal_approx_sample <- r_normal_approx(n = 10000)

> lognormal_approx_sample <- r_lognormal_approx(n = 10000)

> cauchy_approx_sample <- r_cauchy_approx(n = 10000)

> bind_rows(data.frame(x = normal_approx_sample, dist = "Spline interpolation,\nnormal tails"), 
+     data.frame(x = lognormal_approx_sample, dist =  .... [TRUNCATED] 

> bind_rows(data.frame(x = normal_approx_sample, dist = "Spline interpolation,\nnormal tails"), 
+     data.frame(x = lognormal_approx_sample, dist =  .... [TRUNCATED] 
Warning: Removed 243 rows containing non-finite outside the scale range
(`stat_density()`).

> ps <- seq(from = 0.01, to = 0.99, by = 0.01)

> q_normal_approx <- make_q_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "norm")

> q_lognormal_approx <- make_q_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "lnorm")

> q_cauchy_approx <- make_q_fn(ps = quantile_probs, 
+     qs = q_lognormal, tail_dist = "cauchy")

> quantiles_lognormal <- qlnorm(ps, meanlog = meanlog, 
+     sdlog = sdlog)

> quantiles_normal_approx <- q_normal_approx(ps)

> quantiles_lognormal_approx <- q_lognormal_approx(ps)

> quantiles_cauchy_approx <- q_cauchy_approx(ps)

> dplyr::bind_rows(data.frame(x = ps, y = quantiles_lognormal, 
+     dist = "Log normal"), data.frame(x = ps, y = quantiles_normal_approx, 
+     dis .... [TRUNCATED] 

> lnorm_ps <- seq(from = 0.1, to = 0.9, by = 0.1)

> lnorm_qs <- qlnorm(lnorm_ps, meanlog = 4, sdlog = 0.5)

> adj_lnorm_ps <- 0.2 + lnorm_ps * 0.8

> point_p <- 0.2

> point_q <- 0

> ps <- c(point_p, adj_lnorm_ps)

> qs <- c(point_q, lnorm_qs)

> x <- seq(from = -100, to = 400, length = 501)

> p_lognormal_approx <- make_p_fn(ps = ps, qs = qs, 
+     tail_dist = "lnorm")

> cdf_lognormal_approx <- p_lognormal_approx(x)

> data.frame(x = x, y = cdf_lognormal_approx) %>% ggplot() + 
+     geom_line(mapping = aes(x = x, y = y), size = 0.8) + geom_point(data = data.frame( .... [TRUNCATED] 

> plot_ps <- seq(from = 0, to = 0.99, by = 0.001)

> q_lognormal_approx <- make_q_fn(ps = ps, qs = qs, 
+     tail_dist = "lnorm")

> qf_lognormal_approx <- q_lognormal_approx(plot_ps)

> data.frame(x = plot_ps, y = qf_lognormal_approx) %>% 
+     ggplot() + geom_line(mapping = aes(x = x, y = y), size = 0.8) + 
+     geom_point(data = .... [TRUNCATED] 

> dplyr::bind_rows(data.frame(x = x, y = cdf_lognormal_approx, 
+     method = "CDF Estimate"), data.frame(x = qf_lognormal_approx, 
+     y = plot_ps .... [TRUNCATED] 

> r_fn <- make_r_fn(ps = ps, qs = qs, tail_dist = "lnorm")

> sampled_values_df <- data.frame(x = r_fn(10000))

> ggplot(sampled_values_df) + geom_histogram(mapping = aes(x = x), 
+     bins = 100) + theme_bw()

> mean(sampled_values_df$x == 0)
[1] 0.1989

> d_fn_lnorm <- make_d_fn(ps = ps, qs = qs, tail_dist = "lnorm")

  When sourcing ‘distfromq.R’:
Error: make_d_fn requires the distribution to be continuous, but a discrete component was detected
Execution halted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant