[R] error in an univariate integration involving a bivariate normal CDF
Jingqin luo
luojingqin at yahoo.com
Tue Jan 10 00:28:12 CET 2017
R users,I encountered some error message when trying a univariate integration involving a bivariate normal CDF with mean MU and variance matrix Sigma. Below are my code:MU=c(1,3)
Sigma=matrix(c(1,0.5,0.5,1.5),2,2)
integrand=function(xx,y=1,MU=MU,Sigma=Sigma)
{
dnorm(xx,mean=MU[1],sd=sqrt(Sigma[1,1]))*pmvnorm(lower=c(-Inf,-Inf),upper=c(xx,y),mean=MU,sigma=Sigma)
}
integrate(integrand,y=1,MU=MU,Sigma=Sigma,lower=-Inf,upper=Inf,subdivisions=1000)gave : Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr = corr, : ‘diag(sigma)’ and ‘lower’ are of different length.The error came from the pmvnorm() part. I will appreciate any hints to this error.> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.2 (Santiago)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pbivnorm_0.6.0 ggplot2_1.0.0 pROC_1.8 copula_0.999-11
[5] mvtnorm_1.0-0 lcmix_0.3 nnls_1.4 MASS_7.3-45
[9] matrixStats_0.10.0 R.methodsS3_1.6.1 psych_1.6.9
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 munsell_0.4.2 mnormt_1.5-1 ADGofTest_0.3
[5] colorspace_1.2-4 pspline_1.0-16 lattice_0.20-29 stringr_0.6.2
[9] plyr_1.8.1 tcltk_3.3.1 tools_3.3.1 parallel_3.3.1
[13] grid_3.3.1 gtable_0.1.2 digest_0.6.4 Matrix_1.1-4
[17] reshape2_1.4 labeling_0.3 scales_0.2.4 gsl_1.9-10
[21] stats4_3.3.1 stabledist_0.6-6 foreign_0.8-66 proto_0.3-10
[[alternative HTML version deleted]]
More information about the R-help
mailing list