anan1986
2010-Mar-09 16:01 UTC
[R] Help! I need to use R to calculate a recursive function!
hi,all Z(i)=0.05X(i)+0.95Z(i-1), where i = 1.....32, and X's are given data, the question is how to use r to get the 32 values of Z. I couldn't do this in R and wish somebody can help me. thanks in regards -- View this message in context: http://n4.nabble.com/Help-I-need-to-use-R-to-calculate-a-recursive-function-tp1586189p1586189.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
Barry Rowlingson
2010-Mar-09 18:34 UTC
[R] Help! I need to use R to calculate a recursive function!
On Tue, Mar 9, 2010 at 4:01 PM, anan1986 <ayc_boy at hotmail.com> wrote:> > hi,all > > Z(i)=0.05X(i)+0.95Z(i-1), where i = 1.....32, and X's are given data, the > question is how to use r to get the 32 values of Z. > > I couldn't do this in R and wish somebody can help me.Can you do anything in R? Have you tried? Have you read any of the introductory R tutorials? All this needs is a for() loop and some vector indexing. You'll do it if you read the first five pages of any introductory R guide. Barry
anan1986
2010-Mar-09 21:06 UTC
[R] Help! I need to use R to calculate a recursive function!
I tried! but my solution is not correc! -- View this message in context: http://n4.nabble.com/Help-I-need-to-use-R-to-calculate-a-recursive-function-tp1586189p1586590.html Sent from the R help mailing list archive at Nabble.com.
Please show your attempt that didn't work. What do you do for Z(1)? (You could try looking at the help on filter) -- View this message in context: http://n4.nabble.com/Help-I-need-to-use-R-to-calculate-a-recursive-function-tp1586189p1586777.html Sent from the R help mailing list archive at Nabble.com.