Re: [R] Generating Data using Formulas

2007-05-31 Thread Prof Brian Ripley
On Wed, 30 May 2007, Charles C. Berry wrote: Christian, The formula language is not suited to such recursive useage AFAICS. But filter() is. In this case the result is an AR(1) process, so arima.sim() could be used (and internally that uses filter). I know this is an exercise, but using

Re: [R] Generating Data using Formulas

2007-05-30 Thread Charles C. Berry
Christian, The formula language is not suited to such recursive useage AFAICS. You can _vectorize_ your code like this: cmat - outer( 1:25, 1:25, function(y,x) ifelse( xy, 0, 0.8^(y-x) ) ) res - replicate(1000,{ y - 1 + cmat %*% rnorm(25) coef(lm(y[-1]~y[-25]))

[R] Generating Data using Formulas

2007-05-29 Thread Chrisitan Falde
Hello, My name is Christian Falde. I am new to R. My problem is this. I am attempting to learn R on my own. In so doing I am using some problems from Davidson and MacKinnon Econometric Theory and Methods to do so. This is because I can already do the some of the problems in SAS so I