NOTE: What is the historical trend for nutrition incentive dollars in OHIO What are the state investments in nutrition incentive dollars in Ohio?
What is the association/relationship between monthly statewide nutrition incentive dollar distribution and month-to-month growth of monthly SNAP distribution dollars from 2017 to 2021 at FMs participating in GusNIP in Ohio?
NOTE: Work on Objectives (This have to be more specific)
Describe monthly SNAP dollars distribution, nutrition incentive dollar distribution, and month-to-month growth of SNAP dollars distribution at participating FM by location (rural vs urban, network-membership), market size (number of vendors).
Produce a correlation matrix between FM size (number of vendors) and Volume of SNAP sales.
Model/Assess the correlation/association of the amount of monthly statewide nutrition incentive dollars and month-to-month growth of SNAP distribution dollars at FM from 2017 to 2021 adjusted by relevant FM and contextual characteristics
Outcome Variables The key outcome in this study is month-to-month growth of mean monthly SNAP dollars distribution at farmers’ markets in Ohio, from 2017 to 2019. Monthly SNAP distributions is defined as the amount of SNAP dollars distributed in a month at farmers’ market included in the study. Month-to-Month growth of monthly SNAP dollars distribution is calculated as follows:
Month-to-month growth of mean SNAP Sales (%). The outcome describes how large an increase in mean monthly SNAP dollars distributions in a given month compared to the prior month. The formula here is M2Mmgrowth = ((Snap.Sales of current month/Snap.slaes of prior month) - 1)%100.
Mean SNAP dollar distributed at FMs. This outcomes describes the total mean monthly distributions of SNAP dollars at FMs in Ohio.
Mean number of new customers. This variable describes the mean number of new customers in a given month.
Mean number of transactions. This variable describes the mean number of SNAP transactions in a given month.
Important Predictor Variable(s) || Relationship between Outcome and theorethically important predictor variables
This study is to assess factors likely driving the growth of SNAP dollars distributed at FM in Ohio. We hypothesize that the following factors are important predictors of the outcome:
Mean statewide nutrition incentive dollars distributed at FMs. This variable describes the total mean monthly distributions of statewide nutrition incentive dollars distributed at FMs in Ohio.
Mean number of new customers. This variable describes the mean number of new customers in a given month.
Mean number of transactions. This variable describes the mean number of SNAP transactions in a given month.
Mean number of FM days. This variable describes the mean number of days Farmers’ Markets are opened for business in Ohio.
The following is the analysis plan for this AIM. I’m using Rob J Hyndman and George Athanasopoulos’ approach to modeling time series. https://otexts.com/fpp3/index.html
This is an useful flowchart for ARIMA modeling and forecasting.
The main data set used to address the research questions in this AIM are daily SNAP transaction reports from farmers’ markets utilizing the FMTracks platform. The FMTracks app was developed by Dr. Darcy Freedman and team, to track SNAP distribution, and nutrition incentive dollars distribution at participating FMs. FMtracks is the app used by Farmers’ Markets participating in the SNAP nutrition incentive program in Ohio. The raw data was re-downloaded from FMTracks by Roberto Martinez on Feb 01 of 2023.
Total number of rows: 14,488. This represents unique daily transactions for 148 unique Farmers’ Markets from year 2016 to year 2021. This dataset contains no missing data on SNAP transactions. (CHECK THESE NUMBERS)
FMTracks data was enriched by merging data at the census tract level from: 1. Geographic Identifiers (GEOIDs). The Census Bureau and other state and federal agencies are responsible for assigning geographic identifiers, or GEOIDs, to geographic entities to facilitate the organization, presentation, and exchange of geographic and statistical data. GEOIDs are numeric codes that uniquely identify all administrative/legal and statistical geographic areas for which the Census Bureau tabulates data. https://www.census.gov/programs-surveys/geography/guidance/geo-identifiers.html
Census tract socioeconomic and demographic information found in the American Community Survey.
Rural-Urban Commuting Area Codes. The rural-urban commuting area (RUCA) codes classify U.S. census tracts using measures of population density, urbanization, and daily commuting. A second data-set applies 2010 RUCA classifications to ZIP code areas by transferring RUCA values from the census tracts that comprise them. The most recent RUCA codes are based on data from the 2010 decennial census and the 2006–10 American Community Survey. The classification contains two levels. Whole numbers (1–10) delineate metropolitan, metropolitan, small town, and rural commuting areas based on the size and direction of the primary (largest) commuting flows. These 10 codes are further subdivided based on secondary commuting flows, providing flexibility in combining levels to meet varying definition needs and preferences. Descriptions of the codes are found within the data files, and also in the Documentation.
The USDA Food Access Research Atlas. The FARA presents an overview of food access indicators for low-income and other census tracts using different measures of supermarket accessibility. It provides food access data for populations within census tracts, and Offers census-tract-level data on food access that can be downloaded for community planning or research purposes.
The data-set contain the following variables.
| Variable Name | Type. | Variable Description |
|---|---|---|
| Month-to-month Grow SNAP | Numerical | |
| Market.Name | Categorical | |
| Weekly_Date | Date | |
| Paid Staff | Numerical | |
| Volunteers | Numerical | |
| F&VProducers/Vendors | Numerical | |
| FM_Size | Categorical | |
| Network | Categorical | |
| SNAP Sales | Numerical | |
| Incentives.Distributed | Numerical | |
| Urban | Categorical | |
| ADI Area Deprivation Ind | Numerical (Score) | |
| LILATracts_1And10 | Categorical | |
| Received_Food_stampsSNAP | Numerical. | |
| Number of FMs | Numerical | |
| . Transactions | Numerical | |
| New SNAP Customers. | Numerical |
Other Potential Variables (Check with Darcy) PM-SNAP Redeemed PM-F&V-only SNAP Incentives Redeemed Gross Sales for All Vendors Head Count ‘#.New.Federal.Benefit.Customers’
Loading FMTracks Data
Merging data all years of data into one data-set.
Loading the USDA Food Access Research Atlas & selecting variables of interest.
Loading GEOID information for FMs
Loading Ruca Codes
Installing Census Bureau API key
When to Use 1-year, 3-year, or 5-year Estimates Choosing which data-set involves more than simply considering the population size in your area. You must think about the balance between currency and sample size/reliability/precision. For details, research implications, and examples, see “Understanding and Using ACS Single-Year and Multiyear Estimates,” in section 3 of the General Data Users Handbook.
Use 5-year Estimates Precision is more important than currency Analyzing very small populations Examining tracts and other smaller geographies because 1-year estimates are not available
The following are inclusion criteria for the study.
The FMTracks data-set contains 148 Farmers’ Markets. These Farmers’ Markets reported distribution of SNAP Dollars and the nutrition incentive dollars at some point between 2017 and 2021. After applying the first inclusion/exclusion criteria the list is reduced to 119 Farmers’ Markets. In the end 71 FM are included in the sample.
Code Creating Filter: SNAP Sales <100 a year
Aggregating Farmers’ Maket data by importatn sales variables. I’m calculating the mean sales in a year per day.
## [1] "2nd Street Market"
## [2] "Athens Farmers Market"
## [3] "Barberton Farmers Market"
## [4] "Bexley Farmers Market"
## [5] "Canal Market District"
## [6] "Canton Farmers' Market"
## [7] "City Fresh CSA"
## [8] "Clintonville Farmers' Market"
## [9] "Coit Road Farmers Market"
## [10] "Columbus Public Health Farmers Market"
## [11] "Countryside Farmers' Market at Highland Square"
## [12] "Countryside Farmers' Market at Howe Meadow"
## [13] "Countryside OTS Winter Farmers' Market"
## [14] "Countryside Public Market"
## [15] "Cultivate Co-op Cafe"
## [16] "Downtown Lima Farmers' Market"
## [17] "Fayette County Farmers Market - Saturday"
## [18] "Findlay Farmers Market"
## [19] "Food Forest"
## [20] "Franklin Park Conservatory & Botanical Gardens FM"
## [21] "Franklinton Farms"
## [22] "Franklinton Farms Market"
## [23] "Garrettsville Farmers' Market"
## [24] "Gateway 105 Farmers Market"
## [25] "Good Earth Farm Stand"
## [26] "Hamilton's Historic Farmers' Market"
## [27] "HAPI Fresh Farmers' Market"
## [28] "Hartman Heimstytte Family Farms"
## [29] "Haymaker Farmers Market"
## [30] "Healthy Harvest Mobile Market"
## [31] "Homefull Mobile Grocery"
## [32] "Howland Farmers Market"
## [33] "Idora Neighborhood Farmers Market"
## [34] "Indian Lake Farmers Market"
## [35] "Kamm's Corners Farmers Market"
## [36] "Lakewood Earth & Food Community Farmers Market"
## [37] "Lakewood Farmers Market"
## [38] "Lancaster Farmers Market"
## [39] "League Park Market Place"
## [40] "Lettuce Eat Well Farmers' Market"
## [41] "Local Matters - Veggie Van"
## [42] "Logan County Farmers Market"
## [43] "Loveland Farmers Market"
## [44] "Main Street Delaware Farmers' Market"
## [45] "Market Night on Arlington"
## [46] "Market on the Green (Whitehall)"
## [47] "Medina Square Farmers Market"
## [48] "Meigs County Farmers Market"
## [49] "Mission of Mary CSA"
## [50] "Montgomery Farmers Market"
## [51] "Mount Vernon Farmers Market"
## [52] "New Carlisle Farmers Market"
## [53] "North Market"
## [54] "North Union Farmers Market at Chagrin Falls"
## [55] "North Union Farmers Market at Cleveland Clinic"
## [56] "North Union Farmers Market at Crocker Park"
## [57] "North Union Farmers Market at Legacy Village"
## [58] "North Union Farmers Market at Playhouse Square"
## [59] "North Union Farmers Market at Shaker Square"
## [60] "North Union Farmers Market at UH"
## [61] "North Union Farmers Market at Van Aken"
## [62] "North Union Farmers Market Indoor Market at Crocker Park"
## [63] "North Union Farmers Market Indoor Winter Market at Shaker Square"
## [64] "Northside Farmers Market"
## [65] "Ohio Valley Farmers Market"
## [66] "Old Brooklyn Farmers' Market"
## [67] "Our Harvest Cooperative"
## [68] "Oxford Farmers Market Uptown"
## [69] "Pearl Market"
## [70] "Piqua Community Farmers Market"
## [71] "Prairie Township Farmers' Market"
## [72] "Reading Farmers Market"
## [73] "Reynoldsburg Farmers' Market"
## [74] "Shiloh Farmers' Market"
## [75] "Springfield Farmers Market"
## [76] "StarkFresh Mobile Market"
## [77] "Stow Community Farmers Market"
## [78] "Summit Lake Neighborhood Farmers' Market"
## [79] "Tiffin Seneca Farmers' Market"
## [80] "Toledo Farmers' Market"
## [81] "Tremont Farmers Market"
## [82] "Tuscarawas Valley Farmers Market"
## [83] "Union County Farmers Market, Marysville"
## [84] "Upper Arlington Farmers Market"
## [85] "Village Market in Slavic Village"
## [86] "Way Farms Waverly Market"
## [87] "Westerville Farmers Market"
## [88] "Westgate Farmers Market (Columbus)"
## [89] "Westgate Farmers' Market (Toledo)"
## [90] "Worthington Farmers Market"
## [91] "Wright Stop Plaza"
## [92] "Wyoming Ave. Farmers Market"
## [93] "Yellow Springs Farmers Market"
## [94] "Ω Cleveland Botanical Gardens Farm Stand Fairfax"
## [95] "Ω Cleveland Botanical Gardens Farm Stand Midtown"
## [96] "Ω Cleveland Botanical Gardens Farm Stand Slavic Village"
## [97] "Ω Clintonville Farmers Market - Wednesday"
## [98] "Ω Clintonville Farmers' Market - Winter Drive Thru"
## [99] "Ω College Hill Farmers Market"
## [100] "Ω Dublin Farmers' Market"
## [101] "Ω DUMMY MARKET"
## [102] "Ω Euclid Farmers Market"
## [103] "Ω Findlay Farm Stand at Evanston"
## [104] "Ω Findlay Farmers Market – Sunday"
## [105] "Ω Gateway 105 at NEON"
## [106] "Ω Linden Farmers Market"
## [107] "Ω Madisonville Garden Market"
## [108] "Ω Marion Ohio Market"
## [109] "Ω Nationwide Children's Hospital"
## [110] "Ω North Union Farmers Market at Cleveland Clinic Beachwood"
## [111] "Ω North Union Farmers Market at Pinecrest"
## [112] "Ω North Union Farmers Market at Public Square"
## [113] "Ω Oberlin Farmers Market"
## [114] "Ω Ohio City Farm Stand"
## [115] "Ω Pearl Market - Tuesday - OLD, DO NOT USE"
## [116] "Ω Richwood Farmers Market"
## [117] "Ω St. Clair Farmers Market"
## [118] "Ω Stark Fresh Corridor Farmers Market"
## [119] "Ω Wellington Farmers Market"
Code || Creating Filter || Two consecutive years of Transactions
## [1] "2nd Street Market"
## [2] "Athens Farmers Market"
## [3] "Barberton Farmers Market"
## [4] "Bexley Farmers Market"
## [5] "Canal Market District"
## [6] "City Fresh CSA"
## [7] "Clintonville Farmers' Market"
## [8] "Coit Road Farmers Market"
## [9] "Columbus Public Health Farmers Market"
## [10] "Countryside Farmers' Market at Highland Square"
## [11] "Countryside Farmers' Market at Howe Meadow"
## [12] "Countryside OTS Winter Farmers' Market"
## [13] "Countryside Public Market"
## [14] "Downtown Lima Farmers' Market"
## [15] "Fayette County Farmers Market - Saturday"
## [16] "Findlay Farmers Market"
## [17] "Food Forest"
## [18] "Franklin Park Conservatory & Botanical Gardens FM"
## [19] "Franklinton Farms"
## [20] "Gateway 105 Farmers Market"
## [21] "Good Earth Farm Stand"
## [22] "HAPI Fresh Farmers' Market"
## [23] "Haymaker Farmers Market"
## [24] "Healthy Harvest Mobile Market"
## [25] "Kamm's Corners Farmers Market"
## [26] "Lakewood Earth & Food Community Farmers Market"
## [27] "Lakewood Farmers Market"
## [28] "Lettuce Eat Well Farmers' Market"
## [29] "Local Matters - Veggie Van"
## [30] "Logan County Farmers Market"
## [31] "Loveland Farmers Market"
## [32] "Main Street Delaware Farmers' Market"
## [33] "Medina Square Farmers Market"
## [34] "Mission of Mary CSA"
## [35] "Montgomery Farmers Market"
## [36] "Mount Vernon Farmers Market"
## [37] "New Carlisle Farmers Market"
## [38] "North Market"
## [39] "North Union Farmers Market at Chagrin Falls"
## [40] "North Union Farmers Market at Cleveland Clinic"
## [41] "North Union Farmers Market at Crocker Park"
## [42] "North Union Farmers Market at Legacy Village"
## [43] "North Union Farmers Market at Playhouse Square"
## [44] "North Union Farmers Market at Shaker Square"
## [45] "North Union Farmers Market at UH"
## [46] "North Union Farmers Market at Van Aken"
## [47] "North Union Farmers Market Indoor Market at Crocker Park"
## [48] "North Union Farmers Market Indoor Winter Market at Shaker Square"
## [49] "Northside Farmers Market"
## [50] "Ohio Valley Farmers Market"
## [51] "Old Brooklyn Farmers' Market"
## [52] "Oxford Farmers Market Uptown"
## [53] "Pearl Market"
## [54] "Prairie Township Farmers' Market"
## [55] "Reynoldsburg Farmers' Market"
## [56] "Shiloh Farmers' Market"
## [57] "Springfield Farmers Market"
## [58] "StarkFresh Mobile Market"
## [59] "Stow Community Farmers Market"
## [60] "Summit Lake Neighborhood Farmers' Market"
## [61] "Toledo Farmers' Market"
## [62] "Tremont Farmers Market"
## [63] "Tuscarawas Valley Farmers Market"
## [64] "Upper Arlington Farmers Market"
## [65] "Village Market in Slavic Village"
## [66] "Westgate Farmers Market (Columbus)"
## [67] "Westgate Farmers' Market (Toledo)"
## [68] "Worthington Farmers Market"
## [69] "Wright Stop Plaza"
## [70] "Wyoming Ave. Farmers Market"
## [71] "Yellow Springs Farmers Market"
Creating a function to compute the p-value for continuous or categorical variables.
Mean yearly SNAP distribution, Incentive distributions, new customers, vendors and snapvendors during the study period.
## Warning in table1.formula(~SNAP.Sales + Transaction.Sales +
## SNAP.Incentives.Distributed + : Terms to the right of '|' in formula 'x' define
## table columns and are expected to be factors with meaningful labels.
| 0 (N=78) |
1 (N=70) |
P-value | |
|---|---|---|---|
| SNAP.Sales | |||
| Mean (SD) | 687 (1620) | 4150 (5260) | <0.001 |
| Median [Min, Max] | 108 [0, 10600] | 2330 [205, 28900] | |
| Transaction.Sales | |||
| Mean (SD) | 997 (1820) | 5850 (9030) | <0.001 |
| Median [Min, Max] | 335 [0, 10600] | 2500 [205, 45800] | |
| SNAP.Incentives.Distributed | |||
| Mean (SD) | 541 (1390) | 3440 (4510) | <0.001 |
| Median [Min, Max] | 86.3 [0, 9690] | 1550 [130, 27400] | |
| newcustomers | |||
| Mean (SD) | 16.8 (34.8) | 68.7 (84.0) | <0.001 |
| Median [Min, Max] | 6.00 [0, 262] | 39.5 [1.83, 482] | |
| vendors | |||
| Mean (SD) | 141 (205) | 1150 (1830) | <0.001 |
| Median [Min, Max] | 32.0 [0, 915] | 506 [16.0, 10400] | |
| snapvendors | |||
| Mean (SD) | 100 (145) | 761 (1060) | <0.001 |
| Median [Min, Max] | 26.3 [0, 824] | 411 [16.0, 5720] |
## FMmonthlyagg$SNAP.Sales
## n missing distinct Info Mean Gmd .05 .10
## 70 0 70 1 591.9 576.6 81.59 109.80
## .25 .50 .75 .90 .95
## 199.66 375.50 825.17 1375.19 1619.10
##
## lowest : 34.1111 58.8125 63.9048 75.5833 88.9412
## highest: 1502.89 1714.18 1979.95 2047.43 2794.23
## FMmonthlyagg$vendors
## n missing distinct Info Mean Gmd .05 .10
## 70 0 68 1 31.08 25.97 1.603 7.605
## .25 .50 .75 .90 .95
## 15.882 25.129 39.470 58.149 75.059
##
## lowest : 1 1.27692 1.5625 1.65217 2.41538
## highest: 69.7455 79.4058 88.0645 104.388 170.629
Results: Table 1
Mean Monthly Data in the study period
| TRUE (N=70) |
|
|---|---|
| SNAP.Sales | |
| Mean (SD) | 592 (566) |
| Median [Min, Max] | 376 [34.1, 2790] |
| Transaction.Sales | |
| Mean (SD) | 776 (866) |
| Median [Min, Max] | 441 [34.1, 4130] |
| SNAP.Incentives.Distributed | |
| Mean (SD) | 499 (508) |
| Median [Min, Max] | 314 [21.7, 2660] |
| newcustomers | |
| Mean (SD) | 11.0 (12.9) |
| Median [Min, Max] | 6.96 [0.476, 81.6] |
| vendors | |
| Mean (SD) | 31.1 (26.9) |
| Median [Min, Max] | 25.1 [1.00, 171] |
| snapvendors | |
| Mean (SD) | 21.4 (14.8) |
| Median [Min, Max] | 19.6 [1.00, 73.3] |
| pstaff | |
| 0 | 4 (5.7%) |
| 1 | 66 (94.3%) |
| FMsize | |
| Small | 25 (35.7%) |
| Medium | 29 (41.4%) |
| Large | 16 (22.9%) |
| SNAP.Salescat | |
| Small | 16 (22.9%) |
| Medium | 36 (51.4%) |
| Large | 18 (25.7%) |
| ADI | |
| Mean (SD) | 104 (24.4) |
| Median [Min, Max] | 106 [56.5, 146] |
| Urban | |
| 0 | 3 (4.3%) |
| 1 | 67 (95.7%) |
| LILATracts_1And10 | |
| 0 | 66 (94.3%) |
| 1 | 4 (5.7%) |
| LowIncomeTracts | |
| 0 | 32 (45.7%) |
| 1 | 38 (54.3%) |
| HUNVFlag | |
| 0 | 47 (67.1%) |
| 1 | 23 (32.9%) |
Outcome Variables The key outcome in this study is month-to-month growth of mean monthly SNAP dollars distribution at farmers’ markets in Ohio, from 2017 to 2019. Monthly SNAP distributions is defined as the amount of SNAP dollars distributed in a month at farmers’ market included in the study. Month-to-Month growth of monthly SNAP dollars distribution is calculated as follows:
To understand month-to-month growth of mean SNAP sales in ohio, we need to study the following time series. We hypothesize that these time series are highly correlated with the main outcome. Nontheless, there may be a relatinship between the nutrition incentive dollars distribution at FM in Ohio, and the number of new customers and total number of transactions at the FM. We expect that the knowledge among potential customers about the statewid nutrition incentive program would incentivize them to use their SNAP dollars at Farmers’ Markets, thus increasing the number of new customers and transactions.
The current outcome already includes a calendar adjustment. As the name of the outcome describes, we computed average (mean) sales per trading day in each month.
Why is this calendar adjustment needed? Some of the variation seen in seasonal data may be due to simple calendar effects. In such cases, it is usually much easier to remove the variation before doing any further analysis. For example, if you are studying the total monthly sales in a retail store, there will be variation between the months simply because of the different numbers of trading days in each month, in addition to the seasonal variation across the year. It is easy to remove this variation by computing average sales per trading day in each month, rather than total sales in the month.
Trend A trend exists when there is a long-term increase or decrease in the data. It does not have to be linear. Sometimes we will refer to a trend as “changing direction”, when it might go from an increasing trend to a decreasing trend. There is a trend in the drug sales data shown in Figure 2.2.
Seasonal A seasonal pattern occurs when a time series is affected by seasonal factors such as the time of the year or the day of the week. Seasonality is always of a fixed and known period. The monthly sales of antidiabetic drugs (Figure 2.2) shows seasonality which is induced partly by the change in the cost of the drugs at the end of the calendar year.
Cyclic A cycle occurs when the data exhibit rises and falls that are not of a fixed frequency. These fluctuations are usually due to economic conditions, and are often related to the “business cycle”. The duration of these fluctuations is usually at least 2 years.
Autocorrelation Strong autocorrelation in a lag plot typically manifests in the following ways:
Clear Linear Pattern: When there is strong autocorrelation, the points in the lag plot tend to align along a straight line, indicating a linear relationship between the current values and their lagged counterparts.
Tight Cluster: Points in a lag plot with strong autocorrelation tend to form a tight cluster around the regression line. This means that the relationship between the current values and lagged values is consistent and predictable.
Persistence of Patterns: If there are patterns in the original time series data, those patterns will be reflected in the lag plot when there is autocorrelation. For example, if there’s a repeating pattern every few time points, you’ll see a similar repeating pattern in the lag plot.
Slow Decay: In some cases of strong autocorrelation, the lag plot might show a slow decay in the pattern as the lag increases. This indicates that the effect of autocorrelation persists over several lagged values.
## # A dable: 72 x 7 [1]
## # Key: SNAP.Sales, .model [72]
## # : Ym2m = trend + remainder
## SNAP.Sales .model Month Ym2m trend remainder season_adjust
## <dbl> <chr> <int> <dbl> <dbl> <dbl> <dbl>
## 1 2172 stl 2 0 0 0 0
## 2 2293 stl 1 0 0 0 0
## 3 2304 stl 3 0 0 0 0
## 4 2521 stl 4 0 0 0 0
## 5 3377. stl 1 -63.7 -63.7 0 -63.7
## 6 3685. stl 1 0.0279 0.0279 0 0.0279
## 7 3757. stl 2 -54.4 -54.4 0 -54.4
## 8 4002. stl 2 -0.393 -0.393 0 -0.393
## 9 4357. stl 3 -48.6 -48.6 0 -48.6
## 10 4862. stl 2 16.9 16.9 0 16.9
## # ℹ 62 more rows
Box-Cox Transformation
Adding a Constant to the outcome. I looked at the most negative number (the smallest number) and I added a constant in that ammount.
## Estimated transformation parameter
## Y1
## 0.5569151
## # A dable: 72 x 7 [1M]
## # Key: .model [1]
## # : m2m = trend + season_year + remainder
## .model Month m2m trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2016 Jan 0 -10.5 -7.21 17.8 7.21
## 2 stl 2016 Feb -5.28 -9.49 4.09 0.122 -9.37
## 3 stl 2016 Mar -8.39 -8.45 21.3 -21.3 -29.7
## 4 stl 2016 Apr -41.3 -7.40 8.90 -42.8 -50.2
## 5 stl 2016 May 23.5 -6.56 7.31 22.7 16.2
## 6 stl 2016 Jun 14.7 -5.71 6.12 14.3 8.58
## 7 stl 2016 Jul 16.4 -4.87 14.4 6.87 2.00
## 8 stl 2016 Aug 16.9 -3.89 12.9 7.93 4.05
## 9 stl 2016 Sep -15.1 -2.91 -13.8 1.65 -1.26
## 10 stl 2016 Oct -5.61 -1.93 -14.0 10.3 8.38
## # ℹ 62 more rows
## # A dable: 60 x 7 [1M]
## # Key: .model [1]
## # : m2m = trend + season_year + remainder
## .model Month m2m trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2017 Jan -18.0 -1.16 -10.6 -6.22 -7.38
## 2 stl 2017 Feb 19.0 -0.709 2.33 17.3 16.6
## 3 stl 2017 Mar 3.09 -0.262 31.4 -28.1 -28.3
## 4 stl 2017 Apr 19.6 0.184 23.6 -4.15 -3.96
## 5 stl 2017 May 4.60 0.477 0.545 3.57 4.05
## 6 stl 2017 Jun 8.12 0.769 1.96 5.39 6.16
## 7 stl 2017 Jul 30.8 1.06 9.98 19.7 20.8
## 8 stl 2017 Aug 10.0 1.38 10.3 -1.62 -0.239
## 9 stl 2017 Sep -7.31 1.70 -14.4 5.39 7.09
## 10 stl 2017 Oct -11.5 2.01 -15.7 2.23 4.25
## # ℹ 50 more rows
## SNAP.Sales SNAP.Incentives.Distributed
## 369.511226 177.886920
## Transaction.Sales nsnaptx.x
## 87.190777 99.432924
## newcustomers snapvendors
## 44.671969 52.520767
## dayopen.x Mean_SNAP.Sales
## 78.107656 11.355316
## postcapTRUE pcovidTRUE
## 3.179640 5.183707
## seasonSpring seasonSummer
## 3.024323 4.568636
## seasonWinter
## 3.582480
collinearity, in statistics, correlation between predictor variables (or independent variables), such that they express a linear relationship in a regression model. When predictor variables in the same regression model are correlated, they cannot independently predict the value of the dependent variable. In other words, they explain some of the same variance in the dependent variable, which in turn reduces their statistical significance.
## m2m Ym2m SNAP.Sales
## m2m 1.00000000 0.08752219 0.1914593
## Ym2m 0.08752219 1.00000000 0.2504640
## SNAP.Sales 0.19145926 0.25046398 1.0000000
## SNAP.Incentives.Distributed 0.17184385 0.25405769 0.9913821
## Transaction.Sales 0.17081484 0.21336656 0.9826677
## nsnaptx.x 0.20152583 0.14719027 0.9665169
## newcustomers 0.29713238 0.13170546 0.9493926
## snapvendors 0.11182481 0.09423497 0.9117058
## dayopen.x 0.08968040 0.06220550 0.9111477
## Mean_SNAP.Sales 0.20830922 0.44102739 0.7639076
## SNAP.Incentives.Distributed Transaction.Sales
## m2m 0.1718438 0.1708148
## Ym2m 0.2540577 0.2133666
## SNAP.Sales 0.9913821 0.9826677
## SNAP.Incentives.Distributed 1.0000000 0.9741784
## Transaction.Sales 0.9741784 1.0000000
## nsnaptx.x 0.9551977 0.9721282
## newcustomers 0.9361921 0.9626253
## snapvendors 0.9235556 0.9238771
## dayopen.x 0.9212462 0.9244462
## Mean_SNAP.Sales 0.7370249 0.7212361
## nsnaptx.x newcustomers snapvendors dayopen.x
## m2m 0.2015258 0.2971324 0.11182481 0.0896804
## Ym2m 0.1471903 0.1317055 0.09423497 0.0622055
## SNAP.Sales 0.9665169 0.9493926 0.91170583 0.9111477
## SNAP.Incentives.Distributed 0.9551977 0.9361921 0.92355556 0.9212462
## Transaction.Sales 0.9721282 0.9626253 0.92387713 0.9244462
## nsnaptx.x 1.0000000 0.9715407 0.94186028 0.9510509
## newcustomers 0.9715407 1.0000000 0.91772518 0.9252083
## snapvendors 0.9418603 0.9177252 1.00000000 0.9860260
## dayopen.x 0.9510509 0.9252083 0.98602603 1.0000000
## Mean_SNAP.Sales 0.6625238 0.6601870 0.53375244 0.5114694
## Mean_SNAP.Sales
## m2m 0.2083092
## Ym2m 0.4410274
## SNAP.Sales 0.7639076
## SNAP.Incentives.Distributed 0.7370249
## Transaction.Sales 0.7212361
## nsnaptx.x 0.6625238
## newcustomers 0.6601870
## snapvendors 0.5337524
## dayopen.x 0.5114694
## Mean_SNAP.Sales 1.0000000
Autocorrelation analysis is an important step in the Exploratory Data Analysis of time series forecasting. The autocorrelation analysis helps detect patterns and check for randomness. It’s especially important when you intend to use an autoregressive–moving-average (ARMA) model for forecasting because it helps to determine its parameters. The analysis involves looking at the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots.
The lag plot is used to answer the following questions:
Distribution of Model: Distribution of model here means deciding what is the shape of data on the basis of the lag plot. Below are some examples of lag plot and their original plot: If the lag plot is linear, then the underlying structure is of the autoregressive model. If the lag plot is of elliptical shape, then the underlying structure represents a continuous periodic function such as sine, cosine, etc.
Outliers: Outliers are a set of data points that represent the extreme values in the distribution
Randomness in data: The lag plot is also useful for checking whether the given dataset is random or not. If there is randomness in the data then it will be reflected in the lag plot, if there is no pattern in the lag plot.
Seasonality: If there is seasonality in the plot then, it will give a periodic lag plot.
Autocorrelation: If the lag plot gives a linear plot, then it means the autocorrelation is present in the data, whether there is positive autocorrelation or negative that depends upon the slope of the line of the dataset. If more data is concentrated on the diagonal in lag plot, it means there is a strong autocorrelation.
## # A tsibble: 18 x 2 [1M]
## lag acf
## <cf_lag> <dbl>
## 1 1M 0.207
## 2 2M -0.0180
## 3 3M -0.0798
## 4 4M -0.240
## 5 5M -0.0786
## 6 6M -0.234
## 7 7M -0.0514
## 8 8M -0.0494
## 9 9M -0.0579
## 10 10M 0.0129
## 11 11M 0.218
## 12 12M 0.186
## 13 13M 0.180
## 14 14M 0.118
## 15 15M -0.0965
## 16 16M -0.0770
## 17 17M -0.194
## 18 18M -0.200
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
SARIMA Models Manually Chosen SARIMA(12,1,0) OR ARIMA(0,1,1)
This outcomes describes the total mean monthly distributions of SNAP dollars at FMs in Ohio.
To understand month-to-month growth of mean SNAP sales in Ohio, we need to study the following time series. We hypothesize that these time series are highly correlated with the main outcome. Nonetheless, there may be a relationship between the nutrition incentive dollars distribution at FM in Ohio, and the number of new customers and total number of transactions at the FM. We expect that the knowledge among potential customers about the statewid nutrition incentive program would incentivize them to use their SNAP dollars at Farmers’ Markets, thus increasing the number of new customers and transactions.
The current outcome already includes a calendar adjustment. As the name of the outcome describes, we computed average (mean) sales per trading day in each month.
Why is this calendar adjustment needed? Some of the variation seen in seasonal data may be due to simple calendar effects. In such cases, it is usually much easier to remove the variation before doing any further analysis. For example, if you are studying the total monthly sales in a retail store, there will be variation between the months simply because of the different numbers of trading days in each month, in addition to the seasonal variation across the year. It is easy to remove this variation by computing average sales per trading day in each month, rather than total sales in the month.
Box-Cox Transformation
Adding a Constant to the outcome. I looked at the most negative number (the smallest number) and I added a constant in that ammount.
## Estimated transformation parameter
## Y1
## 0.7450515
## # A dable: 72 x 7 [1M]
## # Key: .model [1]
## # : Mean_SNAP.Incentives.Distributed = trend + season_year + remainder
## .model Month Mean_SNAP.Incentives.Distributed trend season_year remainder
## <chr> <mth> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2016 Jan 79.9 78.5 -21.3 22.8
## 2 stl 2016 Feb 73.5 75.7 -21.8 19.6
## 3 stl 2016 Mar 66.2 72.9 -17.1 10.4
## 4 stl 2016 Apr 41.1 70.1 -6.74 -22.2
## 5 stl 2016 May 45.3 67.4 1.69 -23.8
## 6 stl 2016 Jun 61.2 64.7 18.1 -21.5
## 7 stl 2016 Jul 77.2 62.0 20.9 -5.68
## 8 stl 2016 Aug 87 59.4 34.1 -6.48
## 9 stl 2016 Sep 74.9 56.7 22.0 -3.83
## 10 stl 2016 Oct 72.0 54.0 10.1 7.85
## # ℹ 62 more rows
## # ℹ 1 more variable: season_adjust <dbl>
## # A dable: 60 x 7 [1M]
## # Key: .model [1]
## # : Mean_SNAP.Incentives.Distributed = trend + season_year + remainder
## .model Month Mean_SNAP.Incentives.Distributed trend season_year remainder
## <chr> <mth> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2017 Jan 25.1 43.6 -29.3 10.8
## 2 stl 2017 Feb 27.8 44.5 -30.0 13.3
## 3 stl 2017 Mar 32.6 45.4 -22.2 9.42
## 4 stl 2017 Apr 38.8 46.2 1.53 -8.98
## 5 stl 2017 May 42.6 47.2 10.6 -15.2
## 6 stl 2017 Jun 53.9 48.1 27.8 -22.0
## 7 stl 2017 Jul 70.0 49.0 22.9 -1.88
## 8 stl 2017 Aug 79.5 49.8 36.8 -7.17
## 9 stl 2017 Sep 71.5 50.6 23.7 -2.76
## 10 stl 2017 Oct 65.2 51.4 8.56 5.19
## # ℹ 50 more rows
## # ℹ 1 more variable: season_adjust <dbl>
Autocorrelation analysis is an important step in the Exploratory Data Analysis of time series forecasting. The autocorrelation analysis helps detect patterns and check for randomness. It’s especially important when you intend to use an autoregressive–moving-average (ARMA) model for forecasting because it helps to determine its parameters. The analysis involves looking at the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots.
The lag plot is used to answer the following questions:
Distribution of Model: Distribution of model here means deciding what is the shape of data on the basis of the lag plot. Below are some examples of lag plot and their original plot: If the lag plot is linear, then the underlying structure is of the autoregressive model. If the lag plot is of elliptical shape, then the underlying structure represents a continuous periodic function such as sine, cosine, etc.
Outliers: Outliers are a set of data points that represent the extreme values in the distribution
Randomness in data: The lag plot is also useful for checking whether the given dataset is random or not. If there is randomness in the data then it will be reflected in the lag plot, if there is no pattern in the lag plot.
Seasonality: If there is seasonality in the plot then, it will give a periodic lag plot.
Autocorrelation: If the lag plot gives a linear plot, then it means the autocorrelation is present in the data, whether there is positive autocorrelation or negative that depends upon the slope of the line of the dataset. If more data is concentrated on the diagonal in lag plot, it means there is a strong autocorrelation.
## # A tsibble: 18 x 2 [1M]
## lag acf
## <cf_lag> <dbl>
## 1 1M 0.862
## 2 2M 0.727
## 3 3M 0.531
## 4 4M 0.379
## 5 5M 0.279
## 6 6M 0.180
## 7 7M 0.172
## 8 8M 0.213
## 9 9M 0.307
## 10 10M 0.403
## 11 11M 0.467
## 12 12M 0.481
## 13 13M 0.457
## 14 14M 0.378
## 15 15M 0.259
## 16 16M 0.147
## 17 17M 0.0278
## 18 18M -0.0398
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
This outcomes describes the total mean monthly distributions of SNAP dollars at FMs in Ohio.
To understand month-to-month growth of mean SNAP sales in Ohio, we need to study the following time series. We hypothesize that these time series are highly correlated with the main outcome. Nonetheless, there may be a relationship between the nutrition incentive dollars distribution at FM in Ohio, and the number of new customers and total number of transactions at the FM. We expect that the knowledge among potential customers about the statewid nutrition incentive program would incentivize them to use their SNAP dollars at Farmers’ Markets, thus increasing the number of new customers and transactions.
The current outcome already includes a calendar adjustment. As the name of the outcome describes, we computed average (mean) sales per trading day in each month.
Why is this calendar adjustment needed? Some of the variation seen in seasonal data may be due to simple calendar effects. In such cases, it is usually much easier to remove the variation before doing any further analysis. For example, if you are studying the total monthly sales in a retail store, there will be variation between the months simply because of the different numbers of trading days in each month, in addition to the seasonal variation across the year. It is easy to remove this variation by computing average sales per trading day in each month, rather than total sales in the month.
Box-Cox Transformation
Adding a Constant to the outcome. I looked at the most negative number (the smallest number) and I added a constant in that ammount.
## Estimated transformation parameter
## Y1
## -0.09741612
## # A dable: 72 x 7 [1M]
## # Key: .model [1]
## # : Mean_SNAP.Sales = trend + season_year + remainder
## .model Month Mean_SNAP.Sales trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2016 Jan 121. 114. -22.8 29.8 143.
## 2 stl 2016 Feb 114. 110. -22.0 26.6 136.
## 3 stl 2016 Mar 105. 106. -9.35 8.23 114.
## 4 stl 2016 Apr 61.5 102. 1.09 -41.5 60.4
## 5 stl 2016 May 75.9 98.1 2.60 -24.8 73.3
## 6 stl 2016 Jun 87.1 94.3 11.2 -18.4 75.9
## 7 stl 2016 Jul 101. 90.5 17.7 -6.86 83.7
## 8 stl 2016 Aug 119. 86.8 33.2 -1.51 85.3
## 9 stl 2016 Sep 101. 83.1 18.7 -1.18 81.9
## 10 stl 2016 Oct 95.0 79.4 7.72 7.93 87.3
## # ℹ 62 more rows
## # A dable: 60 x 7 [1M]
## # Key: .model [1]
## # : Mean_SNAP.Sales = trend + season_year + remainder
## .model Month Mean_SNAP.Sales trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2017 Jan 43.9 66.1 -33.2 11.0 77.0
## 2 stl 2017 Feb 52.2 67.0 -33.0 18.2 85.2
## 3 stl 2017 Mar 53.8 67.9 -12.7 -1.48 66.5
## 4 stl 2017 Apr 64.3 68.9 15.9 -20.4 48.5
## 5 stl 2017 May 67.3 69.7 12.2 -14.5 55.1
## 6 stl 2017 Jun 72.8 70.5 19.4 -17.1 53.4
## 7 stl 2017 Jul 95.2 71.3 20.2 3.71 75.0
## 8 stl 2017 Aug 105. 71.9 34.3 -1.48 70.4
## 9 stl 2017 Sep 97.0 72.5 18.5 6.00 78.5
## 10 stl 2017 Oct 85.9 73.1 6.36 6.39 79.5
## # ℹ 50 more rows
Autocorrelation analysis is an important step in the Exploratory Data Analysis of time series forecasting. The autocorrelation analysis helps detect patterns and check for randomness. It’s especially important when you intend to use an autoregressive–moving-average (ARMA) model for forecasting because it helps to determine its parameters. The analysis involves looking at the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots.
The lag plot is used to answer the following questions:
Distribution of Model: Distribution of model here means deciding what is the shape of data on the basis of the lag plot. Below are some examples of lag plot and their original plot: If the lag plot is linear, then the underlying structure is of the autoregressive model. If the lag plot is of elliptical shape, then the underlying structure represents a continuous periodic function such as sine, cosine, etc.
Outliers: Outliers are a set of data points that represent the extreme values in the distribution
Randomness in data: The lag plot is also useful for checking whether the given dataset is random or not. If there is randomness in the data then it will be reflected in the lag plot, if there is no pattern in the lag plot.
Seasonality: If there is seasonality in the plot then, it will give a periodic lag plot.
Autocorrelation: If the lag plot gives a linear plot, then it means the autocorrelation is present in the data, whether there is positive autocorrelation or negative that depends upon the slope of the line of the dataset. If more data is concentrated on the diagonal in lag plot, it means there is a strong autocorrelation.
## # A tsibble: 18 x 2 [1M]
## lag acf
## <cf_lag> <dbl>
## 1 1M 0.864
## 2 2M 0.731
## 3 3M 0.555
## 4 4M 0.425
## 5 5M 0.355
## 6 6M 0.282
## 7 7M 0.263
## 8 8M 0.254
## 9 9M 0.288
## 10 10M 0.333
## 11 11M 0.389
## 12 12M 0.404
## 13 13M 0.400
## 14 14M 0.342
## 15 15M 0.253
## 16 16M 0.171
## 17 17M 0.0662
## 18 18M 0.00976
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
This outcomes describes the total mean number of monthly new customers at FMs in Ohio.
To understand month-to-month growth of mean SNAP sales in Ohio, we need to study the following time series. We hypothesize that these time series are highly correlated with the main outcome. Nonetheless, there may be a relationship between the nutrition incentive dollars distribution at FM in Ohio, and the number of new customers and total number of transactions at the FM. We expect that the knowledge among potential customers about the statewid nutrition incentive program would incentivize them to use their SNAP dollars at Farmers’ Markets, thus increasing the number of new customers and transactions.
The current outcome already includes a calendar adjustment. As the name of the outcome describes, we computed average (mean) sales per trading day in each month.
Why is this calendar adjustment needed? Some of the variation seen in seasonal data may be due to simple calendar effects. In such cases, it is usually much easier to remove the variation before doing any further analysis. For example, if you are studying the total monthly sales in a retail store, there will be variation between the months simply because of the different numbers of trading days in each month, in addition to the seasonal variation across the year. It is easy to remove this variation by computing average sales per trading day in each month, rather than total sales in the month.
Box-Cox Transformation
Adding a Constant to the outcome. I looked at the most negative number (the smallest number) and I added a constant in that ammount.
## Estimated transformation parameter
## Y1
## 0.7987282
## # A dable: 72 x 7 [1M]
## # Key: .model [1]
## # : Mean_newcustomers = trend + season_year + remainder
## .model Month Mean_newcustomers trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2016 Jan 2.05 2.10 -0.713 0.663 2.77
## 2 stl 2016 Feb 1.42 2.03 -0.820 0.211 2.24
## 3 stl 2016 Mar 0.773 1.96 -0.625 -0.559 1.40
## 4 stl 2016 Apr 0.976 1.88 -0.286 -0.621 1.26
## 5 stl 2016 May 2.58 1.81 0.223 0.538 2.35
## 6 stl 2016 Jun 2.34 1.75 0.541 0.0567 1.80
## 7 stl 2016 Jul 2.54 1.68 1.06 -0.194 1.48
## 8 stl 2016 Aug 2.82 1.61 1.44 -0.234 1.38
## 9 stl 2016 Sep 2.06 1.55 0.620 -0.112 1.44
## 10 stl 2016 Oct 1.20 1.49 -0.0381 -0.251 1.24
## # ℹ 62 more rows
## # A dable: 60 x 7 [1M]
## # Key: .model [1]
## # : Mean_newcustomers = trend + season_year + remainder
## .model Month Mean_newcustomers trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2017 Jan 0.481 1.37 -0.921 0.0279 1.40
## 2 stl 2017 Feb 0.597 1.39 -0.921 0.133 1.52
## 3 stl 2017 Mar 0.691 1.40 -0.465 -0.241 1.16
## 4 stl 2017 Apr 1.16 1.41 -0.0587 -0.191 1.22
## 5 stl 2017 May 1.27 1.41 0.0740 -0.214 1.20
## 6 stl 2017 Jun 2.09 1.42 0.540 0.133 1.55
## 7 stl 2017 Jul 2.69 1.43 1.11 0.153 1.58
## 8 stl 2017 Aug 2.89 1.43 1.49 -0.0377 1.39
## 9 stl 2017 Sep 2.22 1.43 0.637 0.147 1.58
## 10 stl 2017 Oct 1.93 1.44 0.00710 0.482 1.92
## # ℹ 50 more rows
Autocorrelation analysis is an important step in the Exploratory Data Analysis of time series forecasting. The autocorrelation analysis helps detect patterns and check for randomness. It’s especially important when you intend to use an autoregressive–moving-average (ARMA) model for forecasting because it helps to determine its parameters. The analysis involves looking at the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots.
The lag plot is used to answer the following questions:
Distribution of Model: Distribution of model here means deciding what is the shape of data on the basis of the lag plot. Below are some examples of lag plot and their original plot: If the lag plot is linear, then the underlying structure is of the autoregressive model. If the lag plot is of elliptical shape, then the underlying structure represents a continuous periodic function such as sine, cosine, etc.
Outliers: Outliers are a set of data points that represent the extreme values in the distribution
Randomness in data: The lag plot is also useful for checking whether the given dataset is random or not. If there is randomness in the data then it will be reflected in the lag plot, if there is no pattern in the lag plot.
Seasonality: If there is seasonality in the plot then, it will give a periodic lag plot.
Autocorrelation: If the lag plot gives a linear plot, then it means the autocorrelation is present in the data, whether there is positive autocorrelation or negative that depends upon the slope of the line of the dataset. If more data is concentrated on the diagonal in lag plot, it means there is a strong autocorrelation.
## # A tsibble: 18 x 2 [1M]
## lag acf
## <cf_lag> <dbl>
## 1 1M 0.764
## 2 2M 0.432
## 3 3M 0.0885
## 4 4M -0.233
## 5 5M -0.438
## 6 6M -0.508
## 7 7M -0.390
## 8 8M -0.212
## 9 9M 0.0537
## 10 10M 0.332
## 11 11M 0.549
## 12 12M 0.635
## 13 13M 0.524
## 14 14M 0.277
## 15 15M -0.0117
## 16 16M -0.267
## 17 17M -0.425
## 18 18M -0.476
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
This outcomes describes the total mean number of monthly transactions at FMs in Ohio.
To understand month-to-month growth of mean SNAP sales in Ohio, we need to study the following time series. We hypothesize that these time series are highly correlated with the main outcome. Nonetheless, there may be a relationship between the nutrition incentive dollars distribution at FM in Ohio, and the number of new customers and total number of transactions at the FM. We expect that the knowledge among potential customers about the statewid nutrition incentive program would incentivize them to use their SNAP dollars at Farmers’ Markets, thus increasing the number of new customers and transactions.
The current outcome already includes a calendar adjustment. As the name of the outcome describes, we computed average (mean) sales per trading day in each month.
Why is this calendar adjustment needed? Some of the variation seen in seasonal data may be due to simple calendar effects. In such cases, it is usually much easier to remove the variation before doing any further analysis. For example, if you are studying the total monthly sales in a retail store, there will be variation between the months simply because of the different numbers of trading days in each month, in addition to the seasonal variation across the year. It is easy to remove this variation by computing average sales per trading day in each month, rather than total sales in the month.
Box-Cox Transformation
Adding a Constant to the outcome. I looked at the most negative number (the smallest number) and I added a constant in that ammount.
## Estimated transformation parameter
## Y1
## -0.4896065
## # A dable: 72 x 7 [1M]
## # Key: .model [1]
## # : Mean_Transaction.Sales = trend + season_year + remainder
## .model Month Mean_Transaction.Sales trend season_year remainder
## <chr> <mth> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2016 Jan 312. 296. -27.6 44.1
## 2 stl 2016 Feb 295. 281. -26.9 41.4
## 3 stl 2016 Mar 328. 266. -2.47 64.4
## 4 stl 2016 Apr 185. 251. 2.19 -68.6
## 5 stl 2016 May 212. 237. 14.8 -39.9
## 6 stl 2016 Jun 153. 223. -0.394 -69.5
## 7 stl 2016 Jul 204. 209. 11.0 -15.5
## 8 stl 2016 Aug 218. 195. 28.9 -6.01
## 9 stl 2016 Sep 184. 181. 18.4 -15.0
## 10 stl 2016 Oct 180. 167. 3.08 9.76
## # ℹ 62 more rows
## # ℹ 1 more variable: season_adjust <dbl>
## # A dable: 60 x 7 [1M]
## # Key: .model [1]
## # : Mean_newcustomers = trend + season_year + remainder
## .model Month Mean_newcustomers trend season_year remainder season_adjust
## <chr> <mth> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 stl 2017 Jan 0.481 1.37 -0.921 0.0279 1.40
## 2 stl 2017 Feb 0.597 1.39 -0.921 0.133 1.52
## 3 stl 2017 Mar 0.691 1.40 -0.465 -0.241 1.16
## 4 stl 2017 Apr 1.16 1.41 -0.0587 -0.191 1.22
## 5 stl 2017 May 1.27 1.41 0.0740 -0.214 1.20
## 6 stl 2017 Jun 2.09 1.42 0.540 0.133 1.55
## 7 stl 2017 Jul 2.69 1.43 1.11 0.153 1.58
## 8 stl 2017 Aug 2.89 1.43 1.49 -0.0377 1.39
## 9 stl 2017 Sep 2.22 1.43 0.637 0.147 1.58
## 10 stl 2017 Oct 1.93 1.44 0.00710 0.482 1.92
## # ℹ 50 more rows
Autocorrelation analysis is an important step in the Exploratory Data Analysis of time series forecasting. The autocorrelation analysis helps detect patterns and check for randomness. It’s especially important when you intend to use an autoregressive–moving-average (ARMA) model for forecasting because it helps to determine its parameters. The analysis involves looking at the Autocorrelation Function (ACF) and Partial Autocorrelation Function (PACF) plots.
The lag plot is used to answer the following questions:
Distribution of Model: Distribution of model here means deciding what is the shape of data on the basis of the lag plot. Below are some examples of lag plot and their original plot: If the lag plot is linear, then the underlying structure is of the autoregressive model. If the lag plot is of elliptical shape, then the underlying structure represents a continuous periodic function such as sine, cosine, etc.
Outliers: Outliers are a set of data points that represent the extreme values in the distribution
Randomness in data: The lag plot is also useful for checking whether the given dataset is random or not. If there is randomness in the data then it will be reflected in the lag plot, if there is no pattern in the lag plot.
Seasonality: If there is seasonality in the plot then, it will give a periodic lag plot.
Autocorrelation: If the lag plot gives a linear plot, then it means the autocorrelation is present in the data, whether there is positive autocorrelation or negative that depends upon the slope of the line of the dataset. If more data is concentrated on the diagonal in lag plot, it means there is a strong autocorrelation.
## # A tsibble: 18 x 2 [1M]
## lag acf
## <cf_lag> <dbl>
## 1 1M 0.764
## 2 2M 0.432
## 3 3M 0.0885
## 4 4M -0.233
## 5 5M -0.438
## 6 6M -0.508
## 7 7M -0.390
## 8 8M -0.212
## 9 9M 0.0537
## 10 10M 0.332
## 11 11M 0.549
## 12 12M 0.635
## 13 13M 0.524
## 14 14M 0.277
## 15 15M -0.0117
## 16 16M -0.267
## 17 17M -0.425
## 18 18M -0.476
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
NOTE: This is not a Stationary Time Series. A stationary time series is one whose properties do not depend on the time at which the series is observed. Thus, time series with trends, or with seasonality, are not stationary — the trend and seasonality will affect the value of the time series at different times.
The ACF plot can provide answers to the following questions: Is the observed time series white noise/random? Is an observation related to an adjacent observation, an observation twice-removed, and so on? Can the observed time series be modeled with an MA model? If yes, what is the order?
The dashed blue lines indicate whether the correlations are significantly different from zero (as explained in Section 2.9).
Transformation?
An alternative to using seasonal dummy variables, especially for long seasonal periods, is to use Fourier terms. Jean-Baptiste Fourier was a French mathematician, born in the 1700s, who showed that a series of sine and cosine terms of the right frequencies can approximate any periodic function. We can use them for seasonal patterns.
With Fourier terms, we often need fewer predictors than with dummy variables, especially when m is large. This makes them useful for weekly data, for example, where m ≈ 52 . For short seasonal periods (e.g., quarterly data), there is little advantage in using Fourier terms over seasonal dummy variables. These Fourier terms are produced using the fourier() function. For example, the Australian beer data can be modelled like this.
## Series: m2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -40.096 -10.291 -2.188 8.720 77.065
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 40.9078407 39.2942529 1.041 0.303061
## SNAP.Incentives.Distributed 0.0004207 0.0006674 0.630 0.531441
## Mean_newcustomers 45.4230574 10.8739985 4.177 0.000124 ***
## Mean_snapvendors -1.5024274 1.2236959 -1.228 0.225517
## dayopen.x -0.2396670 0.1181879 -2.028 0.048146 *
## Mean_Transaction.Sales -0.1924585 0.1273438 -1.511 0.137261
## postcapTRUE 15.1864944 8.5060576 1.785 0.080520 .
## pcovidTRUE -5.7331911 9.4637037 -0.606 0.547496
## nsnaptx.x -0.0175939 0.0176808 -0.995 0.324687
## seasonSpring 13.7256812 9.8539320 1.393 0.170064
## seasonSummer 5.0287181 10.9166859 0.461 0.647134
## seasonWinter 3.7903668 10.8749190 0.349 0.728957
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.4 on 48 degrees of freedom
## Multiple R-squared: 0.571, Adjusted R-squared: 0.4727
## F-statistic: 5.808 on 11 and 48 DF, p-value: 7.0199e-06
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.473 518. 368. 376. 396.
| Month | m2m | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | -18.003 | -2.938 | -15.065 |
| 2017 Feb | 18.957 | 0.726 | 18.231 |
| 2017 Mar | 3.085 | 12.339 | -9.253 |
| 2017 Apr | 19.635 | 19.720 | -0.085 |
| 2017 May | 4.596 | 11.283 | -6.687 |
| 2017 Jun | 8.120 | 18.226 | -10.106 |
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## Warning: Removed 12 rows containing non-finite values (`stat_bin()`).
Should I be Looking at Cook’s Distance for “Outliers” or points that are out of the ordinary?
## Best Subsets Regression
## ----------------------------------------------------------------------------------------------------------------------------------------------
## Model Index Predictors
## ----------------------------------------------------------------------------------------------------------------------------------------------
## 1 season
## 2 nsnaptx.x Mean_newcustomers
## 3 nsnaptx.x Mean_newcustomers season
## 4 nsnaptx.x Mean_newcustomers Mean_snapvendors season
## 5 nsnaptx.x Mean_newcustomers Mean_snapvendors postcap season
## 6 Mean_newcustomers Mean_snapvendors dayopen.x postcap season Mean_Transaction.Sales
## 7 Mean_newcustomers Mean_snapvendors dayopen.x postcap pcovid season Mean_Transaction.Sales
## 8 SNAP.Incentives.Distributed Mean_newcustomers Mean_snapvendors dayopen.x postcap pcovid season Mean_Transaction.Sales
## 9 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers Mean_snapvendors dayopen.x postcap pcovid season Mean_Transaction.Sales
## ----------------------------------------------------------------------------------------------------------------------------------------------
##
## Subsets Regression Summary
## --------------------------------------------------------------------------------------------------------------------------------------
## Adj. Pred
## Model R-Square R-Square R-Square C(p) AIC SBIC SBC MSEP FPE HSP APC
## --------------------------------------------------------------------------------------------------------------------------------------
## 1 0.2381 0.2045 0.1459 34.3503 661.9081 452.2190 673.2915 37095.5002 545.0950 7.6864 0.8054
## 2 0.3402 0.3210 0.2459 22.6434 649.5560 444.0318 658.6626 32600.0672 471.5402 6.6570 0.7172
## 3 0.3967 0.3510 0.2668 17.0497 649.1078 439.8624 665.0444 30252.2590 456.7530 6.4584 0.6743
## 4 0.4783 0.4302 0.3296 8.0835 640.6407 432.5855 658.8540 26555.3884 406.3058 5.7564 0.5995
## 5 0.5131 0.4599 0.3544 5.4088 637.6705 430.5323 658.1605 25165.3920 390.1313 5.5403 0.5754
## 6 0.5477 0.4903 0.3637 2.7614 634.3640 428.5579 657.1307 23742.6367 372.8847 5.3101 0.5497
## 7 0.5518 0.4867 0.3534 4.2127 635.7109 430.4393 660.7542 23901.7078 380.2304 5.4319 0.5603
## 8 0.5532 0.4800 0.339 6.0190 637.4789 432.6652 664.7989 24209.0813 390.0356 5.5919 0.5744
## 9 0.5534 0.4715 0.3028 8.0000 639.4560 435.0489 669.0527 24598.1496 401.3045 5.7765 0.5907
## --------------------------------------------------------------------------------------------------------------------------------------
## AIC: Akaike Information Criteria
## SBIC: Sawa's Bayesian Information Criteria
## SBC: Schwarz Bayesian Criteria
## MSEP: Estimated error of prediction, assuming multivariate normality
## FPE: Final Prediction Error
## HSP: Hocking's Sp
## APC: Amemiya Prediction Criteria
Mean_newcustomers dayopen.x Mean_Transaction.Sales postcap season
## Series: m2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -44.804 -9.456 -2.340 8.167 85.156
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.019e+01 1.553e+01 -1.300 0.199
## SNAP.Incentives.Distributed -3.559e-04 5.180e-04 -0.687 0.495
## Mean_newcustomers 3.528e+01 8.065e+00 4.374 6.04e-05 ***
## dayopen.x -1.194e-01 1.066e-01 -1.119 0.268
## nsnaptx.x -1.270e-02 1.710e-02 -0.743 0.461
## postcapTRUE 6.538e+00 7.495e+00 0.872 0.387
## seasonSpring 1.389e+01 9.535e+00 1.457 0.151
## seasonSummer 1.193e+01 1.030e+01 1.158 0.252
## seasonWinter 4.395e+00 1.049e+01 0.419 0.677
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.78 on 51 degrees of freedom
## Multiple R-squared: 0.5259, Adjusted R-squared: 0.4516
## F-statistic: 7.072 on 8 and 51 DF, p-value: 3.0283e-06
## Series: m2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -53.0687 -10.2003 -0.1241 5.8130 110.1935
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -33.6144 10.9745 -3.063 0.00341 **
## Mean_newcustomers 13.8661 5.3677 2.583 0.01253 *
## postcapTRUE -0.9391 6.8240 -0.138 0.89105
## seasonSpring 37.5223 8.2575 4.544 3.14e-05 ***
## seasonSummer 7.7781 9.7816 0.795 0.42999
## seasonWinter 18.5755 9.7871 1.898 0.06305 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 22.36 on 54 degrees of freedom
## Multiple R-squared: 0.3588, Adjusted R-squared: 0.2995
## F-statistic: 6.045 on 5 and 54 DF, p-value: 0.00016368
## Series: m2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -51.7319 -9.7793 -0.7156 8.1387 117.5245
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -16.43187 9.08858 -1.808 0.076080 .
## Mean_SNAP.Incentives.Distributed 0.05307 0.06547 0.811 0.421115
## seasonSpring 35.83448 8.63706 4.149 0.000117 ***
## seasonSummer 20.62033 8.64639 2.385 0.020560 *
## seasonWinter 6.97898 9.13824 0.764 0.448303
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 23.4 on 55 degrees of freedom
## Multiple R-squared: 0.2848, Adjusted R-squared: 0.2328
## F-statistic: 5.475 on 4 and 55 DF, p-value: 0.00087652
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.452 482. 368. 373. 389.
| Month | m2m | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | -18.003 | -11.794 | -6.208 |
| 2017 Feb | 18.957 | -7.841 | 26.797 |
| 2017 Mar | 3.085 | 3.130 | -0.044 |
| 2017 Apr | 19.635 | 18.624 | 1.011 |
| 2017 May | 4.596 | 12.835 | -8.239 |
| 2017 Jun | 8.120 | 19.513 | -11.393 |
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## Warning: Removed 12 rows containing non-finite values (`stat_bin()`).
Mean_newcustomers dayopen.x Mean_Transaction.Sales postcap season
## Series: m2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -49.849 -10.745 -0.919 9.106 86.805
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -19.572454 14.680277 -1.333 0.1882
## Mean_newcustomers 35.691351 8.003751 4.459 4.31e-05 ***
## snapvendors -0.003430 0.003583 -0.957 0.3427
## nsnaptx.x -0.021967 0.009857 -2.229 0.0301 *
## seasonSpring 15.400343 8.893644 1.732 0.0892 .
## seasonSummer 8.495350 9.074267 0.936 0.3534
## seasonWinter 6.668565 9.439458 0.706 0.4830
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 19.51 on 53 degrees of freedom
## Multiple R-squared: 0.5209, Adjusted R-squared: 0.4666
## F-statistic: 9.603 on 6 and 53 DF, p-value: 3.8688e-07
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.467 444. 365. 368. 382.
| Month | m2m | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | -18.003 | -6.342 | -11.661 |
| 2017 Feb | 18.957 | -3.128 | 22.085 |
| 2017 Mar | 3.085 | 7.573 | -4.488 |
| 2017 Apr | 19.635 | 21.204 | -1.568 |
| 2017 May | 4.596 | 17.192 | -12.596 |
| 2017 Jun | 8.120 | 22.913 | -14.793 |
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
## Warning: Removed 12 rows containing non-finite values (`stat_bin()`).
## Best Subsets Regression
## ----------------------------------------------------------------------------------------------------------------------------------------------
## Model Index Predictors
## ----------------------------------------------------------------------------------------------------------------------------------------------
## 1 Mean_Transaction.Sales
## 2 nsnaptx.x Mean_Transaction.Sales
## 3 SNAP.Incentives.Distributed nsnaptx.x Mean_Transaction.Sales
## 4 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers Mean_Transaction.Sales
## 5 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers season Mean_Transaction.Sales
## 6 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers postcap season Mean_Transaction.Sales
## 7 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers dayopen.x pcovid season Mean_Transaction.Sales
## 8 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers Mean_snapvendors dayopen.x pcovid season Mean_Transaction.Sales
## 9 SNAP.Incentives.Distributed nsnaptx.x Mean_newcustomers Mean_snapvendors dayopen.x postcap pcovid season Mean_Transaction.Sales
## ----------------------------------------------------------------------------------------------------------------------------------------------
##
## Subsets Regression Summary
## ----------------------------------------------------------------------------------------------------------------------------------------
## Adj. Pred
## Model R-Square R-Square R-Square C(p) AIC SBIC SBC MSEP FPE HSP APC
## ----------------------------------------------------------------------------------------------------------------------------------------
## 1 0.3762 0.3654 0.2947 7.7518 638.6216 468.1067 644.9046 137872.1426 2374.4184 40.3127 0.6668
## 2 0.4502 0.4310 0.3588 2.1853 633.0411 463.1666 641.4185 123678.3277 2163.6624 36.7970 0.6076
## 3 0.4826 0.4549 0.2921 0.8757 631.3984 462.1673 641.8701 118509.2047 2105.4692 35.8887 0.5913
## 4 0.4983 0.4618 0.2885 1.2776 631.5571 462.9276 644.1231 117055.8848 2111.4454 36.0931 0.5930
## 5 0.5144 0.4490 0.2427 1.6289 635.5962 463.7439 654.4453 115429.7137 2194.7055 37.6450 0.5935
## 6 0.5213 0.4462 0.2047 2.9255 636.7397 465.5336 657.6831 115982.0523 2239.4477 38.5668 0.6052
## 7 0.5275 0.4424 0.175 4.2921 637.9579 467.4467 660.9957 116725.2959 2288.3173 39.5903 0.6179
## 8 0.5289 0.4328 0.1511 6.1465 639.7766 469.8143 664.9088 118700.7246 2362.2103 41.0819 0.6374
## 9 0.5303 0.4227 0.11 8.0000 641.5938 472.1962 668.8203 120754.7451 2438.9296 42.6635 0.6575
## ----------------------------------------------------------------------------------------------------------------------------------------
## AIC: Akaike Information Criteria
## SBIC: Sawa's Bayesian Information Criteria
## SBC: Schwarz Bayesian Criteria
## MSEP: Estimated error of prediction, assuming multivariate normality
## FPE: Final Prediction Error
## HSP: Hocking's Sp
## APC: Amemiya Prediction Criteria
## Series: Ym2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -98.126 -26.623 -7.459 10.023 185.598
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.417e+01 2.646e+01 -1.670 0.101
## SNAP.Incentives.Distributed 1.187e-03 7.613e-04 1.559 0.125
## Mean_newcustomers 2.247e+01 1.879e+01 1.196 0.237
## seasonSpring 3.177e+01 2.202e+01 1.443 0.155
## seasonSummer -3.533e+01 2.428e+01 -1.455 0.151
## seasonWinter 3.649e+01 2.435e+01 1.498 0.140
##
## Residual standard error: 55.67 on 54 degrees of freedom
## Multiple R-squared: 0.2166, Adjusted R-squared: 0.1441
## F-statistic: 2.986 on 5 and 54 DF, p-value: 0.018835
## Series: Ym2m
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -122.895 -18.753 -0.717 23.016 118.631
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.170e+00 2.268e+01 -0.316 0.753145
## SNAP.Incentives.Distributed 5.142e-03 9.702e-04 5.300 2.29e-06 ***
## Mean_newcustomers 6.701e+01 1.748e+01 3.834 0.000336 ***
## nsnaptx.x -1.340e-01 2.526e-02 -5.307 2.23e-06 ***
## seasonSpring -2.484e+01 2.089e+01 -1.189 0.239657
## seasonSummer -3.269e+01 1.981e+01 -1.650 0.104910
## seasonWinter 1.210e+00 2.095e+01 0.058 0.954146
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 45.41 on 53 degrees of freedom
## Multiple R-squared: 0.4884, Adjusted R-squared: 0.4305
## F-statistic: 8.434 on 6 and 53 DF, p-value: 1.9476e-06
Mean_newcustomers dayopen.x Mean_Transaction.Sales postcap season
## Series: Mean_SNAP.Sales
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.1706 -6.8166 0.9597 7.1932 21.4670
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.488e+01 1.999e+01 -1.745 0.087165 .
## SNAP.Incentives.Distributed 9.724e-04 2.311e-04 4.207 0.000107 ***
## Mean_newcustomers 7.276e+00 4.662e+00 1.561 0.124931
## dayopen.x -1.059e-01 5.116e-02 -2.069 0.043695 *
## Mean_Transaction.Sales 7.428e-01 6.136e-02 12.106 < 2e-16 ***
## postcapTRUE 5.525e+00 3.999e+00 1.382 0.173197
## seasonSpring -2.530e+00 5.138e+00 -0.493 0.624497
## seasonSummer -2.924e+00 5.123e+00 -0.571 0.570728
## seasonWinter 3.117e+00 5.599e+00 0.557 0.580254
## Mean_snapvendors 5.231e-01 6.339e-01 0.825 0.413163
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.3 on 50 degrees of freedom
## Multiple R-squared: 0.9754, Adjusted R-squared: 0.971
## F-statistic: 220.7 on 9 and 50 DF, p-value: < 2.22e-16
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.971 127. 291. 296. 314.
| Month | Mean_SNAP.Sales | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | 43.860 | 43.730 | 0.131 |
| 2017 Feb | 52.175 | 51.857 | 0.318 |
| 2017 Mar | 53.785 | 49.663 | 4.122 |
| 2017 Apr | 64.345 | 69.248 | -4.902 |
| 2017 May | 67.303 | 81.659 | -14.356 |
| 2017 Jun | 72.768 | 67.620 | 5.148 |
SNAP.Incentives.Distributed Mean_snapvendors Mean_Transaction.Sales
season
SNAP.Incentives.Distributed Mean_newcustomers Mean_snapvendors
Mean_Transaction.Sales season
Mean_newcustomers dayopen.x Mean_Transaction.Sales postcap season
## Series: Mean_SNAP.Sales
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.116 -7.126 1.856 5.583 25.639
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.927e+01 1.446e+01 -4.100 0.000142 ***
## SNAP.Incentives.Distributed 6.996e-04 1.569e-04 4.458 4.33e-05 ***
## Mean_snapvendors 7.894e-01 5.719e-01 1.380 0.173307
## Mean_Transaction.Sales 8.473e-01 3.985e-02 21.263 < 2e-16 ***
## seasonSpring 2.269e+00 4.594e+00 0.494 0.623410
## seasonSummer -2.037e+00 4.404e+00 -0.463 0.645558
## seasonWinter 8.127e+00 4.629e+00 1.756 0.084896 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.5 on 53 degrees of freedom
## Multiple R-squared: 0.973, Adjusted R-squared: 0.9699
## F-statistic: 318.1 on 6 and 53 DF, p-value: < 2.22e-16
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.970 124. 291. 293. 307.
| Month | Mean_SNAP.Sales | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | 43.860 | 43.333 | 0.527 |
| 2017 Feb | 52.175 | 51.020 | 1.155 |
| 2017 Mar | 53.785 | 49.025 | 4.760 |
| 2017 Apr | 64.345 | 68.627 | -4.282 |
| 2017 May | 67.303 | 86.025 | -18.723 |
| 2017 Jun | 72.768 | 67.656 | 5.112 |
SNAP.Incentives.Distributed Mean_snapvendors Mean_Transaction.Sales season
## Series: Mean_SNAP.Sales
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.0994 -6.1493 0.9356 5.7531 27.2972
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.074e+01 5.401e+00 -7.543 5.41e-10 ***
## SNAP.Incentives.Distributed 7.142e-04 1.579e-04 4.524 3.37e-05 ***
## Mean_Transaction.Sales 8.416e-01 3.997e-02 21.058 < 2e-16 ***
## seasonSpring 4.276e+00 4.394e+00 0.973 0.3347
## seasonSummer -3.507e+00 4.309e+00 -0.814 0.4194
## seasonWinter 1.050e+01 4.335e+00 2.421 0.0189 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.58 on 54 degrees of freedom
## Multiple R-squared: 0.972, Adjusted R-squared: 0.9694
## F-statistic: 375 on 5 and 54 DF, p-value: < 2.22e-16
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.969 123. 291. 293. 305.
| Month | Mean_SNAP.Sales | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | 43.860 | 43.333 | 0.527 |
| 2017 Feb | 52.175 | 51.020 | 1.155 |
| 2017 Mar | 53.785 | 49.025 | 4.760 |
| 2017 Apr | 64.345 | 68.627 | -4.282 |
| 2017 May | 67.303 | 86.025 | -18.723 |
| 2017 Jun | 72.768 | 67.656 | 5.112 |
## Series: Mean_SNAP.Sales
## Model: TSLM
##
## Residuals:
## Min 1Q Median 3Q Max
## -17.6028 -5.0351 0.5695 4.2523 16.3025
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.098e+01 1.292e+01 -1.623 0.111
## SNAP.Incentives.Distributed 5.875e-04 1.233e-04 4.764 1.57e-05 ***
## Mean_snapvendors -4.682e-02 4.656e-01 -0.101 0.920
## Mean_Transaction.Sales 7.010e-01 3.943e-02 17.777 < 2e-16 ***
## pcovidTRUE 2.284e+01 3.814e+00 5.988 2.01e-07 ***
## seasonSpring 1.870e+00 3.568e+00 0.524 0.602
## seasonSummer -1.041e-01 3.436e+00 -0.030 0.976
## seasonWinter 1.466e-01 3.834e+00 0.038 0.970
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.152 on 52 degrees of freedom
## Multiple R-squared: 0.984, Adjusted R-squared: 0.9819
## F-statistic: 457.1 on 7 and 52 DF, p-value: < 2.22e-16
Comparing Models
## # A tibble: 1 × 5
## adj_r_squared CV AIC AICc BIC
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.982 82.0 261. 265. 280.
| Month | Mean_SNAP.Sales | .fitted | .resid |
|---|---|---|---|
| 2017 Jan | 43.860 | 43.381 | 0.479 |
| 2017 Feb | 52.175 | 49.685 | 2.490 |
| 2017 Mar | 53.785 | 55.046 | -1.261 |
| 2017 Apr | 64.345 | 66.756 | -2.411 |
| 2017 May | 67.303 | 83.818 | -16.515 |
| 2017 Jun | 72.768 | 71.994 | 0.774 |
## Warning: Removed 12 rows containing missing values (`geom_line()`).
## Warning: Removed 12 rows containing missing values (`geom_point()`).
ARIMA Models Manually Chosen ARIMA(12,1,0) OR ARIMA(0,1,1)
## # A mable: 3 x 2
## # Key: Model name [3]
## `Model name` Orders
## <chr> <model>
## 1 arima011 <ARIMA(0,1,1)(0,1,1)[12]>
## 2 arima110 <ARIMA(1,1,0)(1,1,0)[12]>
## 3 auto <ARIMA(1,0,1)(2,0,0)[12]>
## # A tibble: 1 × 3
## .model lb_stat lb_pvalue
## <chr> <dbl> <dbl>
## 1 arima011 23.7 0.927
## # A mable: 4 x 2
## # Key: Model name [4]
## `Model name` Orders
## <chr> <model>
## 1 arima011 <LM w/ ARIMA(0,1,1)(0,1,1)[12] errors>
## 2 arima110 <LM w/ ARIMA(1,1,0)(1,1,0)[12] errors>
## 3 arima101 <LM w/ ARIMA(1,0,1)(1,0,0)[12] errors>
## 4 auto <LM w/ ARIMA(1,0,1)(1,0,0)[12] errors>
## # A tibble: 4 × 6
## .model sigma2 log_lik AIC AICc BIC
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 arima011 564. -277. 565. 567. 578.
## 2 arima110 858. -284. 580. 582. 593.
## 3 arima101 513. -324. 663. 666. 682.
## 4 auto 513. -324. 663. 666. 682.
SNAP.Incentives.Distributed + newcustomers + dayopen.x
m2mTfuture <- new_data(m2mT, 12) |> mutate(m2m = mean(m2mT\(m2m), SNAP.Incentives.Distributed = tail(m2mT\)Mean_SNAP.Incentives.Distributed, n=12), newcustomers = tail(m2mT\(Mean_newcustomers, n=12), dayopen.x = tail(m2mT\)dayopen.x, n=12))
forecast(m2mTfitc, new_data = m2mTfuture) |> autoplot(m2mT) + labs(y = “Percentage change”
us_change |> select(-Consumption, -Income) |> pivot_longer(-Quarter) |> ggplot(aes(Quarter, value, colour = name)) + geom_line() + facet_grid(name ~ ., scales = “free_y”) + guides(colour = “none”) + labs(y=“% change”)