Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toarstats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
toar-public
toarstats
Commits
1c21dc0a
Commit
1c21dc0a
authored
1 year ago
by
Niklas Selke
Browse files
Options
Downloads
Patches
Plain Diff
Fixed an issue when calling the moving block bootstrap algorithm with 'method=OLS'.
parent
8e6e48a0
No related branches found
No related tags found
2 merge requests
!9
Develop
,
!6
Niklas issue009 feat calculate quantile regression
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
toarstats/trends/interface.py
+1
-1
1 addition, 1 deletion
toarstats/trends/interface.py
toarstats/trends/ols.py
+1
-1
1 addition, 1 deletion
toarstats/trends/ols.py
toarstats/trends/utils.py
+3
-2
3 additions, 2 deletions
toarstats/trends/utils.py
with
5 additions
and
4 deletions
toarstats/trends/interface.py
+
1
−
1
View file @
1c21dc0a
...
...
@@ -63,7 +63,7 @@ def calculate_trend(method, data, quantiles=None):
if
not
all
(
0
<
quantile
<
1
for
quantile
in
quantile_list
):
raise
ValueError
(
"
The quantiles must be strictly between 0 and 1.
"
)
anomalies_series
=
calculate_anomalies
(
data_in
)
if
method
==
"
quant
_reg
"
:
if
method
==
"
quant
"
:
fit
=
{
quantile
:
quant_reg
(
anomalies_series
,
quantile
)
for
quantile
in
quantile_list
...
...
This diff is collapsed.
Click to expand it.
toarstats/trends/ols.py
+
1
−
1
View file @
1c21dc0a
...
...
@@ -21,7 +21,7 @@ def ols(data):
:return: The trend with its uncertainty and p value
"""
fit
=
smf
.
ols
(
"
value~datetime
"
,
data
).
fit
(
method
=
"
qr
"
).
params
mbb
=
moving_block_bootstrap
(
"
OLS
"
,
data
,
quantile
)
mbb
=
moving_block_bootstrap
(
"
OLS
"
,
data
)
fit_se
=
np
.
nanstd
(
mbb
,
axis
=
0
)
fit_pv
=
2
*
scipy
.
stats
.
t
.
sf
(
x
=
abs
(
fit
/
fit_se
),
df
=
len
(
data
)
-
2
)
return
{
"
trend
"
:
fit
,
"
uncertainty
"
:
fit_se
,
"
p_value
"
:
fit_pv
}
This diff is collapsed.
Click to expand it.
toarstats/trends/utils.py
+
3
−
2
View file @
1c21dc0a
...
...
@@ -42,13 +42,14 @@ def calculate_anomalies(data):
}).
sort_values
(
"
datetime
"
)
def
moving_block_bootstrap
(
method
,
data
,
quantile
,
num_samples
=
1000
):
def
moving_block_bootstrap
(
method
,
data
,
quantile
=
None
,
num_samples
=
1000
):
"""
Perform the moving block bootstrap algorithm.
:param method: either ``
"
OLS
"
`` or ``
"
quant
"
``
:param data: data containing a list of date time values and
associated parameter values
:param quantile: a single quantile, must be between 0 and 1
:param quantile: a single quantile, must be between 0 and 1 if
``method=
"
quant
"
``
:param num_samples: number of sampled trends
:return: A list of sampled trends
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment