segmented: A toolbox for segmented regression.
Project description
Segmented
segmented is a Python toolbox for segmented regression.
Installation
segmented is written for Python 3.7+. To install...
Features
- 0.0.1
- single change point
- identity link functions
- single predictor
- 0.0.2
- single, parametric change point
- identity link functions
- single predictor
-
= 0.0.3
- user-specified number of segments (>2)
- link functions
- etc.
How to Use segmented
import segmented as sgmt
import pandas as pd
data = pd.read_csv('mydata.csv')
###############################################################################
# 2 segment model (1 change point)
# specify 2 model specifications: pre- and post-changepoint
model = sgmt.segment(models=['y~x', 'y~x'], data=data)
# specify a single model specification that will be used for each segment
model = sgmt.segment(models=['y~x'], num_segments=2, data=data)
# might need to provide some initial guesses at to-be-estimated parameters
model = sgmt.segment(models=['y~1', 'y~x'], x0=.5, data=data)
# might provide GLM capabilities
model = sgmt.segment(models=['y~x'], family=['binomial'], num_segments=2, data=data)
model = sgmt.segment(models=['y~x'], family=['binomial'], num_segments=2, data=data)
# estimate parameters
model.fit()
# check out estimates
print(model.summary())
OR
###############################################################################
# 2 segments, each segments has an intercept and slope associated with x
# the changepoint is a single value of x
model = sgmt.segment(models='y~x', changepoint='~1', num_segments=2, data=data)
# is equivalent to:
model = sgmt.segment(models='y~x', num_segments=2, data=data)
# 2 segments, each segments has an intercept and slope associated with x
# changepoint is parametric, with it's own intercept and slope associated with z
model = sgmt.segment(models='y~x', changepoint='~z', num_segments=2, data=data)
model = sgmt.segment(models=['y~x','y~x','y~x'], changepoint=['~z','~w'], data=data)
References
- TBD
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
segmented-0.0.1.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for segmented-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b07dac7e3c796748360ec5378e11b4f04fef3745ee5ea7b8462b09bf982a32a |
|
MD5 | 3cfff736fda589a37c64c771c279be62 |
|
BLAKE2b-256 | ef5a109aa6789a9d558b4d117469c539ae06e83ec4252443473560c1f42ffcee |