Hi all,
Sorry I have too many questions. I could not think of a way to fix
problem. Can anyone give some suggestions on fixing this?
Hannah
2010/5/28 li li
> Hi Sarah,
> Thanks for your kind help. I now know where the problem is.
> Hannah
>
>
Hi Sarah,
Thanks for your kind help. I now know where the problem is.
Hannah
2010/5/28 Sarah Goslee
> My initial guess appears to be right: you're working with something
> exceedingly sensitive to floating point precision. You may have to
> reconsider your methods.
>
My initial guess appears to be right: you're working with something
exceedingly sensitive to floating point precision. You may have to
reconsider your methods.
Your problem is:
rho.f(rho = 0.3)
gives a different answer than
rho.f(seq(0, 1, by=.1)[4])
even though
all.equal(0.3, seq(0, 1, by=.1)[
I modified my codes. However it looks like it still has the same problem.
Again, rho.f(0.3) gives the right answer. rho.f(corr[4])
gives wrong answer even though corr[4]==0.3.
The codes are attached.
Thank you very much!!!
> rho.f(0.3)
$est.1
[1] 0.000 0.000 0.000 0.000 0.8333
On May 28, 2010, at 12:03 PM, Sarah Goslee wrote:
From your code:
mean <- c(rep(mu0, mzero), rep(mu1,m-mzero))
mean() is a function. If you overwrite it with data, you may mess
other things up -
any function you call that calls mean will now fail (at best).
Actually, it's bad but not quite
You mean there is a function "mean" in R, so I should
avoid to use it, right?
so I do the following:
mean1 <- c(rep(mu0, mzero), rep(mu1,m-mzero))
var.f <- function(rho, m, J) {
(1-rho)*diag(m)+rho*J%*%t(J)
}
Thanks!
2010/5/28 Sarah Goslee
> From your code:
>
> mean <- c(rep(mu0, mzero),
>From your code:
mean <- c(rep(mu0, mzero), rep(mu1,m-mzero))
mean() is a function. If you overwrite it with data, you may mess
other things up -
any function you call that calls mean will now fail (at best).
var.f <- function(rho) {
(1-rho)*diag(m)+rho*J%*%t(J)
}
var.f() is a complete funct
I am not sure about "overwrite mean() with data". My purpose was
to generate random numbers that are from a multivariate normal
distribution with the mean vector.
For the var.f function, since I already specify m and J, so the only
variable is really rho, so I wrote it as a function of rho only.
There are a bunch of problems in your code:
you overwrite mean() with data, and that could screw things up.
you have a function var.f that isn't passed all the arguments it needs.
est.4 is defined several times, each overwriting the previous.
First you need to clean up these sorts of problems sinc
Thanks very much for your reply. The function is a bit long. I attached it.
rho.f () is in second text document. It uses rada1.mnorm() function which
is contained in the first document.
Thank you very very much!!!
2010/5/28 Dennis Murphy
> Hi:
>
> The problem is that input arguments such as c
Hi:
The problem is that input arguments such as corr[4] have to be evaluated
within the body of your function, and apparently you haven't written it to
do so. Unfortunately, I can't help further because my clairvoyance package
is still in the concept development stage. In the meantime, it would be
Hi Hannah,
No, we can't help because we have no idea what rho.f does - you didn't
provide the requested reproducible example. Without more information,
the only thing I can think of is that your function might be ridiculously
sensive to numeric precision (though that seems unlikely):
> corr <- se
12 matches
Mail list logo