You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An example that demonstrates functionality that I think should work is:
test_that(
"rprimarycensoreddist is consistent with dprimarycensoreddist and pprimarycensoreddist when D is not cleanly divided by swindow",
{
n<-10000pwindow<-2swindow<-3D<-13rate<-0.5samples<- rpcens(
n, rexp, pwindow, swindow,
D=D,
rate=rate
)
# Check empirical mean and pmfempirical_pmf<- as.vector(table(samples) /n)
empirical_mean<- mean(samples)
empirical_sd<- sd(samples)
# Theoretical calculationsx_values<- seq(0, D, by=swindow)
pmf<- dpcens(
x_values, pexp, pwindow, swindow,
D=D,
rate=rate
)
theoretical_mean<- sum(x_values*pmf)
theoretical_sd<- sqrt(sum((x_values-theoretical_mean)^2*pmf))
# Compare means and standard deviations
expect_equal(empirical_mean, theoretical_mean, tolerance=0.1)
expect_equal(empirical_sd, theoretical_sd, tolerance=0.1)
# Compare empirical and theoretical PMFs
expect_equal(empirical_pmf, pmf, tolerance=0.1)
# Check empirical CDF against theoretical CDFempirical_cdf<- ecdf(samples)(x_values)
theoretical_cdf<- ppcens(
x_values+swindow, pexp, pwindow, D,
rate=rate
)
expect_equal(empirical_cdf, theoretical_cdf, tolerance=0.02)
# Ensure the last CDF value is close to 1
expect_equal(theoretical_cdf[length(theoretical_cdf)], 1, tolerance=1e-3)
# Check that PMF sums to approximately 1
expect_equal(sum(pmf), 1, tolerance=1e-3)
}
)
My current solution to this is to warn the user and force them to resize the offending windows. We should likely improve the warnings for this and possibly offer some functionality to do it automatically.
An example that demonstrates functionality that I think should work is:
This issue is an extension of #23
On top of the above test passing we would also need an equivalent stan test to pass
The text was updated successfully, but these errors were encountered: