RE: S-plus multivariate normal distribution

From: Steve Riley Date: September 13, 2007 technical Source: mail-archive.com
Nick, Here is a snippet of code that should get you started. # # Set seed and define number of draws desired # set.seed(111) simnum <- 5 # # Define final parameter estimates from NONMEM output # theta <- c(402,-1.11,-11.2,-0.00842, 0.118) # # Define variance-covariance matrix of fixed effects estimates # varcov <- matrix(NA,length(theta),length(theta)) varcov[,1] <- c(1.34, -1.11E-01, -1.29, -1.83E-04, -1.62E-03) varcov[,2] <- c(-1.11E-01, 2.50E-01, 2.27E-02, 3.35E-05, 6.37E-04) varcov[,3] <- c(-1.29, 2.27E-02, 2.10, 8.27E-05, 1.27E-03) varcov[,4] <- c(-1.83E-04, 3.35E-05, 8.27E-05, 8.69E-07, -4.81E-06) varcov[,5] <- c(-1.62E-03, 6.37E-04, 1.27E-03, -4.81E-06, 4.00E-04) varcov <- round(varcov,8) # # Generate random draws from MVN for theta values # sim.theta <- matrix(NA, nrow = simnum, ncol = length(theta)) sim.theta[,1:length(theta)] <- rmvnorm(simnum,mean = theta, cov = varcov) Please let me know if you have other questions. Steve
Quoted reply history
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nick Holford Sent: Thursday, September 13, 2007 6:31 AM To: nmusers Subject: [NMusers] S-plus multivariate normal distribution Hi, Can someone give me some clues on how to sample from a multivariate normal distribution using S-plus? Some working code examples would be very helpful. Thanks, Nick -- Nick Holford, Dept Pharmacology & Clinical Pharmacology University of Auckland, 85 Park Rd, Private Bag 92019, Auckland, New Zealand [EMAIL PROTECTED] tel:+64(9)373-7599x86730 fax:+64(9)373-7090 www.health.auckland.ac.nz/pharmacology/staff/nholford
Sep 13, 2007 Nick Holford S-plus multivariate normal distribution
Sep 13, 2007 Steve Riley RE: S-plus multivariate normal distribution
Sep 13, 2007 Leonid Gibiansky Re: S-plus multivariate normal distribution
Sep 13, 2007 Jeffrey . a . Wald Re: S-plus multivariate normal distribution
Sep 13, 2007 Liviawati Sutjandra RE: S-plus multivariate normal distribution
Sep 14, 2007 Nick Holford Re: S-plus multivariate normal distribution