Running the Regression for a Single BinΒΆ

Import the regression function and some utility libraries

%matplotlib inline
from LOTUS_regression.regression import mzm_regression
from LOTUS_regression.predictors import load_data
import LOTUS_regression.tests as tests
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels as sm

Load in some example data, first our predictors.

predictors = load_data('pred_baseline_pwlt.csv')

<Axes: xlabel='time'>

Load in one latitude bin of SAGE 2/OSIRIS/OMPS merged relative anomalies

s2_omps_osiris = tests.load_example_data('S2_OSIRIS_OMPS_alt_nd_sample.csv')

<Axes: xlabel='time'>

Convert data to raw arrays

predictors, s2_omps_osiris = pd.DataFrame.align(predictors, s2_omps_osiris, axis=0)

# (nsamples, npredictors) matrix
X = predictors.values

# (nsamples) array of observations
Y = s2_omps_osiris['relative_anomaly'].values

And Perform the regression

regression_output = mzm_regression(X, Y)

plt.plot(s2_omps_osiris.index, Y)

plt.plot(s2_omps_osiris.index, regression_output['fit_values'])
[<matplotlib.lines.Line2D at 0x7fecd49078e0>]