In: Statistics and Probability
Consider the yearly data of lumber production (in billions of board feet) in the United States given as follows:
year | production |
1921 | 29 |
1922 | 35.2 |
1923 | 41 |
1924 | 39.5 |
1925 | 41 |
1926 | 39.8 |
1927 | 37.3 |
1928 | 36.8 |
1929 | 38.7 |
1930 | 29.4 |
1931 | 20 |
1932 | 13.5 |
1933 | 17.2 |
1934 | 18.8 |
1935 | 22.9 |
1936 | 27.6 |
1937 | 29 |
1938 | 24.8 |
1939 | 28.8 |
1940 | 31.2 |
1941 | 36.5 |
1942 | 36.3 |
1943 | 34.3 |
1944 | 32.9 |
1945 | 28.1 |
1946 | 34.1 |
1947 | 35.4 |
1948 | 37 |
1949 | 32.2 |
1950 | 38 |
1951 | 37.2 |
1952 | 37.5 |
1953 | 36.7 |
1954 | 36.4 |
1955 | 37.4 |
1956 | 38.2 |
1957 | 32.9 |
1958 | 33.4 |
1959 | 37.2 |
1960 | 32.9 |
1961 | 32 |
1962 | 33.2 |
1963 | 34.7 |
1964 | 36.6 |
1965 | 36.8 |
1966 | 36.6 |
1967 | 34.7 |
1968 | 36.5 |
1969 | 35.8 |
1970 | 34.7 |
1971 | 37 |
1972 | 37.7 |
1973 | 38.6 |
1974 | 34.6 |
1975 | 32.6 |
1976 | 36.3 |
1977 | 39.4 |
1978 | 40.5 |
1979 | 40.6 |
1980 | 35.4 |
1981 | 31.7 |
1982 | 30 |
A. Perform necessary analysis to construct an appropriate model for the series and plot the forecasts for the next four years and calculate 95% forecast limits.
Please use RStudio, and also send codes and packages/libraries used, for me to use and review, Thank you!
ans in rstudio with out put for forecasting
> data=read.csv(file.choose(),header = T) > production=data[,2] > summary(data) year production Min. :1921 Min. :13.50 1st Qu.:1936 1st Qu.:32.05 Median :1952 Median :35.40 Mean :1952 Mean :33.74 3rd Qu.:1967 3rd Qu.:37.20 Max. :1982 Max. :41.00 > > times=ts(data$production) > times Time Series: Start = 1 End = 62 Frequency = 1 [1] 29.0 35.2 41.0 39.5 41.0 39.8 37.3 36.8 38.7 29.4 20.0 [12] 13.5 17.2 18.8 22.9 27.6 29.0 24.8 28.8 31.2 36.5 36.3 [23] 34.3 32.9 28.1 34.1 35.4 37.0 32.2 38.0 37.2 37.5 36.7 [34] 36.4 37.4 38.2 32.9 33.4 37.2 32.9 32.0 33.2 34.7 36.6 [45] 36.8 36.6 34.7 36.5 35.8 34.7 37.0 37.7 38.6 34.6 32.6 [56] 36.3 39.4 40.5 40.6 35.4 31.7 30.0 > plot.ts(production) > plot(production) > plot(times) > > ### To check stationarity > Box.test(production) Box-Pierce test data: production X-squared = 41.097, df = 1, p-value = 1.449e-10 > adf.test(production) # alternative hypothesis: stationary Augmented Dickey-Fuller Test data: production Dickey-Fuller = -2.8426, Lag order = 3, p-value = 0.2339 alternative hypothesis: stationary > ## above test we conclude data is stationary > > > tsdata=ts (production, start=c(1921),end = c(1982),frequency = 62) > ddata <- decompose(tsdata, "multiplicative")# ddata: decomposition of data > plot(ddata) > > library(tseries) > library(forecast) > > myforecast=forecast(tsdata,level = c(95),h=4) > myforecast Point Forecast Lo 95 Hi 95 1983 35.2 35.2 35.2 1984 41.0 41.0 41.0 1985 39.5 39.5 39.5 1986 41.0 41.0 41.0 > plot.ts(production)