R Under development (unstable) (2024-05-20 r86569 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("mvtnorm") > > p <- 0.8 > mean <- c(6.75044368, 0.04996326) > sigmas <- rbind( + c(0.10260550, 0.02096418), + c(0.02096418, 0.16049956) + ) > > ## qmvnorm > qmvnorm(p = p, tail = "lower.tail", mean = mean, sigma = sigmas, + interval=c(5,8))$quantile [1] 7.020033 > qmvnorm(p = p, tail = "upper.tail", mean = mean, sigma = sigmas, + interval=c(-0.5,0))$quantile [1] -0.2872104 > qmvnorm(p = p, tail = "both.tails", mean = mean, sigma = sigmas, + interval=c(5,8))$quantile [1] 7.020033 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="lower.tail",df=Inf) [1] 7.020033 7.020034 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="upper.tail",df=Inf) [1] -0.2872110 -0.2872104 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="both.tails",df=Inf) [1] 7.020032 7.160951 > > ## qmvt, shifted > qmvt(p = p, tail = "lower.tail", delta = mean, sigma = sigmas, + interval=c(5,8), df=1, type="shifted")$quantile [1] 7.214841 > qmvt(p = p, tail = "upper.tail", delta = mean, sigma = sigmas, + interval=c(-0.5,0), df=1, type="shifted")$quantile [1] -0.5240962 > qmvt(p = p, tail = "both.tails", delta = mean, sigma = sigmas, + interval=c(5,8), df=1, type="shifted")$quantile [1] 7.254319 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="lower.tail", + type="shifted",df=1) [1] 7.191328 7.236213 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="upper.tail", + type="shifted",df=1) [1] -0.5448959 -0.5014483 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="both.tails", + type="shifted",df=1) [1] 7.316609 7.736290 > > ## qmvt, Kshirsagar > sigmas <- cov2cor(sigmas) ## use unit variances > qmvt(p = p, tail = "lower.tail", delta = mean, sigma = sigmas, + interval=c(5,8), df=1, type="Kshirsagar")$quantile [1] 26.61055 > qmvt(p = p, tail = "upper.tail", delta = mean, sigma = sigmas, + interval=c(-4,0), df=1, type="Kshirsagar")$quantile [1] -1.271611 > qmvt(p = p, tail = "both.tails", delta = mean, sigma = sigmas, + interval=c(5,8), df=1, type="Kshirsagar")$quantile [1] 26.62147 > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="lower.tail", + type="Kshirsagar",df=1) [1] 8.126826 28.026138 > ##mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="upper.tail", > ## type="Kshirsagar",df=1) # will produce warnings > mvtnorm:::getInt(p,delta=mean, sigma=sigmas,tail="both.tails", + type="Kshirsagar",df=1) [1] 9.828127 29.283805 > > proc.time() user system elapsed 0.62 0.03 0.65