Simulation study in R

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Simulation study in R

Arun.stat
Here I am in a simulation study where I want to find different values
of x and y such that f(x,y)=c (some known constant) w.r.t. x, y >0,
y<=x and x<=c1 (another known constant). Can anyone please tell me how
to do it efficiently in R. One way I thought that I will draw
different random numbers from uniform dist according to that
constraints and pick those which satisfy f(x,y)=c. However it is not I
think computationally efficient. Can anyone here suggest me any other
efficient approach?

Regards,

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulation study in R

Moshe Olshansky-2
Are the pairs (x,y) belong to some lattice or can
change continuously?
Does f assume some discrete values (or is constant on
sets of positive measure)? If not then it will be hard
to randomly select x and y which satisfy the exact
equality (this still can happen since there are
finitely many computer numbers, but their number is
quite large!). So if f change continuously you may
need the condition |f(x,y) - c| < epsilon for some
epsilon > 0.

Regards,

Moshe.

--- Arun Kumar Saha <[hidden email]> wrote:

> Here I am in a simulation study where I want to find
> different values
> of x and y such that f(x,y)=c (some known constant)
> w.r.t. x, y >0,
> y<=x and x<=c1 (another known constant). Can anyone
> please tell me how
> to do it efficiently in R. One way I thought that I
> will draw
> different random numbers from uniform dist according
> to that
> constraints and pick those which satisfy f(x,y)=c.
> However it is not I
> think computationally efficient. Can anyone here
> suggest me any other
> efficient approach?
>
> Regards,
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulation study in R

Arun.stat
x, y are cont. variable, and f also have to be cont.. And your second
suggestion is correct of course, it actually should be |f(x,y) - c| <
epsilon

Thanks

On Tue, Apr 29, 2008 at 12:34 PM, Moshe Olshansky <[hidden email]> wrote:

> Are the pairs (x,y) belong to some lattice or can
> change continuously?
> Does f assume some discrete values (or is constant on
> sets of positive measure)? If not then it will be hard
> to randomly select x and y which satisfy the exact
> equality (this still can happen since there are
> finitely many computer numbers, but their number is
> quite large!). So if f change continuously you may
> need the condition |f(x,y) - c| < epsilon for some
> epsilon > 0.
>
> Regards,
>
> Moshe.
>
>
> --- Arun Kumar Saha <[hidden email]> wrote:
>
> > Here I am in a simulation study where I want to find
> > different values
> > of x and y such that f(x,y)=c (some known constant)
> > w.r.t. x, y >0,
> > y<=x and x<=c1 (another known constant). Can anyone
> > please tell me how
> > to do it efficiently in R. One way I thought that I
> > will draw
> > different random numbers from uniform dist according
> > to that
> > constraints and pick those which satisfy f(x,y)=c.
> > However it is not I
> > think computationally efficient. Can anyone here
> > suggest me any other
> > efficient approach?
> >
> > Regards,
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
> >
>
>



--

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulation study in R

Robert A LaBudde
In reply to this post by Arun.stat
At 02:40 AM 4/29/2008, Arun Kumar Saha wrote:
>Here I am in a simulation study where I want to find different values
>of x and y such that f(x,y)=c (some known constant) w.r.t. x, y >0,
>y<=x and x<=c1 (another known constant). Can anyone please tell me how
>to do it efficiently in R. One way I thought that I will draw
>different random numbers from uniform dist according to that
>constraints and pick those which satisfy f(x,y)=c. However it is not I
>think computationally efficient. Can anyone here suggest me any other
>efficient approach?

You have not specified the distributions proper for X and Y. Using a
uniform distribution is only appropriate when it meets requirements.

One obvious approach is to sample one of the variables, say X, and
then solve your equation for Y. If you're going to draw a lot of
samples, it would pay to develop y = g(x) first.

But you need to know how to sample X in the first place. Is its
distribution uniform, or something else?

================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: [hidden email]
Least Cost Formulations, Ltd.            URL: http://lcfltd.com/
824 Timberlake Drive                     Tel: 757-467-0954
Virginia Beach, VA 23464-3239            Fax: 757-467-2947

"Vere scire est per causas scire"

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.