mults

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: GPL-3.0 Imports: 3 Imported by: 2

README

mults GoDoc

Package mults implements the container for multivariate time series data.

How to use the package

package main

import (
	"fmt"
    "math/rand"
    "github.com/yukai-yang/mults"
)

func main() {
	data := make([]float64, 40)
	for i := range data {
		data[i] = rand.NormFloat64()
	}

	ts := &mults.MulTS{}
	ts.SetData(data, 4, nil)
	ts.SetFreq(4, nil, nil)
	ts.SetNames([]string{"V0", "V1", "V2", "V3"})
	ts.SetLag(2)

	ts.SetDepByCol(false, 0)
	ts.SetDepByName(true, "V1")

	ts.SetIndepByCol(false, 2, 0)
	ts.SetIndepByName(true, "V3", 2)

	var dep, _ = ts.DepVars(2, 10)
	fmt.Println(mul.ViewMatrix(dep))
	var indep, _ = ts.IndepVars(2, 10)
	fmt.Println(mul.ViewMatrix(indep))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ViewMatrix

func ViewMatrix(m mat.Matrix) string

ViewMatrix prints the matrix

Types

type MulTS

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

MulTS is a struct for the multivariate time series

func (*MulTS) DepVars

func (ts *MulTS) DepVars(from, to int) (mat.Matrix, error)

DepVars returns (copies) a matrix containing the dependent variables subset from "from" to but without "to"

func (*MulTS) IndepVars

func (ts *MulTS) IndepVars(from, to int) (mat.Matrix, error)

IndepVars returns a matrix containing the independent variables

func (*MulTS) PossibleFrame

func (ts *MulTS) PossibleFrame() (int, int)

PossibleFrame returns the possible time frame from and to with the largest sample size

func (*MulTS) SetData

func (ts *MulTS) SetData(data []float64, nvar int, vnames []string) error

SetData sets the data, start, end and frequency data is a slice of float64, row first sorted nvar is the number of variables vnames contains the names of the variables, nil for no names

func (*MulTS) SetDepByCol

func (ts *MulTS) SetDepByCol(app bool, deps ...int) error

SetDepByCol sets dependent variables by column numbers

func (*MulTS) SetDepByName

func (ts *MulTS) SetDepByName(app bool, deps ...string) error

SetDepByName appends dependent variables by variable names

func (*MulTS) SetFreq

func (ts *MulTS) SetFreq(freq int, start, end []int) error

SetFreq sets the frequency of the time series start and end are 2-slices of int representing the start and end time points if start and/or end are nil, they will be inferred

func (*MulTS) SetIndepByCol

func (ts *MulTS) SetIndepByCol(app bool, indep int, lag int) error

SetIndepByCol sets independent variables by column numbers

func (*MulTS) SetIndepByName

func (ts *MulTS) SetIndepByName(app bool, indep string, lag int) error

SetIndepByName appends independent variables by variable names

func (*MulTS) SetLag

func (ts *MulTS) SetLag(k int) error

SetLag sets the lag length

func (*MulTS) SetNames

func (ts *MulTS) SetNames(vnames []string) error

SetNames sets the names of the variables

Jump to

Keyboard shortcuts

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