Results 1 to 2 of 2

Thread: Defining Recursive formulas in R

  1. #1 Defining Recursive formulas in R 
    Forum Freshman
    Join Date
    Aug 2013
    Hello there, I'm very new to programming and as such have been facing quite a bit of difficulty with a current assignment. My goal is to define a recursive formula where x(i+1) is based on x(i) and u(i) where where u is a Gaussian (normal) variable. Because this is my first time doing this, however, I've decided to start simple and just try to construct a recursive formula based on x(i). Here's what I've got:

    y <- function(y) {
    + if(y==1)
    + return(1.5)
    + else
    + return(1.022*function(y-1))

    At which point I receive:
    Error: unexpected '-' in:

    I've played around with the syntax so much and still I haven't been able to make it work. Any advice?

    Reply With Quote  


  3. #2  
    Brassica oleracea Strange's Avatar
    Join Date
    Oct 2011
    I am not really familiar with R but you appear to have named both the function and its parameter 'y'.

    Maybe you need:
    f <- function(y) { # function named f, withparameter y
    return(1.022*f(y-1) # call f with argument y-1

    ei incumbit probatio qui dicit, non qui negat
    Reply With Quote  

Similar Threads

  1. Diagram G and Recursive Transition Networks
    By invert_nexus in forum Mathematics
    Replies: 14
    Last Post: October 30th, 2013, 09:28 AM
  2. Recursive definition and induction principle
    By annitaz in forum Mathematics
    Replies: 1
    Last Post: March 9th, 2010, 01:00 PM
  3. Defining Entropy
    By organic god in forum Physics
    Replies: 3
    Last Post: January 13th, 2009, 06:47 AM
  4. Recursive formula
    By biohazard87 in forum Mathematics
    Replies: 9
    Last Post: December 10th, 2007, 10:42 PM
  5. Recursive enumerable set
    By nico2005 in forum Mathematics
    Replies: 0
    Last Post: July 18th, 2005, 07:11 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts