[R] simulation for equation with two variables
David Winsemius
dwinsemius at comcast.net
Thu Jul 21 20:22:01 CEST 2011
On Jul 21, 2011, at 1:42 PM, Benjamin Caldwell wrote:
> That is, run all possible combinations of the two vectors through the
> equation.
> *Ben *
For "all combinations" the usual route is data preparation with either
expand.grid() or outer()
>
> On Thu, Jul 21, 2011 at 10:04 AM, Benjamin Caldwell <btcaldwell at berkeley.edu
>> wrote:
>
>> Hi,
>> I'm trying to run a basic simulation and sensitivity test by
>> running an
>> equation with two variables and then plotting the results against
>> each of
>> the vectors. R is running the vectors like this : 0 with 0, 1 with
>> 1, etc. I
>> would like it to run them like 0 for 1:100, 1 for 1:100, and then the
>> reverse (so 100^2*100@ iterations. How do I get it to do that?
>> Here's what
>> I have so far:
>>
>> par(mfrow=c(1,2))
>> t <- 0:100
>> DBH <- 0:100
>> M <- 4000*(1-exp(-t*(1.104-(0.67*0.7)-0.163*log(DBH))^2)))
>> plot(M~DBH)
>> plot(M~t)
>>
>> *Ben*
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list