< Depends how much time you want to spend programming, how many values you want to draw, and how fast your computer is ...> There are examples of 'efficient' Gibbs samplers for truncated multivariate normal variables on the web (try a search on 'truncated multivariate normal').
Use the search engine at CRAN (http://cran.r-project.org/) to search for Gibbs - in the MCMC package there is an example of generating a truncated (univariate) Normal which may help you get started. However...with a mean of (.5, .5) and variances of 120 and 154 you might be able to live with an approximation. Generate MVN from mu = c(0,0) Sigma=c([120, 191], [191,154]) using the mvnorm that Ben suggested. Then take absolute values (throwing away any generated pair with a 0 in the first coordinate). This is not precisely the distribution you want and maybe a bad idea for your purposes but the absolute difference between the joint CDF of what you exactly want and the joint CDF of this approximation is at most about 0.01. And bytheway Ben: go gators :) Good luck with it Bob Usual disclaimers... -----Original Message----- From: Ben Bolker [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 5:30 PM To: Juliana Garcia Cespedes Cc: [EMAIL PROTECTED] Subject: Re: [R] truncated multivariate normal Do you mean you want to generate deviates from this distribution or that you want the density function (or distribution function)? mvrnorm in package MASS (library(MASS)) will generate multivariate normal deviates. A brute-force approach would just keep picking values until you get ones in the right quadrant, although with your example (large variance, small mean) that would mean you would be wasting 3/4 of your values -- so there are probably more efficient approaches. Depends how much time you want to spend programming, how many values you want to draw, and how fast your computer is ... Ben On Tue, 30 Sep 2003, Juliana Garcia Cespedes wrote: > Please, > > I would like to know how to generate a truncated multivariate normal > distribution k - dimensional, X ~ NT(mu, Sigma), where the > elements of X to be non-negative (except the first), and the first > dimension is strictly larger than zero. > > Example: > > X ~ NT_2(mu, Sigma), > > where mu=c(0.5, 0.5) and Sigma=c([120, 191], [191,154]), with X_1>0 > and X_2>=0 > Could anybody help me? > > Thanks in advanced. > > Juliana G. Cespedes > Mestranda em Estat�stica e Experimenta��o Agron�mica > Departamento de Ci�ncias Exatas - ESALQ/USP > S�o Paulo - Brasil > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > -- 620B Bartram Hall [EMAIL PROTECTED] Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help [[alternative HTML version deleted]] ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
