Displaying 20 results from an estimated 1000 matches similar to: "Bootstrapping a covariance matrix"
2011 Aug 30
2
Multivariate Normal: Help wanted!
I have the following function, a MSE calc based on some Multivariate normals:
MV.MSE<-function(n,EP,X,S){
(dmvnorm(X,mean=rep(0,2),I+S+EP)-dmvnorm(X,mean=rep(0,2),I+S))^2
+
1/n*(dmvnorm(X,mean=rep(0,2),1+S+EP/2)*det(4*pi*EP)^-.5-
(dmvnorm(X,mean=rep(0,2),I+S+EP ))^2)}
I can get the MV.MSE for given values of the function e.g
2012 Aug 11
3
Problem when creating matrix of values based on covariance matrix
Hi,
I want to simulate a data set with similar covariance structure as my
observed data, and have calculated a covariance matrix (dimensions
8368*8368). So far I've tried two approaches to simulating data:
rmvnorm from the mvtnorm package, and by using the Cholesky
decomposition (http://www.cerebralmastication.com/2010/09/cholesk-post-on-correlated-random-normal-generation/).
The problem is
2011 May 01
2
Question on where samples are grouped in rmvnorm{mvtnorm}
Dear All,
For function: rmvnorm{mvtnorm} in (library mvtnorm, not splus2R), if I generate 2 bivariate normal samples as follows:
> rmvnorm(2,mean=rep(0,2),sigma=diag(2))
[,1] [,2]
[1,] 2.0749459 1.4932752
[2,] -0.9886333 0.3832266
Where is the first sample, it is stored in the first row or the first column?
Does this function store samples row-wise or column-wise?
Thank
2006 Nov 30
1
data.frame within a function (PR#9294) (cont'd)
This continues the message "data.frame within a function (PR#9294)" that
was posted on 2006/10/12. Duncan Murdoch kindly replied. I'm using the
current version R 2.4.0, but the same issue exists. Just copy and paste
the following code under R, and compare the output of f1() and f2() and
the output of f3() and f4(). Does anybody have any idea? Thanks.
2007 May 26
1
Why ?rmvnorm not working
Hi,
My R version is 2.4.1 and I installed the the packages MASS and run
command library("MASS"),
however when I type ?rmvnorm, no help topic found, it worked before.
I tried to ype ?rinvgamma from "MCMCpack" which works great.
Anybody have idea? I also reinstalled MASS package, but when I try to type
rmvnorm(), no functions found.
Pat
2012 Sep 27
2
Generating an autocorrelated binary variable
Hi R-fellows,
I am trying to simulate a multivariate correlated sample via the Gaussian copula method. One variable is a binary variable, that should be autocorrelated. The autocorrelation should be rho = 0.2. Furthermore, the overall probability to get either outcome of the binary variable should be 0.5.
Below you can see the R code (I use for simplicity a diagonal matrix in rmvnorm even if it
2007 Feb 13
4
Generating MVN Data
Dear All
I want to generate multivariate normal data in R for a given covariance
matrix, i.e. my generated data must have the given covariance matrix. I
know the rmvnorm command is to be used but may be I am failing to
properly assign the covariance matrix.
Any help will be greatly appreciated
thanks.
M. R. Ahmad
2008 Oct 22
3
Help finding the proper function
This might not be the correct forum for this question for there might be some
flaws in my logic so the R function I'm looking for might not be the
correct, but I know there?s a lot of smart people in this forum so please
correct me if I'm wrong. I have been googling and searching in this forum
for something useful but so far I'm out of luck.
This is the background to my problem. I
2008 Aug 11
2
generating a random signal with a known correlation
Hi,
How can I generate a random signal that's correlated with a given signal at
a given correlation (say 0.7)?
I've been looking at rmvnorm etc but don't seem to figure it out. Thanks
-----
Yasir H. Kaheil
Columbia University
--
View this message in context: http://www.nabble.com/generating-a-random-signal-with-a-known-correlation-tp18932541p18932541.html
Sent from the R help
2013 Sep 19
2
(no subject)
Dear R sages,
I used the function rbind to combine a matrix (M) and a vector (Fert) to
get a new matrix (A). This was fine.
The issue is however, that the new matrix A has as its row names the name
of the vector Fert, even though I set teh new vector A to have
dimnames=NULL. See short code below fyi.
*Fert<-c(0,1,5)
*
*M <- matrix(0, 2, 3)
diag(M) <- c(0.3,0.5)
*
*A<-
2010 Aug 24
3
generate random numbers from a multivariate distribution with specified correlation matrix
Hi all,
rmvnorm()can be used to generate the random numbers from a multivariate
normal distribution with specified means and covariance matrix, but i want
to specify the correlation matrix instead of covariance matrix for the
multivariate
normal distribution.
Does anybody know how to generate the random numbers from a multivariate
normal distribution with specified correlation matrix? What about
2010 May 10
1
Random walk
Hi everybody,
I am trying to generate two random walks with an specific correlation,
for example, two random walks of 200 time steps with a correlation 0.7.
I built the random walks with:
x<-cumsum(rnorm(200, mean=0,sd=1))
y<-cumsum(rnorm(200, mean=0,sd=1))
but I don't know how to fix the correlation between them.
With white noise is easy to fix the correlation using the function
2010 Dec 09
1
Constraints when sampling from a distribution
Dear R-helpers,
My question is related to how to impose constraints when when sampling from a distribution.
For example, suppose I'm sampling a vector from a multivariate normal distribution
vbeta <- 100*diag(2)
mbeta <- c(1,1)
ans <- beta <- c(rmvnorm(1,mbeta,vbeta))
ans will thus be a vector with two elements.
My question is how do I place a restriction on one of the
2011 Aug 25
2
Create two uniformly random variables correlated
Hello,
I want to create two random variables (x1,x2) both with uniform distribution bounded by (-1) and (1) that has a correlation of 0.6 between them.
Does somebody know how I can do it? For normal random variables I known how to implement it with the rmvnorm command but I don't know how to do it with variables uniformly distributed.
Thanks a lot.
Alexandra
[[alternative HTML
2012 Jul 08
1
Data Simulation
Hi,
I have great difficulty in simulation the a dataset based in a loading
matrix [c(1,1,1,2,3,3,3,4,4,3,2,2,1,1), 7, 2) and an error covariance matrix
is 2*I. I have to simulate a dataset with 7 variables and 50 rows. I search
a lot and did find some information on this, for example, using rmvnorm().
But I could do it.
Please help!
--
View this message in context:
2002 Oct 02
4
T-Distribution
Dear sir,
I would ask if there are in R some code to generate a random sample
from a mvariate student distribution like that one wich generate the
multivariate normal one i mean( rmvnorm(n, mu, sigma)
Second question : if R can plot density 3Dcurve I don't mean de
histogram but de hole density function(normal for example).
I use a windows version of The R software
Thank you in advance
wiyh
2004 Jun 25
2
Simulating from a Multivariate Normal Distribution Using a Correlation Matrix
Hello,
I would like to simulate randomly from a multivariate normal distribution using a correlation
matrix, rho. I do not have sigma. I have searched the help archive and the R documentation as
well as doing a standard google search. What I have seen is that one can either use rmvnorm in
the package: mvtnorm or mvrnorm in the package: MASS. I believe I read somewhere that the latter
was
2018 Apr 12
3
Bivariate Normal Distribution Plots
R-Help
I am attempting to create a series of bivariate normal distributions. So using the mvtnorm library I have created the following code ...
# Standard deviations and correlation
sig_x <- 1
sig_y <- 1
rho_xy <- 0.0
# Covariance between X and Y
sig_xy <- rho_xy * sig_x *sig_y
# Covariance matrix
Sigma_xy <- matrix(c(sig_x ^ 2, sig_xy, sig_xy, sig_y ^ 2), nrow = 2, ncol = 2)
2006 Jul 01
5
generate bi-variate normal data
Dear all,
I would like to generate bi-variate normal data given that the first column
of the data is known. for example:
I first generate a set of data using the command,
x <- rmvnorm(10, c(0, 0), matrix(c(1, 0, 0, 1), 2))
then I would like to sum up the two columns of x:
x.sum <- apply(x, 1, sum)
now with x.sum I would like to generate another column of data, say y, that
makes
2008 Aug 01
2
contour lines in windows device but neither in pdf nor in postscript
library(mvtnorm)
x = seq(-4,4,length=201)
xy = expand.grid(x,x)
sigma = (diag(c(1,1))+1)/2
d2 = matrix(dmvnorm(xy,sigma=sigma),201)
xsamp = rmvnorm(200,sigma=sigma)
contour(x,x,d2)
points(xsamp,col=3,pch=16)
pdf("pdftry.pdf")
contour(x,x,d2)
points(xsamp,col=3,pch=16)
dev.off()
postscript("pstry.ps")
contour(x,x,d2)
points(xsamp,col=3,pch=16)
dev.off()
# I can see