Skip to content

5. Example usage

AHdezS edited this page Jan 23, 2026 · 2 revisions

1. Import packages and prepare your data as numpy arrays

from sarlib import SAR, OLS, SampleSizeAnalysis, show_scatter
import numpy as np
x = np.random.randn(100, 3)  # predictors
y = np.random.randn(100)     # response

2. Visualize data

show_scatter(x, y)

3. Fit SAR model

model_sar = SAR(n_realiz=100, norm='epsins', alpha=0.05)
stats_sar = model_sar.fit(x, y, verbose=True)

4. Compare with an OLS model

model_ols = OLS(n_realiz=100, alpha=0.05)
stats_ols = model_ols.fit(x, y, verbose=True)

5. Analyze sample size effect

analysis = SampleSizeAnalysis(model_sar, x, y, steps=7)
analysis.plot_loss()
analysis.plot_pvalue()
analysis.plot_coef()

Clone this wiki locally