Due: At the start of class on Thursday, September 1. Please turn in a hard copy.

Question 1 Download the data fertilizer_2000.RData from the course website to answer this question (there is also a description file on the course website).

  1. How many observations does this data contain?

  2. Data about what country is provided in the 21st row?

  3. What is the average per capita GDP across all countries in the data?

  4. What is the average precipitation among countries that have higher than average per capita GDP?

Question 2 The Fibonacci sequence is the sequence of numbers \(0,1,1,2,3,5,8,13,21,34,55,\ldots\) that comes from starting with \(0\) and \(1\) and where each subsequent number is the sum of the previous two. For example, the 5 in the sequence comes from adding 2 and 3; the 55 in the sequence comes from adding 21 and 34.

  1. Write a function called fibonacci that takes in a number n and computes the nth element in the Fibonacci sequence. For example fibonacci(5) should return 3 and fibonacci(8) should return 13. Use your function to compute the 16th element of the Fibonacci sequence.

  2. Consider an alternative sequence where, starting with the third element, each element is computed as the sum of the previous two elements (the same as with the Fibonacci sequence) but where the first two elements can be arbitrary. Write a function alt_seq(a,b,n) where a is the first element in the sequence, b is the second element in the sequence, and n is which element in the sequence to return. For example, if \(a=3\) and \(b=7\), then the sequence would be \(3,7,10,17,27,44,71,\ldots\) and alt_seq(a=3,b=7,n=4) = 17. Use your function to compute the 16th element of the this alternative sequence for \(a=5\) and \(b=9\).