Wavelet Analysis on APPL and TSLA by Using R
Qinyi Ruan
Department of Mathematics and Applied Mathematics, Wenzhou University, Wenzhou, Zhejiang, China
Keywords: Wavelet, R, Apple, Tesla, AAPL, TSLA, Time Series.
Abstract: In this paper, we created and analyzed the time series plots of Apple and Tesla stock prices over the past 2
years and wavelet coherence plots connecting them by using R. We found a causal relationship between AAPL
and TSLA in different frequency bands: In the first half of 2020, and from 2022 to the present, TSLA and
AAPL interact with each other in the 0-128 frequency bands, showing a positive correlation. From the second
half of 2020 to the first half of 2021, there was a positive correlation interaction in the 32-128 frequency bands
between AAPL and TSLA. Our study provides several significant supports for investors and scholars. For
example, in the general environment of vigorous development of clean energy, helping to predict the trends
of Apple, Tesla and other similar companies' stock prices in the future, providing a reference not only for
Apple and Tesla to compete and develop in the future, but also for other companies with similar conditions
to forecast, estimate the company's competitive strength and formulate long-term development strategies.
1 INTRODUCTION
In recent years, as the leader of new energy
companies, Tesla stock price has soared, becoming
the world's No.1 car company by market
capitalization. More and more people are comparing
it to Apple, which is the world's largest technology
company, not to mention that Apple's plans to build
cars and investments in clean energy are ongoing.
Tesla is an electric vehicle and clean energy
company. It designs, develops, manufactures and
markets all-electric and advanced automotive
powertrain components and energy storage systems.
In addition, it sells and leases solar systems and
renewable energy to commercial and residential
customers. As the world's first electric vehicle
company to use lithium-ion batteries, it is gradually
dominating the world automotive market and leading
global automotive companies with emerging
technologies and competitive strategies. On
December 30, 2019, Tesla completed delivery of the
first Model 3s from its Shanghai Super Factory to
fifteen employee owners. On January 7, 2020, at the
official delivery ceremony, Musk announced the
delivery of the cars to the general public consumers
and the launch of the project to manufacture Model Y
in China. He initially said in twitter that the idea of
the plant supplying only the Greater China region
changed because the epidemic of COVID-19 in 2020
affects the resumption plans in the United State, and
the excellent cost of production line capacity made in
China. In the case of gradual expansion and beyond
the demand of the local market, on October 26,
Tesla's Shanghai Super Factory began exporting
Chinese-made electric cars to more than a dozen
advanced countries, including Europe and Australia
(Wang and Peng, 2020).
Apple designs, develops, communicates and sells
consumer electronics, computer software, online
services and personal computers. Before making the
iPhone, Steve Jobs wanted to produce an "Apple
Car”. since 2018, Apple has been opening new
offices, investing in automotive engineering
machines, hiring thousands of engineers and rehiring
the former chief automotive engineer at Tesla.
Meanwhile, to address the world's environmental
issues, Apple has issued a total of $4.7 billion worth
of green bonds between February 2016 and
November 2019, to actively pursue low-carbon
engineering, renewable energy, carbon sequestration,
carbon saving and emission reduction. They plan to
achieve carbon neutrality of overall company
operations, manufacturing supply chain and product
lifecycle by 2030. Currently, Apple's global business
operations have achieved carbon neutrality. By 2030,
the climate impact of every Apple device sold will be
reduced to net zero (Apple's $4.7 billion green bond
Ruan, Q.
Wavelet Analysis on APPL and TSLA by Using R.
DOI: 10.5220/0012034300003620
In Proceedings of the 4th International Conference on Economic Management and Model Engineering (ICEMME 2022), pages 439-444
ISBN: 978-989-758-636-1
Copyright
c
2023 by SCITEPRESS Science and Technology Publications, Lda. Under CC license (CC BY-NC-ND 4.0)
439
spend is helping to create 1.2 gigawatts of Clean
Power, 2022).
In the face of increasing global pollution, the new
energy industry will enable us to reduce industrial
waste by replacing traditional energy sources with
environmentally friendly ones, while ensuring the
sustainability of the energy industry. More and more
people are becoming aware of sustainability and the
aim of reducing CO2 emissions. Therefore, the idea
of vehicles without pollutant emissions is very
promising now, especially in the future. These
vehicles will be cheaper to maintain in the coming
years and owning them will be better for society.
State governments, as well as global organizations
such as the United Nations, are also committed to
increasing the number of electric vehicles. They have
introduced many corresponding policies and
regulations, such as:
1. Financial incentives. Through government
subsidies, vehicle registration tax exemptions,
making electric vehicles more attractive to private
and corporate customers.
2. Urban access restrictions. Oxford proposes to
ban all non-electric vehicles from the city centre from
2020,and Paris intends to ban all gasoline and diesel
vehicles in the city centre (Fekete et al., 2021).
There is a growing overlap between Apple and
Tesla, both in their strong promotion of clean energy
and the development of electric vehicles. The
economic shutdown caused by the epidemic of
COVID-19 in 2020, which also hit the stock market
hard. However, following with a $2 trillion fiscal
stimulus package from the U.S. government and
monetary stimulus from the U.S. Federal Reserve, the
economy recovered and the stock market recovered (
ODEDOKUN, 2021). Tesla was included in the S&P
500 on December 21,2020, and its performance rose
to the top of the list, dominating US market trading.
Meanwhile, Apple also has been performing well in
recent years. Its market capitalization exceeded $1
trillion on August 2, 2018, exceeded $2 trillion by
stock price on August 19, 2020, and on January 3,
2020, once exceeded $3 trillion dollars, although the
stock price fell at the close of trading, failing to hold
the $3 trillion market cap.
Our work in this paper is to explore the
relationship between AAPL and TSLA. First, we
discuss the recent situation and social background of
Apple and Tesla, introduce AAPL and TSLA, and
analyse the relationship between Apple and Tesla to
prepare for the experimental analysis that follows.
The third paragraph is our research methodology. We
will use R to analyse price change of AAPL and
TSLA in detail. The fourth section is the experimental
analysis. We first perform a simple data analysis of
the data components and data sources, as well as
based on time series graphs. Then, we further
describe the connection between AAPL and TSLA by
analysing the wavelet correlation between the two
based on the information from the graphs. In Section
5, I will summarize all of the above and provide an
outlook on future research directions.
2 AAPL, TSLA, WAVELET
COHERENCE
In recent years, many investors have been closely
following the stock price trends of Apple and Tesla
and the relationship between the two. Castro
Caballero et al. have studied the feasibility of an
Apple acquisition of Tesla, doing an extremely
comprehensive strategic analysis, a potential
acquisition ,which is one of the largest M&A's in the
world (Castro Caballero et al., 2020). More and more
research on stock forecasts is being published, with
many reports using Tesla and Apple as examples.
This shows that Apple and Tesla are often mentioned
together to some extent, either as acquisitions or in
comparison to each other, but the degree of
correlation between Apple and Tesla's stock prices,
i.e., the degree of correlation and the lead/lag
relationship between Apple and Tesla, has not yet
been explored.
Wavelet coherence can locate correlations
between sequences and their evolution over time and
across scales. He and Nguyen showed how the
wavelet transform is an effective tool for
decomposing time series into different frequency
levels. This decomposition allows researchers to
study the interaction of financial and economic
variables at different levels: from the very short-term
or high-frequency level to the very long-term or low-
frequency level. Therefore, wavelet analysis is
extremely important for studying the impact and
correlation of economic variables (Nguyen and He,
2015).
Kim and In investigated the relationship that
exists between stock returns and inflation using a
wavelet multiscale approach to decompose a given
time series on a scale-by-scale basis(Kim and In,
2005). Hamrita and Trifi used the wavelet transform
to examine the multiscale relationships among
interest rates, exchange rates, and stock prices. In
particular, they apply the maximum overlap discrete
wavelet transform (MODWT) to interest rates,
exchange rates, and stock prices in the United States
ICEMME 2022 - The International Conference on Economic Management and Model Engineering
440
for the period from January 1990 to December 2008
and analyse the association of these series at
different time scales and the lead/lag relationship by
using the definitions of wavelet variance, wavelet
correlation, and mutual correlation (Hamrita and
Trifi, 2011). Andrieș, Ihnatov and Tiwari used cross-
wavelet power, cross-wavelet coherence and phase
difference methods to study and identify the patterns
of linkage between interest rates, stock prices and
exchange rates in India for the period July 1997 to
December 2010 (Andrieș et al., 2014). Mohamed
Dahir et al. investigated the dynamic link between
Brazil, Russia, India, China and South Africa
(BRICS) regarding the exchange rate and stock
returns through using wavelet analysis (Mohamed
Dahir et al., 2018). Liow, Huang and Song utilized
wavelet-based multi-resolution analyses to
investigate the relationship between the U.S. real
estate and stock markets in the time-frequency
domain (Liow et al., 2019). These previous studies
have well demonstrated the great significance of
wavelet analysis for studying the degree of
correlation and lead/lag relationship between
economic variables.
3 DATA AND METHODOLOGY
The data used in this study includes Apple stock price
(AAPL) and Tesla stock price (TSLA). Both the
AAPL and TSLA data were sourced from Kaggle and
were collected from January 2, 2020 to September 1,
2022, with 673 valid data. We chose this period
because we wanted to reduce the interference of the
COVID-19 global pandemic on this study.
3.1 The Wavelet Coherence
we used R to create time series to analyse AAPL and
TSLA separately. The correlation between AAPL and
TSLA could be analysed by considering the widely
implemented method that did not consider time
series, i.e., wavelet coherence. Torrence and Compo
showed that the cross-wavelet transform can be
performed by two time series a
t
and b
t
articulated as:
𝑁

𝑝, 𝑞
=𝑁
𝑝, 𝑞
𝑁
𝑝, 𝑞
(1)
In the formula, N
p, q
and 𝑁
𝑝, 𝑞
described
two continuous transforms of a
t
and b
t
, with p
was the position index, q denoting the measure. In
addition, (*) represented the composite
conjugate(Torrence and Compo, 1998). Torrence and
Webster stated the equation for the adjusted wavelet
coherence coefficients:
𝑊
𝑝, 𝑞
=
|


,



,
|

|
,
|

|
,
|
(2)
M was the smoothing mechanism. 0𝑊
𝑝, 𝑞
≤1,
which denoted the range of square wavelet coherence
coefficients. Close to zero indicates a lack of
correlation, while close to one indicates high
correlation (Torrence and Webster, 1998).
4 EMPIRICAL ANALYSIS
We analyse the time series chart of AAPL stock price,
as shown in Figure 1.
In March 2020, the global epidemic was in full
swing and the stock value dropped sharply to a trough
of about $56.092. After a series of adjustments by the
U.S. government, Apple and others, the stock value
recovered and oscillated upward, reaching a peak of
about $182.010 in recent years in January 2022, and
then continued its oscillating trend. 32 months, from
a start of $75.088 to a finish of $ 157.960, doubling
the share value.
We analyse the time series chart of TSLA stock
price, as shown in Figure 2.
The large-scale opening of the Chinese market in
2019 owing to the official establishment of the Tesla
China Super Factory and the lower cost of the
Chinese version of the Model 3. A sharp increase in
sales had led to a continued rise in Tesla stock in
2020. After a brief decline to around $200 in the first
half of 2021, Tesla shares soared again in September
and October, reaching a peak of $409.970 in recent
years in November 2021, a value that was more than
14 times the initial value of the analysis period, and
then showed an oscillating decline.
The wavelet coherence between AAPL and TSLA
showed in Figure 3.
There are two larger red islands from 2020 to the
first half of 2021 (0 to 128), indicating a strong
dependence on the 0 to 128 band for the
corresponding sample period. The arrows to the right,
top, and bottom indicate that TSLA and AAPL
interact with each other, showing a positive
correlation. The global outbreak of the epidemic was
in full swing and U.S. stocks fell sharply, followed by
a larger release of monetary liquidity from the Federal
Reserve and a massive fiscal stimulus from the U.S.
government, which led to a recovery in U.S. stock
prices. At the same time, Tesla greatly opened up the
Chinese market with the delivery of the Chinese
version of Model 3, which made a sharp increase in
Wavelet Analysis on APPL and TSLA by Using R
441
overall sales and a more than sevenfold increase in
stock prices, dominating U.S. stock trading in
2020.For Apple, the closure of the epidemic has led
to a shift from the traditional offline office and
learning model to remote, online, driving public
demand for new devices, such as mac and iPad, as of
September 2020, net sales of both devices have
increased by 11% over the same period, and share
values have also increased (10-K 2020, 9.26 -
s2.q4cdn.com, 2020). In addition, Apple has funded
17 green bond projects to promote carbon savings and
clean energy development around the world.
2022 (0 to 128) also has two larger red hot areas.
Particularly, the area in 0-32 frequency bands is
darker in red, indicating the correlation is much
stronger. Arrows in this region are up and down to the
right, which means AAPL and TSLA influence each
other. For the red island over the 64 to 128 days
frequency bands, arrows to the right and down to the
right, illustrating that AAPL leads TSLA. Both of two
red hot areas show positive correlation. The
government's support for clean energy and the
establishment of laws and regulations favourable to
electric vehicles have led shares of companies like
Tesla, using new energy, and Apple, which is
implementing solar energy investment plans, to rise.
Apple has accelerated its development of fully
autonomous electric vehicles in recent years, and
while the Apple Car program has undergone several
shifts and changes over the past few years due to
internal conflicts and leadership issues, development
is now on track. 26 percent of people surveyed by
Strategic Vision of 200,000 new car owners said they
liked the Apple brand and would consider buying a
car if it made one. Apple also had the highest quality
impression with a score of 24%, compared to 11% for
Tesla. So, it's clear that Apple and Tesla will be in
strong competition for the electric car.
There are many red islands of varying sizes in the
0 to 16 band with arrows to the right, top right, and
bottom right, indicating that AAPL and TSLA are
always mutually causal in both directions in the lower
frequency bands.
In summary, AAPL and TSLA exhibit
bidirectional causality in almost all frequency bands.
Figure 1: AAPL stock price from January 2, 2020, to
September 1, 2022.
Figure 2:TSLA stock price from January 2, 2020, to
September 1, 2022.
Figure 3. Wavelet Coherence: AAPL vs TSLA
ICEMME 2022 - The International Conference on Economic Management and Model Engineering
442
5 CONCLUSIONS
In this study, we collected from 2020 to September 1,
2022 of daily data on AAPL and TSLA stock prices,
used R to create time series plots and wavelet
coherence plots, and analysed the interactive
bootstrap lag interactions in the time-frequency
domain.
We concluded that AAPL and TSLA exhibit
bidirectional causality in almost all frequency bands:
In the first half of 2020, TSLA and AAPL showed a
positive correlation interaction over the 0 to128 days
frequency bands; From the second half of 2020 to the
first half of 2021, there was a positive correlation
interaction in the 32-128 frequency bands between
AAPL and TSLA; From 2022 to the present, TSLA
and AAPL interact with each other in the 0-128
frequency bands, showing a positive correlation, and
the correlation is much stronger from 0 to32 days; In
particular, from 2020 to present, there are many red
islands of different sizes in the 0-16 frequency bands
with arrows to the right, upper right, and lower right,
indicating that AAPL and TSLA always have a
mutual two-way causality in the low frequency band.
We also found that U.S. policies and government
investments, such as massive fiscal stimulus,
investments in renewable energy and clean energy
industries, not only affect the volatility of AAPL and
TSLA stock prices, but more importantly, strengthen
the correlation between AAPL and TSLA, making the
dynamics of the two closely related.
In the future, scholars and investors can use this
study on the degree of correlation between Apple and
Tesla stocks as a reference basis to explore the degree
of correlation between various companies, the impact
of competition between various companies on stock
prices, and the impact of external environment, such
as policies, on competition and development between
companies in the future, using R and the wavelet
coherence, whether in the face of the continuous
emergence of new viruses, the introduction of various
new policies on economy and environment, or in the
face of the general environment of promoting clean
energy in various industries.
REFERENCES
10-K 2020, 9.26 - s2.q4cdn.com (2020). Available at:
https://s2.q4cdn.com/470004039/files/doc_financials/2
020/ar/_10-K-2020-(As-Filed).pdf
Andrieș, A.M., Ihnatov, I. and Tiwari, A.K. (2014)
“Analyzing time–frequency relationship between
interest rate, stock price and exchange rate through
continuous wavelet,” Economic Modelling, 41, pp.
227–238. Available at:
https://doi.org/10.1016/j.econmod.2014.05.013.
Apple's $4.7 billion green bond spend is helping to create
1.2 gigawatts of Clean Power (2022) Apple Newsroom.
Available at:
https://www.apple.com/newsroom/2021/03/apples-
four-point-seven-billion-green-bond-spend-is-helping-
to-create-one-point-two-gigawatts-of-clean-power/
Castro Caballero, N.M. et al. (2020) Acquisition of Tesla
Inc by Apple Inc, Digital Object Identifier System.
Universidad del Rosario. Available at:
https://doi.org/10.48713/10336_30991
Fekete, H. et al. (2021) “A review of successful climate
change mitigation policies in major emitting economies
and the potential of global replication,” Renewable and
Sustainable Energy Reviews, 137, p. 110602. Available
at: https://doi.org/10.1016/j.rser.2020.110602.
He, T.-X. and Nguyen, T. (2015) Wavelet analysis and
applications in economics and Finance, Research &
Reviews: Journal of Statistics and Mathematical
Sciences. Research and Reviews. Available at:
https://www.rroij.com/open-
access/pdfdownload.php?aid=62323
Kim, S. and In, F. (2005) “The relationship between stock
returns and inflation: New evidence from Wavelet
Analysis,” Journal of Empirical Finance, 12(3), pp.
435–444. Available at:
https://doi.org/https://doi.org/10.1016/j.jempfin.2004.0
4.008.
Liow, K.H., Huang, Y. and Song, J. (2019) “Relationship
between the United States Housing and stock markets:
Some evidence from Wavelet Analysis,” The North
American Journal of Economics and Finance, 50, p.
101033. Available at:
https://doi.org/10.1016/j.najef.2019.101033.
Mohamed Dahir, A. et al. (2018) “Revisiting the dynamic
relationship between exchange rates and stock prices in
BRICS countries: A wavelet analysis,” Borsa Istanbul
Review, 18(2), pp. 101–113. Available at:
https://doi.org/10.1016/j.bir.2017.10.001.
Mohamed Essaied Hamrita and Abdelkader Trifi (2011)
“The Relationship between Interest Rate, Exchange
Rate and Stock Price: A Wavelet
Analysis,” International Journal of Economics and
Financial Issues, Econjournals, vol. 1(4), pages 220-
228.
ODEDOKUN, Ezekiel Adeyemi (2021). “COVID–19
Pandemic Lockdown: A Comparative Analysis of
Government Intervention between Palliatives in
Nigeria and Stimulus in United States of America
(USA),” KIU Journal of Social Sciences, [S.l.], v. 6, n.
4, p. 7-16, jan. 2021. ISSN 2519-0474. Available at:
https://kampalajournals.ac.ug/ojs/index.php/kiujoss/art
icle/view/1075
Torrence, C. and Compo, G.P. (1998) “A practical guide to
wavelet analysis,” Bulletin of the American
Meteorological Society, 79(1), pp. 61–78. Available at:
https://doi.org/10.1175/1520-
0477(1998)079<0061:apgtwa>2.0.co;2.
Wavelet Analysis on APPL and TSLA by Using R
443
Torrence, C. and Webster, P.J. (1998) “The annual cycle of
persistence in the el nño/southern oscillation,”
Quarterly Journal of the Royal Meteorological Society,
124(550), pp. 1985–2004. Available at:
https://doi.org/10.1002/qj.49712455010.
Wang, J. and Peng, X. (2020) “A study of patent open
source strategies based on open innovation: The case of
tesla,” Open Journal of Social Sciences, 08(07), pp.
386–394. Available at:
https://doi.org/https://doi.org/10.4236/jss.2020.87031.
ICEMME 2022 - The International Conference on Economic Management and Model Engineering
444