首页 > > 详细

讲解script留学生、辅导R设计、R编程语言调试、辅导histogram辅导留学生 Statistics统计、回归、迭代|解析Jav

Homework Assignment #1
1. Download Canadian monthly housing starts in urban centres over 10,000 (1950-now, total
dwellings) from CanSim and save it as tab-delimited txt file.
2. Start a R script with appropriate header and read in the txt data. Create a data frame with two
variables. The first one should include the dates (yyyy-mm) and the second one the
corresponding housing starts.
3. Create a histogram of the housing starts variable, comment on why it looks the way it looks and
if this is useful information.
4. Create a time series graph of housing starts, try to get the dates on the x-axis.
5. Create a function that takes in a vector x and calculates the growth rates (𝑙𝑛(𝑥𝑡) − 𝑙𝑛(𝑥𝑡−1)).
Within the function,
a. Determine the length of the input vector x and save it as n.
b. if the minimum element of the vector is negative, add the absolute value of this
minimum plus 1 to the vector, so that the new minimum is 1.
c. Take the natural logarithm of this new vector
d. Subtract the vector elements 1 to (n-1) from the vector elements 2 to n to get the
growth rates
e. Add an NaN to the beginning of the vector
f. Return the final vector
6. Create a vector v = [-2, 0, -1, 3, 5, 7, 12] and try out your function.
7. Apply your function to the housing starts variable.
8. Plot the new housing starts growth rates.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!