Try this for size:
Not a very efficient way to do it though!!!
Get.Random.Walk-function(){
length.walk-1000
rand.walk-rep(0,length.walk)
for(i in 2:length.walk)
{
rand.walk[i]-rand.walk[i-1]+rnorm(1, mean=0, sd=1)
}
return(rand.walk)
}
plot(Get.Random.Walk())
-Original Message-
How about:
y-cumsum(c(0,rnorm(100)))
On Tue, 10 Feb 2004, allan clark wrote:
hi all
how does one simulate a random walk process?
i.e
y(0)=0
y(t)=y(t-1)+ e(t)
where e(t) is normal(0,1) say.
Regards
allan
__
[EMAIL PROTECTED] mailing
On Tue, 10 Feb 2004, allan clark wrote:
hi all
how does one simulate a random walk process?
i.e
y(0)=0
y(t)=y(t-1)+ e(t)
where e(t) is normal(0,1) say.
e-rnorm(100)
y-cumsum(e)
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
[EMAIL PROTECTED]
allan clark [EMAIL PROTECTED] writes:
hi all
how does one simulate a random walk process?
i.e
y(0)=0
y(t)=y(t-1)+ e(t)
where e(t) is normal(0,1) say.
E.g.,
c(0,cumsum(rnorm(1000)))
--
O__ Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics
?lag.plot
-Original Message-
From: allan clark [mailto:[EMAIL PROTECTED]
Sent: 03 February 2004 11:58
To: Rhelp
Subject: [R] R: lags and plots
Hi all
I want to calculate certain lags of a time series and plot them
simultaneously on a graph. can anyone help?
KSS Ltd
Seventh Floor
On Tue, 03 Feb 2004 13:57:53 +0200 allan clark wrote:
Hi all
I want to calculate certain lags of a time series and plot them
simultaneously on a graph. can anyone help?
Something like this?
R x - ts(cumsum(rnorm(20)), start = 0, freq = 10)
R plot(x)
R lines(lag(x, k = -1), col = 4)
hth
Z
allan == allan clark [EMAIL PROTECTED]
on Tue, 03 Feb 2004 13:57:53 +0200 writes:
allan Hi all I want to calculate certain lags of a time
allan series and plot them simultaneously on a graph. can
allan anyone help?
Use lag.plot() {name and part of UI is for S+ compatibility}