Philemon Immersion Bible Study 2024

For the first half of January 2024 I have been reading Titus and Philemon twice daily for the 8 chapters per day. I am writing this post to summarize the key themes that I captured while reading through Philemon.

Context. The Apostle Paul wrote the book of Philemon during his second Roman imprisonment as a letter to Philemon in Colossae. Timothy is also named as an author of the letter. Paul describes Philemon as a beloved brother and fellow worker who was also a slave owner of at least one slave Onesimus. Onesimus had run away from Philemon, arrived in Rome, and was ministering to Paul in his imprisonment at Rome.

People. Philemon is a unique book. It primarily describes one specific situation involving several believers and is a request from Paul for one believer to accept another believer as a beloved brother and no longer a slave. In this letter Paul describes the character of Philemon and Onesimus as well as several other Colossians. It is instructive for us to look more deeply into how Paul described these believers.

Paul describes Philemon as a beloved brother and fellow worker. Philemon demonstrated love and faith toward the Lord Jesus and all the saints. Philemon has refreshed the hearts of the saints. Philemon apparently was also known for hospitality since Paul was bold enough to ask him to prepare lodging for Paul’s planned visit to Colossians. The early church was suffering much persecution, seen no less in Paul’s and Epaphras’ imprisonment. One can reasonably guess that the saints were experiencing discouragement. Philemon’s role to refresh fellow saints must have been especially needed.

Paul describes Onesimus, Philemon’s runaway slave, as his child in the faith, his very heart, who was useful and ministering to Paul while Paul was in chains. He describes Onesimus as a beloved brother both in the flesh and in the Lord.

Paul also describes a few others in Colossae: Apphia our sister, Archippus our fellow soldier, and Epaphras his fellow prisoner in Christ.

Paul’s Request. Paul sends the runaway slave Onesimus back to Philemon, and he requests Philemon to receive him no longer as a slave but a beloved brother. Some commentators say that Paul did not attempt to abolish slavery or even end Philemon’s slavery. However, a careful read of Philemon considering both Paul’s explicit words and Paul’s gentle pleadings indicates that Paul was mostly likely requesting Philemon to release Onesimus from servitude.

  • Paul’s explicit request to receive Onesimus no longer as a slave but more than a slave, as a brother. Paul later explicitly asks Philemon to accept Onesimus as he might accept Paul, certainly not in a harsh manner and possibly not as a slave at all.
  • Paul says that he intended to keep Onesimus. He had been useful to Paul and endeared himself to Paul. However he did not want to keep Onesimus without Philemon’s consent. Paul was asking Philemon to release Onesimus back to serve Paul in his chains.
  • Paul did not want to command Onesimus’ release but wanted Philemon to act voluntarily. Paul was clearly asking for Philemon to act beyond just accepting Philemon back.
  • Paul offers to repay anything that Onesimus owes Philemon.
  • Finally, Paul says that he expects Philemon to do even more than Paul requests. This is more implicit but clearly it is more than just accepting Philemon back as a brother in Christ since Paul says he is gently asking for more than what he has asked.

Application. Paul says that he has boldness in Christ to command Philemon to do what is proper, and he says that Philemon owes Paul even his very self. However, Paul is careful to prioritize brotherly love so that Philemon’s goodness would not be under compulsion but voluntary. Paul also said that he wished to keep Onesimus but demonstrates his integrity that he did not want to do anything without Philemon’s consent.

Titus Immersion Bible Study 2024

Each year I decide how I will read the Bible for the rest of the year. I have usually either used a daily devotional with associated passages or have read through the entire Bible. Some of my favorite devotionals have been Strength for Today by John MacArthur and Truth for Life by Alistair Begg. I have also found chronological one-year Bible reading plans to provide a useful perspective on Old Testament books of prophecy.

In 2023 I learned about the immersion Bible study plan that involves reading each book of the Bible 30 times before moving to a new book, as described by John MacArthur. The book How to Eat Your Bible describes a variation of the immersion Bible study plan. Since the plan in this book varied in intensity from year to year, I decided to alter the immersion plan to be more consistent in intensity month by month, and I am planning to read approximately 8 chapters per day and finishing these chapters after reading them 30 times. Sometimes this will plan involve repeating 4 chapters twice per day.

For the first half of January 2024 I have been reading Titus and Philemon twice daily for the 8 chapters per day. I am writing this post to summarize the key themes that I captured while reading through Titus.

Context. The Apostle Paul addressed this letter to his child in the faith Titus who was serving in Crete. Titus was written between AD 62-64 while Paul was in Macedonia between his two imprisonments [1]. One of Paul’s main motivations for Titus is to direct Titus to appoint elders in all the towns that meet the qualifications Paul provides. He also provides instruction for men and women and believers in general.

Key Themes. Paul begins this letter highlighting how he is writing Titus for the faith of God’s elect and for their knowledge of truth according to godliness. The themes of truth and godliness are consistent themes throughout the book. Paul describes the truth Titus should teach in contrast to deception of rebellious men teaching for gain. Paul describes applications of godliness and emphasizes that believers are saved, not by good works, but unto good works. Paul highlights God’s trustworthy promise of eternal life that provides hope as a repeating theme.

Paul provides several key motivations for modeling the character traits of godliness that he provides. Christians should live in a way that the word of God is not slandered. Those who oppose the gospel should be put to shame have nothing bad to say about Christians’ behavior. We are waiting for the blessed hope of the Second Coming of Christ and also looking forward to being heirs of eternal life.

Titus 1. My pastor has said that Christian men should be preparing themselves to be ready to be elders in a church. The elders whom Titus would appoint would have demonstrated these qualities already prior to Paul’s letter. These qualities include: being above reproach (repeated twice), the husband of one wife, children who are believers not accused of debauchery or rebellion. Paul lists qualities defined by their negatives: not arrogant, not quick-tempered, not a drunk, not violent, and not greedy. Then Paul lists positive qualities: hospitable, loving good, self-controlled, disciplined, righteous, and holy.

Paul then says to silence rebellious men who are teaching and deceiving for dishonest gain. The nature of this teaching involved Jewish myths and commandments of men. These men professed to know God but denied him and were unfit for any good work. Later in Chapter 2, Paul says Titus should speak what accords to sound doctrine in contrast to the rebellious men. We see the theme of teaching truth.

Titus 2. One of the key themes of Titus 2 are the good works believers perform. Paul says to be a model of good works and zealous for good works. Paul also repeats the command to be dignified, self-controlled, and not drunken multiple times.

Paul gives commands for older men, older women, younger women, and younger men. Paul gives commands for older men: to be sober-minded, dignified, self-controlled, sound in faith, in love, and in steadfastness. Paul’s commands for older women are to be reverent in behavior and not slanderers or addicted to wine. He says older women have a special calling to train younger women: to love their husband and children, be self-controlled, pure, working at home, kind, and submissive to their husbands that the word of God not be slandered. He urges younger men to be self-controlled. Clearly the theme of self-control is an important one that appears in his commands for all four groups. Many of these qualities like being self-controlled, not drunken, sober-minded and reverent are not gender-specific, apart from the gender roles Paul describes.

Paul also provides commands for slaves in order to adorn the doctrine of God our savior. The commands for slaves applies generally to all employees but directly to slaves in the Roman Empire who were owned by their masters [1]. Scholars estimate 20-30% of the Roman subjects were slaves by the early Empire. Slaves were to be subject to their masters, pleasing, not contradicting, and demonstrating good faith.

Finally Paul shifts from practical application to theology.

  • The grace of God brings salvation to people of all nations and instructs us to deny ungodliness and to live self-controlled, righteously, and godly. This grace is meant to make believers a new creation, not easybelievism.
  • Believers are to look forward to the second coming of Christ.
  • Christ gave up his earthly life to redeem the elect from lawlessness and to purify the elect as His own possession, zealous for good works.

Titus 3. Paul provides more application regarding believer’s behavior to government and factious behavior and dissension in the church. Paul also provides more theology on the nature of man before salvation and the nature of salvation. Despite the emphasis on good works, Paul clarifies that works of righteous (i.e. good works) do not save anyone.

Paul commands believes to be subject to rulers and authorities, to be obedient and ready for every good work, to slander no one, to be peaceable, considerate, demonstrating gentleness to all. Paul’s commands are convicting for the American church when we consider how we approach politics and even political discussions among family and friends. Politics in America is nothing if not pugnacious and stirring up roughness, not gentleness, among neighbors.

Paul also address strife in the church. He says to avoid foolish controversies, genealogies, strife, and conflicts about the Law, which are worthless. He describes the church discipline process of giving two warnings to factious people in the church before rejecting them out of the church.

  • Paul reminds Titus the nature of men before Christ: foolish, disobedient, deceived, lustful, malicious, envious, despicable, and hating others.
  • Then God’s kindness and affection appeared in Jesus our Savior.
  • Jesus saved us according to His mercy and not man’s works of righteousness. We are justified by His grace.
  • This salvation occurred through the washing of regeneration and renewing by the Holy Spirit.
  • Jesus poured out the Holy Spirit richly on believers.
  • We can look forward in hope to being heirs of eternal life.

Paul concludes the letter saying that “our people” or believers in their church and ministry should lead in good works to meet pressing needs, and this is characteristic of being a fruitful Christian.

  1. The MacArthur Bible Commentary

God’s Steadfast Love in Trials

The phrase steadfast love, hesed in Hebrew, appears frequently in the Old Testament to describe God’s sovereign and loving commitment to His covenant people Israel in the Old Covenant. Psalms 136 describes the Lord’s steadfast love demonstrated in His sovereign creation, in His deliverance of Israel from bondage, and in Israel’s establishment in the Promised Land.

After Moses delivered the Lord’s commandments to Israel, he describes how God chose Israel to be a people for His holy possession, not because of their number but in keeping His oath to their forefathers. Deuteronomy 7:9 describes how the Lord keeps his covenant and steadfast love, hesed, with those who love Him and keep His commandments.

“For you are a people holy to the Lord your God. The Lord your God has chosen you to be a people for his treasured possession, out of all the peoples who are on the face of the earth. It was not because you were more in number than any other people that the Lord set his love on you and chose you, for you were the fewest of all peoples, but it is because the Lord loves you and is keeping the oath that he swore to your fathers, that the Lord has brought you out with a mighty hand and redeemed you from the house of slavery, from the hand of Pharaoh king of Egypt. Know therefore that the Lord your God is God, the faithful God who keeps covenant and steadfast love with those who love him and keep his commandments, to a thousand generations,

Deuteronomy 7:6-9

The topic of trials is fresh on my mind since I have been dealing with my first prolonged bout of sinusitis this year. Since sinus surgery in 2021, I have found treatments that helped managed sinus infections, but these have been slow to work, if at all, this September 2023. This trial is made more acute since I planned to travel to my hometown, Atlanta, GA, this week for the G3 conference and to visit family.

In the past, a trial or disappointment like the current one could leave me frustrated and questioning God’s purposes. Deep in my heart, I may be asking, “How could God have any higher purposes than for me to keep my good plans to attend a Christian conference and visit family?” In the distance past, with a weaker understanding of God’s sovereignty and goodness, I might question Him and murmur like the Israelites wandering through the desert. Like most evangelicals raised Arminian or in the line of General Baptists, I still was lacking comfort in God’s sovereignty. An Arminian in a time of trial can question, “God must not be all powerful if He cannot guarantee any lost people will be saved even after the sacrificial death of His Son Jesus Christ on the cross. This trial may even be out of God’s control.” If I would be so bold, I might even question silently why God would not give me good gifts even though I had chosen to follow Him. In my heart, I doubted His sovereignty or goodness though I knew what Romans 8:28 tells us about God’s sovereign and good purposes for His children.

28 And we know that for those who love God all things work together for good,[h] for those who are called according to his purpose. 29 For those whom he foreknew he also predestined to be conformed to the image of his Son, in order that he might be the firstborn among many brothers. 30 And those whom he predestined he also called, and those whom he called he also justified, and those whom he justified he also glorified.

Romans 8:28-30

This is where a deep understanding of God’s covenant and steadfast love with His New Covenant people is important and why it is not simply a “debatable topic best ignored for the unity of the body.” For those of us who are God’s children, who believed and repented under the work of His Spirit, this is a comforting doctrine and leads us to glorify God all the more. God foreknew us in that He wrote our names in the Book of Life before the foundations of the world (Revelations 17:8). He predestined us to be adopted into His family and conformed to the image of His Son. He works all things, even trials, for our good.

While our plans seem most important to us, God ultimately cares about conforming us into the likeness of His Son. Inconvenience, cancelled travel plans, discomfort, trials, all of these can be used by God to conform us into His image. In the meantime, we can wait patiently on the Lord: resting knowing He is sovereign and good since He predestined to redeem us, trusting that He keeps his covenant and steadfast love for those who love Him, those who have been called, justified, and glorified for His glory.

Come Thou Fount of Every Blessing – Piano Instrumental

After beginning to learn piano again starting last May 2022, Come Thou Fount of Every Blessing is the first hymn I began learning. This is a fairly easy arrangement suited to my first year learning to play again: https://www.musicnotes.com/sheetmusic/mtd.asp?ppn=MN0213498.

While I cannot say which is my favorite hymn, this one is in the top five, alongside Amazing Grace, Be Thou My Vision, In Christ Alone, and It is Well with My Soul.

I am playing here on a Roland FP-30X Digital Piano. One of the primary reasons I chose this digital piano are the keys which are considered comparable to digital pianos of higher quality both for Roland and other manufacturers.

Doctrine or Practical Things?

I heard a good sermon by Martin Lloyd Jones on marriage where he addresses this question about doctrine or practical things, but first I’ll share some personal experience.

At prior churches, I have sat in a service where a pastor delivering the sermon specifically downplayed doctrine and said they preferred rather to focus on practical applications. I dare say this line of thinking is pervasive in the American evangelical community at the least. When someone with authority in the church pulpit downplays doctrine, we must ask, ‘Are they speaking from God?’ Shouldn’t they be speaking for God when appropriating authority from God in the pulpit?

  • Should we pass over doctrines that rub across the grain of our natural self?
  • Should we rest in excuses not to train our mind or study God’s Word?

Let’s see what the Bible says.

The Apostle Paul said:

Have nothing to do with irreverent, silly myths. Rather train yourself for godlinessfor while bodily training is of some value, godliness is of value in every way, as it holds promise for the present life and also for the life to come.

I Timothy 4:7-8

All Scripture is breathed out by God and profitable for teaching, for reproof, for correction, and for training in righteousness,

II Timothy 3:16

If all Scripture is from God and profitable for teaching, should we ignore Scripture that requires some study to understand or that rubs against rough edges of our mind still not renewed in Christ?

The Old Testament, Jewish Tanakh, repeats this theme of training the mind many times in the Psalms:

I have stored up your word in my heart, that I might not sin against you.

Psalm 119:11

This “storing up” requires effort. Training requires effort. God calls His children to put effort into training their mind and heart with His Word.

Martin Lloyd Jones has an answer for this kind of thinking while he preached on the Apostle Paul’s instruction on marriage to the church in Ephesus.

“But why is he speaking concerning Christ and the church? Why has he led them into the mystery? In order that husbands might know how to love their wife. And that is where these glib and superficial people who jeer at doctrine, they say, ‘Ah, those people are only interested in doctrine. We are the practical people.’ You can’t be practical without doctrine. You can’t love your wife unless you understand something about this doctrine, this great mystery. ‘Ah,’ say say people, ‘It’s too difficult. I cannot follow all that.’ My dear friend if you want to live as a true Christian, you’ve got to follow it.

You’ve got to apply your mind. You’ve got to think. You’ve got to study.

You’ve got to try to understand. You’ve got to grapple with it.

It’s here for you, and if you turn your back on this, you’re rejecting something God gives you and you’re a terrible sinner. To reject doctrine is a terrible sin. You musn’t put practice against doctrine. You cannot practice without it. So the apostle takes the trouble to elaborate this wonderful doctrine about the relationship of Christ and the church…In order that you and I ought to love our wives as we ought to love them, even as Christ loved the church.

Romans 7:4 says, ‘Likewise, my brothers, gyou also have died hto the law ithrough the body of Christ, so that you may belong to another, to him who has been raised from the dead, jin order that we may bear fruit for God.’ The church is married to Christ.” (end quote)

The Background Music in Our Thought Life

When we are eating in restaurants, background music often fills the gaps in our conversations and the times when we let our minds wander away from the needs of the day.

We can also be carrying a background “music” of thoughts in our mind. These thoughts can stream continuously in our mind while we are going about our day. We may be wishing for something we do not have, worried about a need in life, worried for people we love, ruminating about all we need to do beyond what we need to do in the moment, or any other topics that are not focused on God. These thoughts streaming in the background of our mind can and often produce fruits in our lives. A background stream of wrongs we perceive can produce discord in our relationships with others. A background stream of worry can produce greed and hoarding God’s blessings. These are only a couple examples.

However, if we are children of God adopted into His family through faith in His grace alone, we also have the Holy Spirit who can remind us of God and His Word throughout our day. We need to be reading God’s word, meditating on it and memorizing it, for the Spirit to bring it to our minds. Praise to God and thanksgiving can be our background music instead. A continual heart of praise and thanksgiving dissipates worries and frustrations, and instead it produces the fruits of the Spirit: love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, and self-control. Unlike the world, we are not seeking a generic gratefulness to give us a better life, but we are grateful for God adopting us into His family and providing us a hope for eternal life beyond whatever we experience in this life.

The Apostle John says in I John 4:11: “Beloved, if God so loved us, we also ought to love one another. No one has ever seen God; if we love one another, God abides in us and his love is perfected in us.” When we remind ourselves of God’s love toward us, we are motivated better to obey Him by loving others.

The Bible also discusses how God’s Words should fill our time. Psalms 1:2 says, “but his delight is in the law of the LORD, and on his law he meditates day and night.” Paul tells us in I Thess. 5:16-18, “Rejoice always, pray without ceasing, give thanks in all circumstances; for this is the will of God in Christ Jesus for you.”

The message at church today spoke on a Psalm where David writes,

Teach me your way, O LORD,
that I may walk in your truth;
unite my heart to fear your name.
I give thanks to you, O Lord my God, with my whole heart,
and I will glorify your name forever.
For great is your steadfast love toward me;
you have delivered my soul from the depths of Sheol.

Psalm 86:11-13

David exhibits this continual stream of praise and thanks, with his whole heart, seeking to glorify God. What motivates him to praise God? He remembers God’s love towards him that he delivered his soul from death, temporal and eternal. He remembers that God gives him hope for a meaningful life on earth for God’s glory and a hope for eternal life free from sin and death.

Romans 5:8-9 reminds us of this good news, the gospel, “but God shows his love for us in that while we were still sinners, Christ died for us. Since, therefore, we have now been justified by his blood, much more shall we be saved by him from the wrath of God.

If we are children of God, may we cancel the stream of thoughts produced by our sin nature or even evil spirits in our spiritual battles, and instead carry a stream of praise and thanksgiving for God.

If you are reading this and not a born again children of God (John 3), may God open your eyes to your sin nature (Romans 3:23), your enmity with God and His ways (Romans 8:7), and cast off vain hopes of eternal life based on your inherent goodness, rituals, or religious efforts, and trust in the gospel of Christ. The Word of God, the Bible, only provides Christ as the way of salvation (John 14:6).

Do We Really Want Revival?

Rev. Steve Richardson opened the Church at War Conference at Trinity Bible Church delivering the first sermon on November 17, 2022. His sermon is titled “Seeking God Through Prayer.” Richardson is a Canadian pastor who was fined and threatened with imprisonment from the Canadian government and ultimately lost his church for refusing to limit worship gatherings to 10 people.

The rest of this article describes Richardson’s message, but reading this summary is like “looking through a glass dimly” compared to listening to the message firsthand:

Historical revivals. Richardson opens his message by describing historical revivals. Parishioners would sit outside in the pouring rain listening to the Word preached. Others continue in prayer and worship inside the church after the worship service and benediction, and still after a second benediction, until past midnight. Children as young as eight and teenagers are gathering to read the Bible and worship God.

Costs of revival. He also asks listeners how often they have prayed more than 30 minutes this week? While not prescriptive, it is a benchmark for comparing our prayer life. John MacArthur describes fervent and answered prayer as a mark of true faith.

Considering the fervent and faithful practice described both by Richardson and MacArthur, this sermon asks us, “Are we ready for revival?”

Need for revival. Many can see a need for political and societal revival in our nation when the government places more restrictions on worship than on aborting a child, when the state backs hospitals that surgically and permanently remove healthy body parts of children too young to drive, when the state backs public schools that teach gender dysphoria to impressionable children learning to tie their shoes, when public school teachers are required to be trained on Marxist ideologies of critical theory, or when the state forces healthy people to decide between losing their income or taking another shot that is unnecessary and proven to harm some who received it once.

However, Richardson challenges us to ask if we would be satisfied if God grants prayers for political and societal change as long as he does not give us Himself. Are we really seeking God? Or do we seek God to grant us favor and grant us our wishes? In Exodus 33:18, Moses asked to see God in His glory. Richardson diagnoses the disease in our generation of the church as laziness, as seen in the lukewarm church in Laodicea.

Traits of revival. Gospel revival has distinct traits which all come from the Word of God. While this list is not exhaustive, and I may have forgotten key elements, I think it provides a useful starting point to compare true gospel revival versus other spiritual experiences that claim to be revivals.

  • People are convicted of their sins and fallen nature before a holy God.
  • Conviction leads people to repentance, committing to turn from sinful ways.
  • Believers have a hunger for the Word and truth. This can include reading, hearing, memorizing, and meditating on the Word, but should be sufficient to saturate the believer’s life to achieve the next trait:
  • Believers have a conviction to remember and obey the Word such that their lives show a gospel transformation. (James 1:22)
  • The prayer life of believers are revived with persistent prayer. (Luke 18:1)
  • Prayers are seeking God’s will. (Matthew 6:33)
  • Believers are using their gifts joyfully to serve God.
  • Believers are glad to assemble with other believers to praise God. (Acts 2:46)
  • Believers are evangelizing the lost, sharing the good news of the gospel. The Great Commission is being fulfilled (Matthew 28:18-20).

Are you ready for revival if God takes hold of your heart to change in these areas? Spending more time in prayer, alone and in fellowship? Stepping out of your comfort zone to evangelize strangers? Spending more time in the Word, not only reading it but memorizing and meditating on it? Spending more time listening to faithful preaching? Spending enough time with God to see Him convicting you in areas where sin remains and seeing His power to live a new life?

If we have no desire for drawing nearing to God, we should check whether our faith is real, as I John encourages its readers to affirm. In little time, I found one resource from John MacArthur describing elements of real faith.

Jesus called the churches in Revelation to be revived by turning to their first love and turning from their sinful practices. Given the state of our society, government, and churches, we need God’s grace and mercy to “rend the heavens” (Richardson quote) and bring revival to our own hearts and then to those around us.

A brief background on Richardson. Richardson is formerly a pastor in Tillsonburg, Ontario within the Canadian Associate Reformed Presbyterian (ARP) Church. He held strong conviction to conduct church with his members without limiting in-person attendance to 10 people per Canadian health guidelines. Pastors may base this conviction on Hebrews 10:25 which commands believes not to forsake assembling. He was fined and threatened with imprisonment by the Canadian government for violating the mandates, and his presbytery applied pressure on him to follow the government mandates. Through a series of events, Richardson left the ARP for Vanguard presbytery and lost his church. Richardson is currently working as a teacher at King Alfred Academy in Ontario.

Lessons from the Garden – Abundant Growth

34But when the Pharisees heard that he had silenced the Sadducees, they gathered together. 35And one of them, a lawyer, asked him a question to test him. 36“Teacher, which is the great commandment in the Law?” 37And he said to him, “You shall love the Lord your God with all your heart and with all your soul and with all your mind. 38This is the great and first commandment. 39And a second is like it: You shall love your neighbor as yourself. 40On these two commandments depend all the Law and the Prophets.” -Matthew 22:34-39

I have had container gardens in two prior years since moving to the suburbs in 2018: a tomato garden and a corn, bean, and squash garden. This year I have been in a different home which had two raised beds already in the backyard, and I have had more space to combine a variety of vegetables. My spring garden this year has been a learning experience. I combined kale, spinach, rosemary, thyme, sage, broccoli, brussels sprouts, and two mints, spearmint and peppermint, into one raised bed. By the end of spring, the mints had expanded so much that they were climbing the broccoli plants and causing the broccoli to lean over. The mints were my most prolific plants hands down.

Our church today had a sermon on Matthew 22 with two exhortations: to love Christ with our whole heart and to be joyful. Much more could be said to reproduce the sermon here, but I will focus on my personal application. The image of mint expanding abundantly and boundlessly in my garden was a vivid image of how our love of Christ should crowd out competing thoughts that would steal our joy. While I experience joy in Christ whenever I seek it, I admittedly find that the concerns of the world-dating/marriage, work, community, housework, etc.-often can choke out my joy in Christ instead of vice versa.

My prayer for this week is to seek joy in Christ whenever I am tempted to let circumstances steal my joy and gratitude for His work.

Walmart Daily Sales Prediction Using Time Series Analysis: Seasonality

Time series prediction can be beneficial in many fields including logistics, weather, sales forecasting, and predictive maintenance. Walmart provided a complete data set on Kaggle that can be used to evaluate time series prediction techniques. I will be making several posts using the Walmart data set from the M5 Forecasting – Accuracy competition to develop and evaluate time series methods in Python.

This first post demonstrates preliminary exploratory data analysis (EDA) and prediction using seasonal features. The post also provides a brief summary of polymorphism in Python using an abstract parent class to minimize code duplication and avoid conditionals like switch or if statements.

Walmart Data Set

The Walmart data set includes data for items in three categories of products from 2011 through 2016: hobbies, foods, and household. Each item is associated with a store in CA, FL, or TX. Three tables contain data to identify daily unit sales, selling prices, and event data for any given day.

The calendar table
  • The calendar table has daily rows with weekday and event labels providing the date of notable events. The event labels contained in the table include religious holidays, such as Chanukah End and Easter, sporting events, such as SuperBowl and NBAFinalsStart, and US national holidays, such as Thanksgiving and IndependenceDay.
  • The sales_train_validation table includes daily unit sales data for products in the three categories among stores in the three states. This table is in wide format with each row containing all daily sales data for one product and columns for each day in the full time range.
The sales_train_validation table
  • The sell_prices table provides weekly prices for each item.
The sell_prices table
Exploratory Data Analysis

Prior to predicting unit sales, we would like to identify good candidate items that have strong seasonal variation. Since the Walmart data set only provides item_id labels instead of true item names or descriptions, EDA is needed to identify these good candidate items. Items that are the best candidates for seasonal prediction have a high correlation with events and holidays. Since some foods are often associated with events (e.g., chocolate on Valentine’s Day), this analysis focuses on items in the FOOD category. This initial round of exploratory data analysis identifies foods that demonstrate higher sales on events. Same items from multiple stores are grouped since preliminary EDA showed these same food items behaved similarly among multiple stores and states.

To identify good candidates for seasonal prediction, the data tables needs to be merged into a form with one column per event and one row per item with the same items from multiple stores groups into one row.

  1. Unpivoting (pandas melt) the sales_train_validation table converts the table from a wide format with a column per day to long format with a primary key including day.
  2. Grouping and averaging (pandas groupby) combines each item sold on one day among all stores into one row for that item with an average unit_sales for this day. The grouped sales_train_validation table now only has three columns: d (day), item_id, and average unit_sales across all stores.
  3. Merging (pandas merge) joins this grouped table with the calendar table on the day column. This step adds the event labels per day to the average unit_sales per day.
  4. Grouping again combines items per event to produce a table with a primary key of item_id and event_name. This table identifies the average unit_sales per event.
  5. Pivoting (pandas pivot) converts this grouped table into wide format with one column per event including a ‘None’ column to group sales on days without events.
  6. Dividing the unit_sales values in the event columns by the the unit_sales values in the ‘None’ column produces a unit_sales ratio to highlight foods with higher sales on event days. This step produces the final table values and structure.
Final unsorted wide table with average unit sales per item and per event

Sorting this wide table to be descending in the ‘Thanksgiving’ column identifies FOODS_3_069 as the food with highest increase in average unit_sales on Thanksgiving Day compared to days without events.

Sorted table identifies foods that sell more on Thanksgiving than normal days

The unit_sales for FOODS_3_069 at the TX_1 store demonstrates the unit_sales seasonality for this food. Distinct peaks occur near New Years Eve, Christmas, Thanksgiving, and Valentine’s Day although not all holidays have a peak each of the five years.

Unit sales of the FOODS_3_069 item shows peaks near three holidays
Unit Sales Prediction with Seasonal Features

This analysis uses a combination of deterministic time series features to predict unit sales. These features are a linear trend, weekly seasonal indicators, and annual seasonal indicators. The linear trend enables the model to detrend a long-term linear trend in time. The seasonal features are Fourier series in which each series has an integer number of cycles within a one year time frame. This analysis uses annual seasonal indicators with 1 to 32 cycles per annum. The statsmodels.tsa.deterministic.DeterministicProcess container class is a convenient class that provides the Fourier Series in addition to constants, time trends, and seasonal indicators for each week. The following method demonstrates the DeterministicProcess syntax. The DeterministicProcess requires a pandas index format for the index column.

    def create_seasonal_features(self, df_merged_store):
        """Creates seasonal features for one item and one store"""
        df_copy = df_merged_store.copy(deep=True)
        y = df_copy['unit_sales']

        df_copy['date'] = pd.DatetimeIndex(df_copy['date'])
        df_copy.set_index('date', inplace=True)
        fourier = CalendarFourier(freq='A', order=16)
        dp = DeterministicProcess(index=df_copy.index,
                                    constant=True,
                                    order=1,
                                    seasonal=True,
                                    additional_terms=[fourier],
                                    drop=True)
        X = dp.in_sample()

        return X, y

The model fitting and prediction problem presents an opportunity to apply polymorphism in Python using the abc package. A parent class contains a generic plotting method and abstract methods for fitting and prediction. A child class defines fitting and prediction methods that are tailored to a specific combination of input features. This first analysis only uses the seasonal features described previously, and the UnitSalesPredictionSeasonal child class fits a linear regression model from sklearn.linear_model.LinearRegression. The full code used in this example is available on GitHub: https://github.com/bspivey/M5ForecastingAccuracy.

from abc import ABC, abstractmethod

class UnitSalesPrediction(ABC):
    def plot_predictions(self, X, y, y_pred):
        list_of_tuples = list(zip(X.index, y, y_pred))
        columns = ['date', 'y', 'y_pred']
        df_wide = pd.DataFrame(list_of_tuples, columns=columns)
        value_vars = ['y', 'y_pred']
        df_tall = pd.melt(df_wide,
                            id_vars='date',
                            value_vars=value_vars,
                            var_name='y_label',
                            value_name='y_value')

        fig = px.line(df_tall,
                        x='date',
                        y='y_value',
                        color='y_label',
                        width=900,
                        height=300)
        fig.update_layout(
            yaxis_title='unit_sales')

        fig.show()

    @abstractmethod
    def fit_unit_sales_model(self):
        pass

    @abstractmethod
    def predict_unit_sales(self):
        pass

class UnitSalesPredictionSeasonal(UnitSalesPrediction):
    def fit_unit_sales_model(self, X_seasonal, y):
        """Trains a model to predict unit sales for one item and one store"""
        X = X_seasonal
        model = LinearRegression().fit(X, y)

        return model

The model trains on FOODS_3_069 time series data excluding the final two years. The final year contains the test data not used for model tuning, and the prior year contains the validation data used for model tuning.

The results for unit_sales predictions on validation and test data demonstrate that the seasonal features model successfully identifies peaks around Thanksgiving and Christmas and a possible peak near Valentine’s Day. The y_pred signal is the predicted unit_sales shown versus the y signal which is the validation or test data unit_sales.

FOODS_3_069 unit sales predictions on validation data
FOODS_3_069 unit sales predictions on test data

While the results demonstrate a correlation with several holidays as expected, the results smooth the predictions and show potential for improvement. Ideas for next steps are (1) including categorical features using actual event and holiday labels combined with lag/lead features, (2) using a hybrid linear regression and nonlinear regression model, and (3) using deep learning packages such as Facebook Prophet.