本次澳洲代写主要为金融模型中波峰检测的assignment

Assessment Brief: Spike Detection Modelling in Finance S1

背景
您面前的算法用于从时间序列数据中检测峰值。这个算法
使用移动平均线和移动标准差来识别峰值。定义了一个尖峰
当一个数据点,xt大于n×σt来自¯xt,其中n是一个整数,¯xt和n×σt,
分别是移动平均和移动标准差。
回忆一下你的基础统计学课程,Z 分数告诉你一个数据点有多远
来自以标准差为单位的平均值(在我们的例子中,平均值和标准
偏差都在移动,其中 xt 的 Z 分数计算如下:
z(xt) = (xt − ¯ xt)
σt
如果原始数据点 xt 高于(低于)平均值,则 Z 分数为正(负)。
如果 xt 等于平均值​​,则 Z 分数为 0。例如,可以识别尖峰
当 xt 的移动 Z-score 大于 3 时,这与当 xt 为
大于移动平均值的 3 × 移动标准差。同样,3 只是一个
任意数字,并且该数字可能并不适用于所有数据集。
下图是该算法的示意图(见图 1):

图 1:在顶部面板中,蓝色轨迹是原始时间序列数据。黄种人
是基于定义的滞后窗口的移动平均线。紫色的痕迹是动人的
基于定义的滞后窗口的标准偏差。在底部面板中,红线
是当上述条件为真时检测到的尖峰。一个值是
为真时分配,否则为零。在神经科学中,来自同一神经元的动作电位(尖峰)不能连续发生
主要是由于神经元的绝对不应期(膜电位必须
在另一个动作电位再次触发之前重置)。为了纠正 VALID
尖峰的数量,您必须计算尖峰之间的时间(也称为间隔时间)
尖峰间隔)。对于此评估,膜电位需要 50 毫秒才能重置。
因此,如果在 x0 处出现尖峰,则该神经元直到 50 毫秒后才能再次尖峰
从 x0。在出现假阳性尖峰的情况下,您需要恢复信号
回到0。
最后,为了演示目的,您必须计算平均峰值间
从有效尖峰列表中的第一个尖峰开始的间隔。你不需要
在电子表格中报告这个数字,因为我们将在演示文稿中讨论这个问题。全部
计算,但在 VBA 中完成。

数据集
在本工作簿中,我提供了两组数据:
1. 第一个是单个神经元的电生理记录。这是一个常见的
在神经科学中追踪它说明电活动的变化(测量
电压)随着时间的推移,尖峰表示动作电位。每个数据点
代表 10ms。
2、二是ASX200指数从1992年到1992年的历史日收盘价数据
本星期。在这种情况下,峰值将表示异常的每日回报。
功能说明
尖峰检测算法被称为函数,依赖于 4 个主要输入:
1. 时间序列数据
2.滞后窗口(滚动平均值和标准偏差的数据点数)
3. 阈值 (n) – 每个观测值远离的移动标准差的数量
从移动平均线
4. 一个重量参数——我会让你自己解决这个(它在某个地方
代码)并在该算法中发挥重要作用。
该函数必须按如下方式调用:
=(数据,滞后,阈值,权重)

Background
The algorithm in front of you is used to detect spikes from time-series data. This algorithm
uses moving averages and moving standard deviations to identify spikes. A spike is defined
when a data point, xt is greater than n×σt from ¯ xt, where n is an integer, ¯ xt and n×σt,
are respectively the moving average and moving standard deviation.
Recall from your basic statistics course that the Z score tells you how far a data point
is from the mean in units of standard deviation (in our case, the mean and standard
deviations are both moving, where the Z-score for xt is calculated as:
z(xt) = (xt − ¯ xt)
σt
If the raw data point, xt, is above (below) the mean then the Z-score is positive (negative).
If xt is equal to the mean then the Z-score is 0. For example, a spike can be identified
when the moving Z-score for xt is greater than 3, which is the same as saying when xt is
greater than 3 × moving standard deviation from the moving mean. Again, 3 is just an
arbitrary number and that number may not be ideal for all datasets.
The image below is an illustration of the algorithm (see Figure 1):

Figure 1: In the top panel, the blue trace is the raw time series data. The yellow race
is the moving average based on a defined lag window. The purple trace is the moving
standard deviation based on a defined lag window. In the bottom panel, the red lines
are the spikes detected when the above mentioned conditions are true. A value of one is
assigned when true and zero otherwise.In neuroscience, an action potential (spike) from the same neuron cannot occur consec-
utively due to the absolute refractory period of a neuron (the membrane potential must
reset before another action potential can fire again). In order to correct for the VALID
number of spikes, you must calculate the time between spikes (also known as the inter-
spike interval). For this assessment, it takes 50ms for the membrane potential to reset.
Therefore, if a spike occurs at x0, this same neuron cannot spike again until after 50ms
from x0. In the case that there are false positive spikes, you need to revert the signals
back to 0.
Finally, for the purpose of the presentation, you must calculate the average inter-spike
intervals starting from the very first spike from the list of valid spikes. You do not need
to report this figure in the spreadsheet as we’ll discuss this in the presentation. ALL
calculations but be completed in VBA.

Datasets
In this workbook, I’ve provided two sets of data:
1. The first is an electrophysiological recording of a single neuron. This is a common
trace in neuroscience where it illustrates the change in electrical activity (measured
in voltage) over time, with spikes denoting action potentials. Each data point
represents 10ms.
2. The second is historical daily closing price data of the ASX200 index from 1992 to
this week. In this case, spikes would denote abnormal daily returns.
Description of the function
The spike detection algorithm is called as a function and relies on 4 main inputs:
1. Time series data
2. Lag window (number of data points for the rolling average and standard deviation)
3. Threshold (n) – the number of moving standard deviations each observation is away
from the moving average
4. A weight parameter – I’ll let you work this one out yourself (it’s somewhere in the
code) and plays an important role in this algorithm.
The function MUST be called as follows:
=(Data, Lag, Threshold, Weight)