search for: rmnorm

Displaying 10 results from an estimated 10 matches for "rmnorm".

Did you mean: rlnorm
2011 Oct 18
1
Repeat a loop until...
...ed over the years about loops but I'm afraid that I'm still stuck. I am using Windows XP and R 2.9.2. I am generating some data using the multivariate normal distribution (within the 'mnormt' package). [The numerical values of sanad and covmat are not important.] > datamat <- rmnorm(n=1500,mean=c(mean(sanad[,1]),mean(sanad[,2]),mean(sanad[,3])),varcov=covmat) The middle column of 'datamat' is simulated data for age. Obviously some of the simulated values are not going to be sensible. Therefore I'd like to set up a function that looks at each row of 'datamat&...
2011 Feb 09
2
Generate multivariate normal data with a random correlation matrix
...an vector=0 and varcov=cormat Problem: This approach violates the triangle inequality property of correlation matrices. ?So, the matrix I've constructed is certainly a valid matrix but it is not a valid correlation matrix and it blows up when you submit it to a random number generator such as rmnorm. ?With a small matrix you sometimes get lucky and generate a valid correlation matrix but as you increase d the probability of obtaining a valid correlation matrix drops off quickly. So, any ideas on how to construct a correlation matrix with random entries that cover the range (or most of the ran...
2008 Oct 02
3
Adding plane in a 3D scatterplot
I have drawn a 3D scatter plot : library(mnormt) library(scatterplot3d) dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3) scatterplot3d(dat) Now I want to do 2 things : 1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 1,1.5,2,2.5............. 2. I want to add two Horizontal planes at hight z=2 and z=3. Those two planes should look like "bottom" of tha...
2009 Oct 14
1
using mapply to avoid loops
...]])%*%Xj[[j]])  Lambda.j <- solve(solve(V.j) + solve(TAU))%*%solve(V.j)  Beta.tilde.j <- Lambda.j%*%Beta.hat.j + (diag(P) - Lambda.j)%*%Wj[[j]]%*%GAMMA }  # Singular case else {  Beta.tilde.j <- V.tilde.j%*%((1/s2)*t(Xj[[j]])%*%Yj[[j]] + solve(TAU)%*%Wj[[j]]%*%GAMMA) } BETA.Js[[j]] <- t(rmnorm(1, mean=as.vector(Beta.tilde.j), V.tilde.j)) }       # THIS DOESN'T WORK USING MAPPLY update.betas <- function(s2,Xj,Yj,TAU,Wj,GAMMA) {  V.tilde.j <- solve((1/s2)*t(Xj[[j]])%*%Xj[[j]] + solve(TAU))  # Not singular case:  if(round(det(t(Xj[[j]])%*%Xj[[j]]),8)!=0) {   Beta.hat.j <- solve...
2010 Apr 13
0
Error using reshape method
...eplis<- 3 stdev<-c(1,2,5,10) #1st set corrmat <- matrix(1, dims, dims) corrmat[upper.tri(corrmat)]<-co selectlow <- lower.tri(corrmat) corrmat[selectlow] <- t(corrmat)[selectlow] sigma<- diag(stdev) %*% corrmat %*% diag(stdev) simu1<-rmnorm(n=ss, Sigma=sigma, mu=mu, d=dims, rho=co) simu11<-cbind(simu1,data.grp=1) #2nd set corrmat2 <- matrix(1, dims, dims) corrmat2[upper.tri(corrmat2)]<-co selectlow2 <- lower.tri(corrmat2) corrmat2[selectlow2] <- t(corrmat2)[selectlow2] sigma2&lt...
2008 Jul 22
1
scatter plot using ggplot
I used ggplot to create a scatter plot : library(ggplot) library(mnormt) Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2) x = rmnorm(20, c(0,0), Sigma) xx = x[order(x[,1]),] y = xx[,1] z = xx[,2] qplot(z, y, type="point", main="x-y plot", xlab="x", col="blue") However I want following: 1. Plot color must be Blue (where it is displaying as red) 2. There should not be any color platted 3....
2010 Jun 16
1
generating samples from multivariate distributions
Sir, I want to draw random from any multivariate disrtibution. Is there any function in R to do this? Regards, Suman Dhara [[alternative HTML version deleted]]
2011 May 05
1
matrix not positive definite (while it should be)
...17 > min(eigen(CORRELATION)$values) [1] 0.09504902 theoretically, it should be 0 for SIGMA, but here it is not the case. The problem here is that here, I cannot generate a Gaussian random vector with that specific covariance matrix, since Cholesky does not work... > library(mnormt) > RES=rmnorm(n,mean=MU,varcov=SIGMA) Error in chol.default(varcov) : the leading minor of order 4 is not positive definite any suggestions ? perhaps a better way of building my covariance matrix ? or another way of generating a random vector with that specific covariance matrix ? Thanks for your help.......
2011 Aug 11
5
generate two sets of random numbers that are correlated
Dear R users I'd like to generate two sets of random numbers with a fixed correlation coefficient, say .4, using R. Any suggestion will be greatly appreciated. Regards, Kathryn Lord -- View this message in context: http://r.789695.n4.nabble.com/generate-two-sets-of-random-numbers-that-are-correlated-tp3735695p3735695.html Sent from the R help mailing list archive at Nabble.com.
2017 Aug 17
2
How to install Tidyverse on Ubuntu 17.04? Getting gcc errors for -fstack-protector-strong and -Wdate-time
...n install.packages : installation of package ?colorspace? had non-zero exit status * installing *source* package ?psych? ... ** package ?psych? successfully unpacked and MD5 sums checked ** R ** data *** moving datasets to lazyload DB ** inst ** preparing package for lazy loading Error : objects ?rmnorm?, ?sadmvn?, ?dmnorm? are not exported by 'namespace:mnormt' ERROR: lazy loading failed for package ?psych? * removing ?/home/popx/R/x86_64-pc-linux-gnu-library/3.4/psych? Warning in install.packages : installation of package ?psych? had non-zero exit status * installing *source* package ?...