Google Trends Analysis for Morocco’s Earthquake Response#
Analyzing Google Trends#
This analysis tries to answer the question if the recent earthquake in Morocco has or will affect the tourism industry. We make use of proprietary Google Trends data that gives us weekly data scaled to the highest result from 0 to 100 i.e. 100 representing the highest proportion for the terms queried within the selected region and time frame and zero the lowest.
Since the team wanted to focus on 5 countries in specific, that make up for the highest number of visitors in Morocco, we created lists of commonly used terms that people tend to use to plan their holidays with Google Search. The kinds of searches that users perform can be a good proxy for the public’s interests, concerns or intentions, but these searches do not necessarily represent users’ opinions. Therefore we use statistical methods to come up with a probabilistic analysis of impact on Morocco’s tourism industry.
Lists of commonly used travel search terms in different languages catering to United States, United Kingdom, France, Germany and Spain.#
eng_terms = ['morocco flights', 'morocco hotels', 'marrakesh', 'marrakesh hotels', 'casablanca morocco','casablanca hotels',
'casablanca flights', 'casablanca travel', 'morocco tourist attractions', 'things to do in morocco', 'things to do in casablanca',
"moroccan cuisine", "beaches in morocco", "Safety in Morocco", "transportation in Morocco"]
french_terms = ['séjour à marrakech', "vacance maroc", "voyages marrakech", "billet avion Maroc", "casablanca hotels", "marrakech hotels",
"Cuisine marocaine", "Sécurité au Maroc"]
spanish_terms = ['Vuelos a Marruecos', 'Hoteles en Marruecos', 'Casablanca Marruecos', 'Hoteles en Casablanca', 'Vuelos a Casablanca', 'Viaje a Marruecos', 'Que hacer en Marruecos',
"Rutas por Marruecos", "Playas en Marruecos", "Seguridad en Marruecos"]
german_terms = ['Marokko Hotels', 'Hotels in Marrakesch', "things to do in morocco", "Pauschalreisen Marokko", "Marokko Sehenswürdigkeiten",
"Marokko Rundreise", "Marokko Strände", "Marokko Sicherheit", "Marokko Transport"]
con_dict = {"US" : "United States", "GB" : "United Kingdom", "ES" : "Spain", "FR" : "France", "DE" : "Germany"}
Looking at the latest available data for the selected countries (for the time period Jan-2023 - latest available date from Google Trends API)
Show code cell source
fig = px.line(df, x='month', y='value', color='country', markers=True, title = f"Google Search Trends for the year 2023")
fig.update_yaxes(
title_text = "Scaled Value",
title_standoff = 25)
fig.update_xaxes(
title_text = "Date",
title_standoff = 25)
fig.show()
## Show all in one graph or split across 5?
Show code cell source
ax = df.reset_index().pivot(index = 'date', columns = 'country', values = 'value').plot(figsize = (15, 8))
ax.set_title("Google Search Trends for the year 2023", fontsize = 12);
Comparing the trends for the past 3 years for the same time period (Jan - Sept)#
Show code cell source
plot_charts("US")
Show code cell source
plot_charts("GB")
Show code cell source
plot_charts("FR")
Show code cell source
plot_charts("ES")
Overall, as expected, 2021 saw very little search travel terms to Morocco because of COVID restrictions and people not willing to travel internationally unless things were safer. 2022 was one of the busiest year for travel in a decade and the trends in plots above show that. For 2023, the trends have gone down by a little but some months show spikes in search for travel terms.
Prediction#
To predict if the tourism will be impacted using Google Trends data, we’ll collect the data points for set query terms from 2019 to latest available date (removing the time periods when the country was under COVID lockdown).
Specific terms related to flight/hotel cancellation were used but Google Trends did not have enough data to show that. This prediction is solely based on yearly trends and seasonality.
Show code cell source
predict_trends("US")
RMS error for United States's data is 8.734
Downward trend: -0.00612
Show code cell source
predict_trends("ES")
RMS error for Spain's data is 9.767
Upward trend: 0.00553
Show code cell source
predict_trends("FR")
RMS error for France's data is 7.433
Downward trend: -0.01239
Show code cell source
predict_trends("DE")
RMS error for Germany's data is 7.908
Downward trend: -0.01682
Show code cell source
predict_trends("GB")
RMS error for United Kingdom's data is 6.376
Downward trend: -0.01236
Needs Assessment#
This part of the analyses uses Google Trends data within Morocco to see if there was a trend in some of the key search terms categories. The search terms comprise of English, French and Arabic terms that could’ve been used by the local communities or the search and rescue operations staff. The analysis also takes a deeper dive at the admin regions most affected by the earthquake to see if there’s any considerable trend for the search terms.
water_terms = ['water', 'drinking water', 'يشرب الماء', 'ماء', 'eau']
food_terms = ['grocery store', 'souk', 'خضروات', 'restaurant near me', 'store' ]
ph_terms = ['toilette', 'الحمام', 'toilet']
hosp_terms = ['مستشفى', 'hôpital', 'clinique', 'عيادة', 'hospital', 'clinic', 'medical supply', 'medicines', 'الأدوية']
Analyzing the trends of search keywords for before and after the earthquake period for Morocco to see if there was any considerable changes in search for these key topics
Show code cell source
print("Trends for before earthquake period of water terms")
get_needs_trends(beq_water)
print("Trends for after earthquake period of water terms")
get_needs_trends(aeq_water)
plot_needs_trends(beq_water, aeq_water, 'Water')
Trends for before earthquake period of water terms
Downward trend: -0.012590969756490955
Trends for after earthquake period of water terms
Upward trend: 0.3631590656284752
Show code cell source
print("Trends for before earthquake period of food terms")
get_needs_trends(beq_food)
print("Trends for after earthquake period of food terms")
get_needs_trends(aeq_food)
plot_needs_trends(beq_food, aeq_food, 'Food')
Trends for before earthquake period of food terms
Upward trend: 0.033220014605524664
Trends for after earthquake period of food terms
Downward trend: -0.01962180200222564
Show code cell source
print("Trends for before earthquake period of personal hygiene terms")
get_needs_trends(beq_ph)
print("Trends for after earthquake period of personal hygiene terms")
get_needs_trends(aeq_ph)
plot_needs_trends(beq_ph, aeq_ph, 'Personal Hygiene')
Trends for before earthquake period of personal hygiene terms
Upward trend: 0.007747643390160294
Trends for after earthquake period of personal hygiene terms
Upward trend: 0.05376344086021354
Show code cell source
print("Trends for before earthquake period of hospital terms")
get_needs_trends(beq_hosp)
print("Trends for after earthquake period of hospital terms")
get_needs_trends(aeq_hosp)
plot_needs_trends(beq_hosp, aeq_hosp, 'Hospital')
Trends for before earthquake period of hospital terms
Downward trend: -0.06686084740024499
Trends for after earthquake period of hospital terms
Upward trend: 0.141811889754047
Analyzing data at subnational regions for impacted areas#
Béni Mellal-Khénifra Region
Show code cell source
#MA-09, MA-07, MA-05
#adm2 = {"Béni Mellal-Khénifra" : "MA-05", "Marrakech-Safi" : "MA-07", "Souss-Massa" : "MA-09"}
needs_terms = {"water" : water_terms, "food" : food_terms, "personal hygiene" : ph_terms, "hospital" : hosp_terms}
#for adm in adm2.keys():
for terms in needs_terms.keys():
bef = get_df_ht(needs_terms[terms], "MA-05", start_date='2023-07', end_date = "2023-08")
aft = get_df_ht(needs_terms[terms], "MA-05", start_date='2023-09', end_date = '2023-09')
print(f"Trends for Béni Mellal-Khénifra before earthquake period of {terms} terms")
get_needs_trends(bef)
print(f"Trends for Béni Mellal-Khénifra after earthquake period of {terms} terms")
get_needs_trends(aft)
plot_needs_trends(bef, aft, terms, 'Béni Mellal-Khénifra')
print("============*****=================")
Trends for Béni Mellal-Khénifra before earthquake period of water terms
Downward trend: -0.04543829165722356
Trends for Béni Mellal-Khénifra after earthquake period of water terms
Upward trend: 0.23439377085650698
============*****=================
Trends for Béni Mellal-Khénifra before earthquake period of food terms
Upward trend: 0.04708015411346975
Trends for Béni Mellal-Khénifra after earthquake period of food terms
Upward trend: 0.09152391546162388
============*****=================
Trends for Béni Mellal-Khénifra before earthquake period of personal hygiene terms
Downward trend: -0.019532791082235976
Trends for Béni Mellal-Khénifra after earthquake period of personal hygiene terms
Downward trend: -0.27779013718947004
============*****=================
Trends for Béni Mellal-Khénifra before earthquake period of hospital terms
Upward trend: 0.019678286732755148
Trends for Béni Mellal-Khénifra after earthquake period of hospital terms
Downward trend: -0.05218143616363871
============*****=================
Marrakech-Safi Region
Show code cell source
for terms in needs_terms.keys():
bef = get_df_ht(needs_terms[terms], "MA-07", start_date='2023-07', end_date = "2023-08")
aft = get_df_ht(needs_terms[terms], "MA-07", start_date='2023-09', end_date = '2023-09')
print(f"Trends for Marrakech-Safi region before earthquake period of {terms} terms")
get_needs_trends(bef)
print(f"Trends for Marrakech-Safi region after earthquake period of {terms} terms")
get_needs_trends(aft)
plot_needs_trends(bef, aft, terms, 'Marrakech-Safi')
print("============*****=================")
Trends for Marrakech-Safi region before earthquake period of water terms
Downward trend: -0.02881821157865583
Trends for Marrakech-Safi region after earthquake period of water terms
Upward trend: 0.16760845383759684
============*****=================
Trends for Marrakech-Safi region before earthquake period of food terms
Downward trend: -0.0469391352521973
Trends for Marrakech-Safi region after earthquake period of food terms
Downward trend: -0.16293659621802056
============*****=================
Trends for Marrakech-Safi region before earthquake period of personal hygiene terms
Upward trend: 0.05608857327524678
Trends for Marrakech-Safi region after earthquake period of personal hygiene terms
Downward trend: -0.03626251390433904
============*****=================
Trends for Marrakech-Safi region before earthquake period of hospital terms
Downward trend: -0.06598227751056951
Trends for Marrakech-Safi region after earthquake period of hospital terms
Downward trend: -0.3387467556544313
============*****=================
Souss-Massa Region
Show code cell source
for terms in needs_terms.keys():
bef = get_df_ht(needs_terms[terms], "MA-09", start_date='2023-07', end_date = "2023-08")
aft = get_df_ht(needs_terms[terms], "MA-09", start_date='2023-09', end_date = '2023-09')
print(f"Trends for Souss-Massa region before earthquake period of {terms} terms")
get_needs_trends(bef)
print(f"Trends for Souss-Massa region after earthquake period of {terms} terms")
get_needs_trends(aft)
plot_needs_trends(bef, aft, terms, 'Souss-Massa')
print("============*****=================")
Trends for Souss-Massa region before earthquake period of water terms
Upward trend: 0.0035506534713302985
Trends for Souss-Massa region after earthquake period of water terms
Upward trend: 0.08671857619577276
============*****=================
Trends for Souss-Massa region before earthquake period of food terms
Downward trend: -0.10109037798091212
Trends for Souss-Massa region after earthquake period of food terms
Downward trend: -0.23617352614015613
============*****=================
Trends for Souss-Massa region before earthquake period of personal hygiene terms
Upward trend: 0.05592908765833136
Trends for Souss-Massa region after earthquake period of personal hygiene terms
Upward trend: 0.104634779384501
============*****=================
Trends for Souss-Massa region before earthquake period of hospital terms
Upward trend: 0.00504757987571303
Trends for Souss-Massa region after earthquake period of hospital terms
Upward trend: 0.289976517117785
============*****=================