For some recursive definitions such as this you can use Reduce
to get calculate your desired value. For example
y <- Reduce(function(prev, t) {
cos(t * pi / 30) + 3 * sin(t * pi / 30) + 0.5 * prev + rnorm(1)
}, 2:n, init=rnorm(1), accumulate = TRUE)
CLICK HERE to find out more related problems solutions.