autoregression

package module
v0.0.0-...-e4744a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2023 License: GPL-2.0 Imports: 4 Imported by: 0

README

autoregression

This is a package for generating autoregressive models for sequential or timeseries data.

NewModelOLS(data []float64, order int) (*ARModel, error)

This function attempts to generate an autoregressive model using the method of Ordinary Least Squares. It requires some past data, as a float64 slice, and an order (or lag). If successful, a model will be returned, which can then be used to make predictions.

ARModel.Order() int

This method returns the order of the model.

ARModel.StandardError() float64

This method returns the standard error of the model. This is a measure of how far the model deviates from the data it was trained on.

ARModel.Predict(newData []float64) (float64, error)

This method returns a prediction of the next value following a given it's preceding data of length order.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNegativeOrder            = errors.New("autoregression: model order cannot be negative")
	ErrInsufficientDataForOrder = errors.New("autoregression: the number of elements in the data must be greater then one more than twice the order")
	ErrSingularCovariantMatrix  = errors.New("autoregression: the covariant matrix generated from the data was singular")
	ErrIncorrectDataLength      = errors.New("autoregression: the length of the supplied new data was not equal to the order")
)

Functions

This section is empty.

Types

type ARModel

type ARModel struct {
	// contains filtered or unexported fields
}

func NewModelOLS

func NewModelOLS(data []float64, order int) (*ARModel, error)

Generate a new AR model using the method of least squares.

func (*ARModel) MarshalJSON

func (model *ARModel) MarshalJSON() ([]byte, error)

func (*ARModel) Order

func (model *ARModel) Order() int

func (*ARModel) Predict

func (model *ARModel) Predict(newData []float64) (float64, error)

func (*ARModel) StandardError

func (model *ARModel) StandardError() float64

func (*ARModel) UnmarshalJSON

func (model *ARModel) UnmarshalJSON(jsonData []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL