Purpose: Enable students to gather data on their own and analyse the data in terms of the concepts of the first part of the course.

Deadline: Tuesday, Oct 4, 2017

Question 1

Input the data into a R ts object. Only consider monthly data on “Total Gross” from Jan 1982 to Dec 2016.

Estimate a linear trend on the data. What is the slope of the linear trend?

First, let is import the data and read it into a data frame:

tot.gross <- read_csv("h5.csv")

Alternatively, you can manually input the data:

tot.gross <- c(49.2,109.9,217.3,100.6,289.2,675.7,675.7,157.6,26.5,115.7,97.8,608.1,
               27.1,68.8,203.3,165.5,372.7,434.9,434.9,173.4,149.0,200.0,204.8,309.6,
               62.8,165.6,366.1,144.0,336.1,726.5,726.5,191.7,221.8,136.3,165.8,593.6,
               60.8,171.6,320.6,76.3,342.1,295.5,295.5,293.1,85.6,136.9,334.9,468.4,
               147.7,184.5,217.7,73.6,360.3,501.6,501.6,260.6,206.3,256.1,267.7,455.9,
               136.2,185.8,205.7,153.3,262.8,458.8,458.8,334.5,256.2,179.5,461.4,510.4,
               46.4,170.0,221.3,249.4,267.3,632.1,632.1,243.4,108.1,132.9,330.0,719.9,
               62.8,188.7,210.3,344.9,303.5,750.7,750.7,363.0,157.4,330.9,440.2,565.4,
               67.6,164.0,585.7,173.7,241.7,531.9,531.9,356.3,181.5,247.5,792.4,508.4,
               119.9,353.2,310.2,139.7,382.0,523.6,523.6,242.1,181.2,234.2,525.5,675.4,
               173.8,277.4,404.5,268.1,470.6,397.7,397.7,317.4,252.0,335.9,773.6,468.0,
               137.6,330.9,190.0,327.9,411.5,674.0,674.0,374.6,225.5,388.8,549.9,668.4,
               111.6,305.9,323.7,250.4,376.8,637.5,637.5,375.9,230.2,379.8,501.3,653.3,
               143.7,207.5,325.8,347.8,534.5,770.3,770.3,473.9,313.4,365.7,612.9,775.0,
               143.6,313.2,447.4,266.7,637.5,600.1,600.1,395.9,259.2,304.9,810.7,767.1,
               301.8,377.6,461.9,322.3,530.6,623.0,623.0,511.5,339.6,415.9,502.1,1484.3,
               174.1,234.9,384.2,387.0,572.5,713.7,713.7,386.1,307.8,521.5,832.8,919.6,
               176.7,329.6,591.0,353.2,783.8,887.5,887.5,653.4,458.2,448.2,842.8,936.0,
               273.7,432.7,506.9,457.2,781.9,863.4,863.4,583.5,365.5,432.2,850.0,1437.1,
               231.2,401.2,529.1,390.0,813.2,831.8,831.8,852.2,268.5,465.0,1024.7,1382.5,
               323.2,392.8,828.9,682.3,1201.4,866.6,866.6,707.4,431.8,581.0,950.3,1418.2,
               347.3,493.5,510.5,530.5,1412.6,550.9,550.9,634.4,462.6,784.9,896.3,1280.7,
               287.8,773.9,543.3,689.4,995.6,1376.8,1376.8,568.5,332.1,809.7,974.7,1124.4,
               370.5,516.2,632.4,483.0,1045.8,1057.0,1057.0,539.2,563.6,529.0,954.1,1240.5,
               378.5,533.2,822.1,522.7,901.7,1159.4,1159.4,672.8,570.9,591.3,870.9,1254.8,
               266.4,623.7,919.7,403.5,1085.4,1113.2,1113.2,871.4,477.7,470.2,864.9,1435.0,
               391.0,661.6,623.1,452.0,1167.2,1066.8,1066.8,655.6,497.0,639.2,1125.0,1148.5,
               675.4,551.6,691.5,564.9,1316.9,1124.1,1124.1,744.4,581.9,619.0,1262.0,1636.9,
               393.2,603.3,1026.3,600.5,951.8,1409.8,1409.8,646.3,507.9,654.5,1202.7,1089.8,
               329.8,587.8,658.6,958.7,1194.2,1141.2,1141.2,693.7,607.0,573.6,1017.2,1097.7,
               433.5,810.4,1117.2,532.2,1180.3,1313.8,1313.8,739.1,564.7,578.7,1539.8,1077.9,
               327.7,537.6,986.4,431.9,1461.1,1229.1,1229.1,841.5,472.2,676.3,1492.5,1179.8,
               386.3,712.1,741.5,743.8,1234.3,997.6,997.6,1011.6,455.0,878.9,1138.2,1322.0,
               406.5,711.2,758.2,639.3,1183.0,1379.0,1379.0,547.4,701.1,594.9,1084.2,1799.7,
               489.0,656.6,1094.4,697.8,925.8,1177.6,1177.6,828.9,628.7,492.6,1301.0,1583.5)

Now, let us generate a time-series object and output it:

tot.gross.ts <- ts(tot.gross,start = c(1982,1),freq=12)
tot.gross.ts
##         Jan    Feb    Mar    Apr    May    Jun    Jul    Aug    Sep    Oct
## 1982   49.2  109.9  217.3  100.6  289.2  675.7  675.7  157.6   26.5  115.7
## 1983   27.1   68.8  203.3  165.5  372.7  434.9  434.9  173.4  149.0  200.0
## 1984   62.8  165.6  366.1  144.0  336.1  726.5  726.5  191.7  221.8  136.3
## 1985   60.8  171.6  320.6   76.3  342.1  295.5  295.5  293.1   85.6  136.9
## 1986  147.7  184.5  217.7   73.6  360.3  501.6  501.6  260.6  206.3  256.1
## 1987  136.2  185.8  205.7  153.3  262.8  458.8  458.8  334.5  256.2  179.5
## 1988   46.4  170.0  221.3  249.4  267.3  632.1  632.1  243.4  108.1  132.9
## 1989   62.8  188.7  210.3  344.9  303.5  750.7  750.7  363.0  157.4  330.9
## 1990   67.6  164.0  585.7  173.7  241.7  531.9  531.9  356.3  181.5  247.5
## 1991  119.9  353.2  310.2  139.7  382.0  523.6  523.6  242.1  181.2  234.2
## 1992  173.8  277.4  404.5  268.1  470.6  397.7  397.7  317.4  252.0  335.9
## 1993  137.6  330.9  190.0  327.9  411.5  674.0  674.0  374.6  225.5  388.8
## 1994  111.6  305.9  323.7  250.4  376.8  637.5  637.5  375.9  230.2  379.8
## 1995  143.7  207.5  325.8  347.8  534.5  770.3  770.3  473.9  313.4  365.7
## 1996  143.6  313.2  447.4  266.7  637.5  600.1  600.1  395.9  259.2  304.9
## 1997  301.8  377.6  461.9  322.3  530.6  623.0  623.0  511.5  339.6  415.9
## 1998  174.1  234.9  384.2  387.0  572.5  713.7  713.7  386.1  307.8  521.5
## 1999  176.7  329.6  591.0  353.2  783.8  887.5  887.5  653.4  458.2  448.2
## 2000  273.7  432.7  506.9  457.2  781.9  863.4  863.4  583.5  365.5  432.2
## 2001  231.2  401.2  529.1  390.0  813.2  831.8  831.8  852.2  268.5  465.0
## 2002  323.2  392.8  828.9  682.3 1201.4  866.6  866.6  707.4  431.8  581.0
## 2003  347.3  493.5  510.5  530.5 1412.6  550.9  550.9  634.4  462.6  784.9
## 2004  287.8  773.9  543.3  689.4  995.6 1376.8 1376.8  568.5  332.1  809.7
## 2005  370.5  516.2  632.4  483.0 1045.8 1057.0 1057.0  539.2  563.6  529.0
## 2006  378.5  533.2  822.1  522.7  901.7 1159.4 1159.4  672.8  570.9  591.3
## 2007  266.4  623.7  919.7  403.5 1085.4 1113.2 1113.2  871.4  477.7  470.2
## 2008  391.0  661.6  623.1  452.0 1167.2 1066.8 1066.8  655.6  497.0  639.2
## 2009  675.4  551.6  691.5  564.9 1316.9 1124.1 1124.1  744.4  581.9  619.0
## 2010  393.2  603.3 1026.3  600.5  951.8 1409.8 1409.8  646.3  507.9  654.5
## 2011  329.8  587.8  658.6  958.7 1194.2 1141.2 1141.2  693.7  607.0  573.6
## 2012  433.5  810.4 1117.2  532.2 1180.3 1313.8 1313.8  739.1  564.7  578.7
## 2013  327.7  537.6  986.4  431.9 1461.1 1229.1 1229.1  841.5  472.2  676.3
## 2014  386.3  712.1  741.5  743.8 1234.3  997.6  997.6 1011.6  455.0  878.9
## 2015  406.5  711.2  758.2  639.3 1183.0 1379.0 1379.0  547.4  701.1  594.9
## 2016  489.0  656.6 1094.4  697.8  925.8 1177.6 1177.6  828.9  628.7  492.6
##         Nov    Dec
## 1982   97.8  608.1
## 1983  204.8  309.6
## 1984  165.8  593.6
## 1985  334.9  468.4
## 1986  267.7  455.9
## 1987  461.4  510.4
## 1988  330.0  719.9
## 1989  440.2  565.4
## 1990  792.4  508.4
## 1991  525.5  675.4
## 1992  773.6  468.0
## 1993  549.9  668.4
## 1994  501.3  653.3
## 1995  612.9  775.0
## 1996  810.7  767.1
## 1997  502.1 1484.3
## 1998  832.8  919.6
## 1999  842.8  936.0
## 2000  850.0 1437.1
## 2001 1024.7 1382.5
## 2002  950.3 1418.2
## 2003  896.3 1280.7
## 2004  974.7 1124.4
## 2005  954.1 1240.5
## 2006  870.9 1254.8
## 2007  864.9 1435.0
## 2008 1125.0 1148.5
## 2009 1262.0 1636.9
## 2010 1202.7 1089.8
## 2011 1017.2 1097.7
## 2012 1539.8 1077.9
## 2013 1492.5 1179.8
## 2014 1138.2 1322.0
## 2015 1084.2 1799.7
## 2016 1301.0 1583.5

Plotting the data:

plot(tot.gross.ts, 
     las=1,col=4,
     ylab="",xlab="",  
     main="Total Movie Gross by Month (in $m)",  
     sub = "SOURCE: Box Office Mojo")
library(Hmisc)
minor.tick(nx=5,ny=5); grid()