wls-go

module
v0.0.0-...-47d1e47 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT

README

wls-go

WLS, weighted linear regression in pure Go w/o any 3d party dependencies or frameworks.

How-to
package main

import (
	"fmt"
	"github.com/vspaz/wls-go/pkg/models"
)

func main() {
	xPoints := []float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0}  // ∈ {int8, int16, int32, int, float32, float64}
	yPoints := []float64{1.0, 3.0, 4.0, 5.0, 2.0, 3.0, 4.0}  // ∈ {int8, int16, int32, int, float32, float64}
	weights := []float64{10.0, 1.0, 3.0, 8.0, 14.0, 21.0, 13.0}  // ∈ {int8, int16, int32, int, float32, float64}
	wls := models.NewWlsWithWeights(xPoints, yPoints, weights)  
	point := wls.FitLinearRegression()
	fmt.Println(point.GetSlope())
	fmt.Println(point.GetIntercept())
}

Description

WLS is based on the OLS method and help solve problems of model inadequacy or violations of the basic regression assumptions.

Estimating a linear regression with WLS is useful, but can appear to be daunting w/o special stats packages, such as Python statsmodels or Pandas.

References

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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