Stat. 474 Quiz 1

Author

<<< Put your name here >>>

Instructions:

The quiz investigate the dataset global_economy. The dataset contains yearly historial economic data for all countries on Earth.

library(pacman)
p_load(tidyverse, fpp3)

Question 1

How many countries are there one Earth? How may Countries are there in the dataset? Why do the numbers differ?

Answer

<<< Write your answer here. >>>

Provide your code here.

data(global_economy)
global_economy
# A tsibble: 15,150 x 9 [1Y]
# Key:       Country [263]
   Country     Code   Year         GDP Growth   CPI Imports Exports Population
   <fct>       <fct> <dbl>       <dbl>  <dbl> <dbl>   <dbl>   <dbl>      <dbl>
 1 Afghanistan AFG    1960  537777811.     NA    NA    7.02    4.13    8996351
 2 Afghanistan AFG    1961  548888896.     NA    NA    8.10    4.45    9166764
 3 Afghanistan AFG    1962  546666678.     NA    NA    9.35    4.88    9345868
 4 Afghanistan AFG    1963  751111191.     NA    NA   16.9     9.17    9533954
 5 Afghanistan AFG    1964  800000044.     NA    NA   18.1     8.89    9731361
 6 Afghanistan AFG    1965 1006666638.     NA    NA   21.4    11.3     9938414
 7 Afghanistan AFG    1966 1399999967.     NA    NA   18.6     8.57   10152331
 8 Afghanistan AFG    1967 1673333418.     NA    NA   14.2     6.77   10372630
 9 Afghanistan AFG    1968 1373333367.     NA    NA   15.2     8.90   10604346
10 Afghanistan AFG    1969 1408888922.     NA    NA   15.0    10.1    10854428
# … with 15,140 more rows
global_economy %>% distinct(Country) %>% 
  count()
# A tibble: 1 × 1
      n
  <int>
1   263

Question 2

Create a new variable GDP_per_capita. Show the first few values of the new variable.

Answer

<<< Write your answer here. >>>

Provide your code here.

gdppc <- global_economy %>%
  mutate(GDP_per_capita = GDP / Population) 
gdppc %>% select(GDP_per_capita) %>% 
  head()
# A tsibble: 6 x 3 [1Y]
# Key:       Country [1]
  GDP_per_capita  Year Country    
           <dbl> <dbl> <fct>      
1           59.8  1960 Afghanistan
2           59.9  1961 Afghanistan
3           58.5  1962 Afghanistan
4           78.8  1963 Afghanistan
5           82.2  1964 Afghanistan
6          101.   1965 Afghanistan

Question 3

Plot the time series data for Population for each of these countries: United States, Brasil, Canada, Mexico, Russia, Israel, and Japan. What do you notice about the population of Russian and Japan?

Answer

<<< Write your answer here. >>>

Provide your code here.

gdppc %>% filter(Code %in% c("USA", "BRA", "CAN",  "MEX", "RUS", "ISR", "JPN")) %>% 
  autoplot(Population)

Question 4

Plot the time series data for GDP for each of these countries: United States, Brasil, Canada, Mexico, Russia, Israel, and Japan. How does the GDP of Japan compare to the GDP of the United States?

Answer

<<< Write your answer here. >>>

Provide your code here.

gdppc %>% filter(Code %in% c("USA", "BRA", "CAN",  "MEX", "RUS", "ISR", "JPN")) %>% 
  autoplot(GDP)
Warning: Removed 29 row(s) containing missing values (geom_path).

Question 5

Plot the time series data for GDP_per_capita for each of these countries: United States, Brasil, Canada, Mexico, Russia, Israel, and Japan. How does the GDP per capita differ for Russia, Mexico and Brasil?

Answer

<<< Write your answer here. >>>

Provide your code here.

gdppc %>% filter(Code %in% c("USA", "BRA", "CAN",  "MEX", "RUS", "ISR", "JPN")) %>% 
  autoplot(GDP_per_capita)
Warning: Removed 29 row(s) containing missing values (geom_path).

Question 6

Remake all of your plots including China. How does China compare to the United States in each plot?

Answer

<<< Write your answer here. >>>

Provide your code here.

Question 7

Does it make sense to run a Seasonal Decomposition with these data? Why or why not, explain.

Answer

<<< Write your answer here. >>>

Question 8

R questions.

  1. Explain what a tsibble is?

<<< Write your answer here. >>>

  1. Explain what a mable is?

<<< Write your answer here. >>>

  1. Explain what a fable is?

<<< Write your answer here. >>>