简体   繁体   中英

R: Distribution Function returns “random” values

I estimated a 5 dimensional normal copula and call the pCopula function with arbitrary upper bounds. As you can see the results vary when the same function is called several times:

 library(copula)
normal.cop = normalCopula( c(0.5517099 ,0.3519115, 0.5681927, 0.4931297, 0.3733265, 0.4956172, 0.3931483, 0.4177506, 0.4112307, 0.6423421), dim=5, dispstr = "un") 

pCopula(c(0.4,0.5,0.3,0.2,0.9),normal.cop)
>0.07235714
pCopula(c(0.4,0.5,0.3,0.2,0.9),normal.cop)
>0.07233399

The function is obviously using some Monte Carlo integration methods because for identical set.seed values the results are the same:

set.seed(1)
pCopula(c(0.4,0.5,0.3,0.2,0.9),normal.cop)
>0.07234068

Where can I change the default settings of the function? I needs very reliable results and would like to set the number of iterations, error tolerance etc. manually. The function does not have any parameters to do that.

According to the documentation however the functions uses pmvnorm. There is no random component in pmvnorm and I can set iterations in pmvnorm. Is there any option to do that in pCoupla?

Thank you for asking me by e-mail (I am the maintainer of copula ). Indeed, higher dimensional integration often works via monte-carlo integration, and in this case is -- as you found -- dependent on R's .Random.seed . In the CRAN version of copula you cannot yet influence the integration algorithm of pCopula() for the normal- and t-copulas. The next version of copula -- a snapshot is available from R-forge (but not by direct installation or tarball .. these are "old") at https://r-forge.r-project.org/R/?group_id=600 -- does provide the possibility and shows some examples.

The good news is that for low dimensions, d=2,3.. possibly up to 5,6 or so, there are non-random algorithms already available [from package mvtnorm ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM