Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

QuantileRegression

Guides

  • Quantile regression

Tech Notes

  • Quantile regression 3D examples
  • Quantile regression over weather time series
  • Unit tests

Symbols

  • NURBSBasis
  • QuantileEnvelope
  • QuantileEnvelopeRegion
  • QuantileRegressionFit
  • QuantileRegression
Quantile regression over weather time series
Introduction
Estimation of conditional density distributions
Quantile regression over heteroscedastic data
​
Introduction
In this notebook we show two primary use cases of for Quantile Regression (QR):
◼
  • Fitting regression quantiles over
    heteroscedastic data
  • ◼
  • Estimation of conditional density distributions
  • Quantile regression over heteroscedastic data
    Load the paclet
    In[186]:=
    Needs["AntonAntonov`QuantileRegression`"]
    Take temperature data
    In[187]:=
    tsTemp=WeatherData[{"Atlanta","Georgia"},"Temperature",{{2018,1,1},{2023,1,1},"Day"}]
    Out[187]=
    TimeSeries
    Time:
    01 Jan 2018
    to
    01 Jan 2023
    Data points: 1827
    
    Plot time series points
    In[188]:=
    opts={ImageSizeLarge,AspectRatio1/2,PlotTheme"Detailed",JoinedFalse};DateListPlot[tsTemp,opts]
    Out[188]=
    Data summary
    In[189]:=
    ResourceFunction["RecordsSummary"][tsTemp["Path"]]
    Out[189]=
    
    1 column 1
    Min
    3723753600
    1st Qu
    3763173600
    Mean
    3802636800
    Median
    3802636800
    3rd Qu
    3842100000
    Max
    3881520000
    ,
    2 column 2
    23.89
    °C
    16
    24.22
    °C
    16
    12.78
    °C
    14
    22.78
    °C
    12
    25
    °C
    12
    23.33
    °C
    11
    (Other)
    1746
    
    Find regression quantiles for 0.1, 0.5, 0.9
    In[190]:=
    AbsoluteTiming​​probs={0.1,0.5,0.9};​​qFuncs=
    QuantileRegression
    [QuantityMagnitude[tsTemp["Path"]],16,probs];​​
    Out[190]=
    {1.01272,Null}
    Plot time series points with fitted regression quantiles
    In[191]:=
    DateListPlot[{tsTemp["Path"],Map[Function[{f},{#,f[#]}&/@tsTemp["Times"]],qFuncs]},opts,Joined{False,True,True,True},PlotLegends{"data",Sequence@@probs}]
    Out[191]=
    Remark: It should be obvious from the plot above that the time series data is heteroscedastic.
    Count the number points under each surface
    In[192]:=
    sepPoints=Association@MapThread[Function[{p,f},pLength[Select[QuantityMagnitude[tsTemp["Path"]],#〚2〛<f[#〚1〛]&]]],{probs,qFuncs}]
    Out[192]=
    0.1182,0.5918,0.91647
    Show the corresponding fractions (should correspond to the probabilities)
    In[193]:=
    sepFractions=N[sepPoints/Length[tsTemp["Path"]]]
    Out[193]=
    0.10.0996169,0.50.502463,0.90.901478
    Estimation of conditional density distributions
    Find regression quantiles for a "comprehensive" set of probabilities
    In[194]:=
    AbsoluteTiming​​probs=Sort[Join[Range[0.1,0.9,0.1],{0.01,0.99}]];​​qFuncs=
    QuantileRegression
    [QuantityMagnitude[tsTemp["Path"]],16,probs];​​
    Out[194]=
    {2.31354,Null}
    Plot time series points with fitted regression quantiles
    In[195]:=
    DateListPlot[{tsTemp["Path"],Map[Function[{f},{#,f[#]}&/@tsTemp["Times"]],qFuncs]},opts,Joined{False,True,True,True},PlotLegends{"data",Sequence@@probs}]
    Out[195]=
    Reconstruct the CDF distribution at the focus point (January 1st, 2020)
    In[196]:=
    focusPoint=AbsoluteTime[{2020,1,1}];​​xs=Through[qFuncs[focusPoint]];​​cdfPairs=Transpose[{xs,probs}];
    Plot the empirical CDF
    In[199]:=
    ListLinePlotcdfPairs,
    
    Out[199]=
    In order to plot the corresponding PDF function define a CDF reconstruction function
    In[200]:=
    CDFEstimate[t0_]:=CDFEstimate[probs,qFuncs,t0];​​​​​​CDFEstimate[qs_,qFuncs_,t0_]:=Interpolation[Transpose[{Through[qFuncs[t0]],qs}],InterpolationOrder1];
    Plot empirical PDF

    © 2025 Wolfram. All rights reserved.

    • Legal & Privacy Policy
    • Contact Us
    • WolframAlpha.com
    • WolframCloud.com