Documentation
¶
Overview ¶
`stats` package provides functions for statistical analysis.
Index ¶
- Constants
- func BartlettSphericity(dataTable insyra.IDataTable) (chiSquare float64, pValue float64, df int, err error)
- func CalculateMoment(dl insyra.IDataList, n int, central bool) (float64, error)
- func CorrelationAnalysis(dataTable insyra.IDataTable, method CorrelationMethod) (corrMatrix *insyra.DataTable, pMatrix *insyra.DataTable, chiSquare float64, ...)
- func CorrelationMatrix(dataTable insyra.IDataTable, method CorrelationMethod) (corrMatrix *insyra.DataTable, pMatrix *insyra.DataTable, err error)
- func Covariance(dlX, dlY insyra.IDataList) (float64, error)
- func CutTreeByHeight(tree *HierarchicalResult, h float64) ([]int, error)
- func CutTreeByK(tree *HierarchicalResult, k int) ([]int, error)
- func Diag(x any, dims ...int) (any, error)
- func Kurtosis(data any, method ...KurtosisMethod) (float64, error)
- func Skewness(sample any, method ...SkewnessMethod) (float64, error)
- type ANOVAResultComponent
- type AgglomerativeMethod
- type AlternativeHypothesis
- type BartlettTestResult
- type ChiSquareTestResult
- type CorrelationMethod
- type CorrelationResult
- type DBSCANOptions
- type DBSCANResult
- type EffectSizeEntry
- type ExponentialRegressionResult
- type FTestResult
- func BartlettTest(groups []insyra.IDataList) (*FTestResult, error)
- func FTestForNestedModels(rssReduced, rssFull float64, dfReduced, dfFull int) (*FTestResult, error)
- func FTestForRegression(ssr, sse float64, df1, df2 int) (*FTestResult, error)
- func FTestForVarianceEquality(data1, data2 insyra.IDataList) (*FTestResult, error)
- func LeveneTest(groups []insyra.IDataList) (*FTestResult, error)
- type FactorAnalysisOptions
- type FactorAnalysisResult
- type FactorCountMethod
- type FactorCountSpec
- type FactorExtractionMethod
- type FactorModel
- type FactorRotationMethod
- type FactorRotationOptions
- type FactorScoreMethod
- type FriedmanTestResult
- type GLMFamily
- type GLMLink
- type GLMOptions
- type GLMResult
- type HierarchicalResult
- type KMeansOptions
- type KMeansResult
- type KNNAlgorithm
- type KNNClassificationResult
- type KNNNeighborsResult
- type KNNOptions
- type KNNRegressionResult
- type KNNWeighting
- type KruskalWallisResult
- type KurtosisMethod
- type LinearRegressionResult
- type LogarithmicRegressionResult
- type LogisticRegressionOptions
- type LogisticRegressionResult
- type MannWhitneyUResult
- type OneWayANOVAResult
- type PCAResult
- type PoissonRegressionOptions
- type PoissonRegressionResult
- type PolynomialRegressionResult
- type PredictType
- type RepeatedMeasuresANOVAResult
- type SeparationPolicy
- type SilhouettePoint
- type SilhouetteResult
- type SkewnessMethod
- type TTestResult
- func PairedTTest(data1, data2 insyra.IDataList, confidenceLevel ...float64) (*TTestResult, error)
- func SingleSampleTTest(data insyra.IDataList, mu float64, confidenceLevel ...float64) (*TTestResult, error)
- func TwoSampleTTest(data1, data2 insyra.IDataList, equalVariance bool, confidenceLevel ...float64) (*TTestResult, error)
- type TwoWayANOVAResult
- type VarimaxAlgorithm
- type WilcoxonTestResult
- type ZTestResult
Constants ¶
const ( KNNUniformWeighting KNNWeighting = "uniform" KNNDistanceWeighting KNNWeighting = "distance" KNNAuto KNNAlgorithm = "auto" KNNBruteForce KNNAlgorithm = "brute" KNNKDTree KNNAlgorithm = "kd_tree" KNNBallTree KNNAlgorithm = "ball_tree" )
Variables ¶
This section is empty.
Functions ¶
func BartlettSphericity ¶ added in v0.2.2
func BartlettSphericity(dataTable insyra.IDataTable) (chiSquare float64, pValue float64, df int, err error)
BartlettSphericity performs Bartlett's test of sphericity.
func CalculateMoment ¶ added in v0.0.3
CalculateMoment calculates the n-th moment of the DataList. If central is true, it computes the central moment; otherwise, raw moment.
func CorrelationAnalysis ¶ added in v0.2.2
func CorrelationAnalysis(dataTable insyra.IDataTable, method CorrelationMethod) (corrMatrix *insyra.DataTable, pMatrix *insyra.DataTable, chiSquare float64, pValue float64, df int, err error)
CorrelationAnalysis calculates correlation matrix, p-value matrix and Bartlett test.
func CorrelationMatrix ¶ added in v0.2.2
func CorrelationMatrix(dataTable insyra.IDataTable, method CorrelationMethod) (corrMatrix *insyra.DataTable, pMatrix *insyra.DataTable, err error)
CorrelationMatrix calculates the correlation coefficient matrix and p-value matrix.
Performance notes: extracts every column's float64 slice exactly once (dropping the previous O(C²) ToF64Slice + AtomicDo work), pre-computes per-column ranks for Spearman, then computes the C(C-1)/2 unique pairs in parallel on those cached slices. Result is bit-identical to the previous serial path: the underlying primitives are the same, only the order / granularity of work differs.
func CutTreeByHeight ¶ added in v0.2.17
func CutTreeByHeight(tree *HierarchicalResult, h float64) ([]int, error)
func CutTreeByK ¶ added in v0.2.17
func CutTreeByK(tree *HierarchicalResult, k int) ([]int, error)
Types ¶
type ANOVAResultComponent ¶ added in v0.2.0
type AgglomerativeMethod ¶ added in v0.2.17
type AgglomerativeMethod string
const ( AggloComplete AgglomerativeMethod = "complete" AggloSingle AgglomerativeMethod = "single" AggloAverage AgglomerativeMethod = "average" AggloWardD AgglomerativeMethod = "ward.D" AggloWardD2 AgglomerativeMethod = "ward.D2" AggloMcQuitty AgglomerativeMethod = "mcquitty" AggloMedian AgglomerativeMethod = "median" AggloCentroid AgglomerativeMethod = "centroid" )
type AlternativeHypothesis ¶ added in v0.2.0
type AlternativeHypothesis string
const ( TwoSided AlternativeHypothesis = "two-sided" Greater AlternativeHypothesis = "greater" Less AlternativeHypothesis = "less" )
type BartlettTestResult ¶ added in v0.2.6
type BartlettTestResult struct {
ChiSquare float64 // Chi-square statistic
DegreesOfFreedom int // Degrees of freedom
PValue float64 // P-value
SampleSize int // Sample size
}
BartlettTestResult contains the results of Bartlett's test of sphericity
type ChiSquareTestResult ¶ added in v0.0.6
type ChiSquareTestResult struct {
// a DataTable representing the contingency table([2]float64{observed, expected})
ContingencyTable *insyra.DataTable
// contains filtered or unexported fields
}
func ChiSquareGoodnessOfFit ¶ added in v0.2.0
func ChiSquareGoodnessOfFit(input insyra.IDataList, p []float64, rescaleP bool) (*ChiSquareTestResult, error)
ChiSquareGoodnessOfFit performs a one-dimensional chi-square goodness of fit test.
input: A DataList containing categorical data (e.g., ["A", "B", "A"]). p: Expected probabilities (e.g., []float64{0.5, 0.5}). If nil, assumes uniform distribution. rescaleP: Whether to rescale p to sum to 1.
func ChiSquareIndependenceTest ¶ added in v0.2.0
func ChiSquareIndependenceTest(rowData, colData insyra.IDataList) (*ChiSquareTestResult, error)
ChiSquareIndependenceTest performs a chi-square test of independence.
func (*ChiSquareTestResult) Show ¶ added in v0.2.6
func (r *ChiSquareTestResult) Show()
type CorrelationMethod ¶ added in v0.0.4
type CorrelationMethod int
CorrelationMethod specifies which correlation coefficient to compute.
const ( PearsonCorrelation CorrelationMethod = iota KendallCorrelation SpearmanCorrelation )
type CorrelationResult ¶ added in v0.2.0
type CorrelationResult struct {
// contains filtered or unexported fields
}
func Correlation ¶ added in v0.0.4
func Correlation(dlX, dlY insyra.IDataList, method CorrelationMethod) (*CorrelationResult, error)
Correlation calculates correlation between two IDataLists.
type DBSCANOptions ¶ added in v0.2.17
type DBSCANOptions struct {
BorderPoints *bool
}
type DBSCANResult ¶ added in v0.2.17
func DBSCAN ¶ added in v0.2.17
func DBSCAN(dataTable insyra.IDataTable, eps float64, minPts int, opts ...DBSCANOptions) (*DBSCANResult, error)
type EffectSizeEntry ¶ added in v0.2.0
type ExponentialRegressionResult ¶ added in v0.2.2
type ExponentialRegressionResult struct {
Intercept float64
Slope float64
Residuals []float64
RSquared float64
AdjustedRSquared float64
StandardErrorIntercept float64
StandardErrorSlope float64
TValueIntercept float64
TValueSlope float64
PValueIntercept float64
PValueSlope float64
ConfidenceIntervalIntercept [2]float64
ConfidenceIntervalSlope [2]float64
}
ExponentialRegressionResult holds the result of exponential regression y = a*e^(b*x).
func ExponentialRegression ¶ added in v0.2.2
func ExponentialRegression(dlY, dlX insyra.IDataList) (*ExponentialRegressionResult, error)
ExponentialRegression performs y = a*e^(b*x) regression.
type FTestResult ¶ added in v0.0.6
type FTestResult struct {
DF2 float64 // degree of freedom for the second group
// contains filtered or unexported fields
}
func BartlettTest ¶ added in v0.2.0
func BartlettTest(groups []insyra.IDataList) (*FTestResult, error)
BartlettTest performs Bartlett's test for equality of variances.
func FTestForNestedModels ¶ added in v0.2.0
func FTestForNestedModels(rssReduced, rssFull float64, dfReduced, dfFull int) (*FTestResult, error)
FTestForNestedModels compares two nested regression models.
func FTestForRegression ¶ added in v0.2.0
func FTestForRegression(ssr, sse float64, df1, df2 int) (*FTestResult, error)
FTestForRegression performs an overall F-test for a regression model.
func FTestForVarianceEquality ¶ added in v0.0.6
func FTestForVarianceEquality(data1, data2 insyra.IDataList) (*FTestResult, error)
FTestForVarianceEquality performs an F-test for variance equality.
func LeveneTest ¶ added in v0.2.0
func LeveneTest(groups []insyra.IDataList) (*FTestResult, error)
LeveneTest performs Levene's test for equality of variances across groups.
type FactorAnalysisOptions ¶ added in v0.2.6
type FactorAnalysisOptions struct {
Count FactorCountSpec
Extraction FactorExtractionMethod
Rotation FactorRotationOptions
Scoring FactorScoreMethod
MaxIter int // Optional: default 100
MinErr float64 // Optional: default 0.001 (R's min.err)
// OptimFactr controls the L-BFGS-B convergence tolerance used by ML
// and MINRES factor extraction: the optimizer terminates when the
// relative function change drops below OptimFactr * machine epsilon.
// Defaults to 1e7 (≈2.2e-9 absolute), matching R psych::fa /
// stats::optim's "moderate accuracy" default. Use 1 for machine
// precision (≈2.2e-16) when you want the true stationary point on
// near-Heywood / flat objective surfaces; the default terminates
// prematurely on those problems and settles at a non-stationary
// boundary point. Use 1e12 for low precision (faster).
OptimFactr float64
// OptimMaxIter caps L-BFGS-B iterations for ML / MINRES extraction.
// Defaults to 100 (matching R stats::optim default). Increase for
// ill-conditioned problems where the optimizer would otherwise hit
// the iteration cap before converging.
OptimMaxIter int
}
FactorAnalysisOptions contains all options for factor analysis
func DefaultFactorAnalysisOptions ¶ added in v0.2.6
func DefaultFactorAnalysisOptions() FactorAnalysisOptions
DefaultFactorAnalysisOptions returns default options for factor analysis. Defaults align with R's psych::fa function defaults.
type FactorAnalysisResult ¶ added in v0.2.6
type FactorAnalysisResult struct {
Loadings insyra.IDataTable // Loading matrix (variables x factors)
UnrotatedLoadings insyra.IDataTable // Unrotated loading matrix (variables x factors)
Structure insyra.IDataTable // Structure matrix (variables x factors)
Uniquenesses insyra.IDataTable // Uniqueness vector (p x 1)
Communalities insyra.IDataTable // Communality table (p x 1: Extraction)
SamplingAdequacy insyra.IDataTable // KMO overall index and per-variable MSA values
BartlettTest *BartlettTestResult // Bartlett's test of sphericity summary
Phi insyra.IDataTable // Factor correlation matrix (m x m), nil for orthogonal
RotationMatrix insyra.IDataTable // Rotation matrix (m x m), nil if no rotation
Eigenvalues insyra.IDataTable // Eigenvalues vector (p x 1)
ExplainedProportion insyra.IDataTable // Proportion explained by each factor (m x 1)
CumulativeProportion insyra.IDataTable // Cumulative proportion explained (m x 1)
Scores insyra.IDataTable // Factor scores (n x m), nil if not computed
ScoreCoefficients insyra.IDataTable // Factor score coefficient matrix (variables x factors)
ScoreCovariance insyra.IDataTable // Factor score covariance matrix (factors x factors)
Converged bool
RotationConverged bool
Iterations int
CountUsed int
Messages []string
}
FactorAnalysisResult contains the output of factor analysis
func (*FactorAnalysisResult) Show ¶ added in v0.2.6
func (r *FactorAnalysisResult) Show(startEndRange ...any)
Show prints everything in the FactorAnalysisResult
type FactorCountMethod ¶ added in v0.2.6
type FactorCountMethod string
FactorCountMethod defines the method for determining number of factors
const ( FactorCountFixed FactorCountMethod = "fixed" FactorCountKaiser FactorCountMethod = "kaiser" )
type FactorCountSpec ¶ added in v0.2.6
type FactorCountSpec struct {
Method FactorCountMethod
FixedK int // Optional: used when Method is CountFixed
EigenThreshold float64 // Optional: default 1.0 for CountKaiser
MaxFactors int // Optional: 0 means no limit
}
FactorCountSpec specifies how to determine the number of factors
type FactorExtractionMethod ¶ added in v0.2.6
type FactorExtractionMethod string
FactorExtractionMethod defines the method for extracting factors. See Docs/stats.md (Factor Analysis - Extraction Methods) for algorithmic details.
const ( FactorExtractionPCA FactorExtractionMethod = "pca" FactorExtractionPAF FactorExtractionMethod = "paf" FactorExtractionML FactorExtractionMethod = "ml" FactorExtractionMINRES FactorExtractionMethod = "minres" )
type FactorModel ¶ added in v0.2.6
type FactorModel struct {
FactorAnalysisResult
}
FactorModel holds the factor analysis model
func FactorAnalysis ¶ added in v0.2.6
func FactorAnalysis(dt insyra.IDataTable, opt FactorAnalysisOptions) (*FactorModel, error)
FactorAnalysis performs factor analysis on a DataTable.
type FactorRotationMethod ¶ added in v0.2.6
type FactorRotationMethod string
FactorRotationMethod defines the method for rotating factors. Rotation families and their properties are documented in Docs/stats.md.
const ( FactorRotationNone FactorRotationMethod = "none" FactorRotationVarimax FactorRotationMethod = "varimax" FactorRotationQuartimax FactorRotationMethod = "quartimax" FactorRotationQuartimin FactorRotationMethod = "quartimin" FactorRotationOblimin FactorRotationMethod = "oblimin" FactorRotationGeominT FactorRotationMethod = "geominT" FactorRotationBentlerT FactorRotationMethod = "bentlerT" FactorRotationSimplimax FactorRotationMethod = "simplimax" FactorRotationGeominQ FactorRotationMethod = "geominQ" FactorRotationBentlerQ FactorRotationMethod = "bentlerQ" FactorRotationPromax FactorRotationMethod = "promax" )
type FactorRotationOptions ¶ added in v0.2.6
type FactorRotationOptions struct {
Method FactorRotationMethod
Kappa float64 // Optional: Promax power (default 4)
Delta float64 // Optional: Oblimin gamma (default 0)
GeominEpsilon float64 // Optional: Geomin delta (default 0.01)
Restarts int // Optional: random orthonormal starts for GPA rotations (default 10)
VarimaxAlgorithm VarimaxAlgorithm // Optional: "kaiser" (psych default) or "gparotation"
}
FactorRotationOptions specifies rotation parameters
type FactorScoreMethod ¶ added in v0.2.6
type FactorScoreMethod string
FactorScoreMethod defines the method for computing factor scores. Scoring equations and trade-offs are outlined in Docs/stats.md.
const ( FactorScoreNone FactorScoreMethod = "none" FactorScoreRegression FactorScoreMethod = "regression" FactorScoreBartlett FactorScoreMethod = "bartlett" FactorScoreAndersonRubin FactorScoreMethod = "anderson-rubin" )
type FriedmanTestResult ¶ added in v0.2.18
type FriedmanTestResult struct {
NSubjects int
KConditions int
// contains filtered or unexported fields
}
FriedmanTestResult holds the result of a Friedman test.
Statistic = Q (Friedman chi^2 with tie correction); DF = k-1 (conditions minus 1); CI is unused (nil); EffectSizes contains Kendall's W coefficient of concordance.
func FriedmanTest ¶ added in v0.2.18
func FriedmanTest(subjects ...insyra.IDataList) (*FriedmanTestResult, error)
FriedmanTest performs the Friedman test on repeated measures. Each IDataList represents one subject's measurements across k conditions (all lists must have the same length k). Ranks are assigned per subject (within each row); the Q statistic is tie-corrected and referred to chi^2 with k-1 degrees of freedom.
** Verified using R **
type GLMOptions ¶ added in v0.2.19
type GLMResult ¶ added in v0.2.19
type GLMResult struct {
Family GLMFamily
Link GLMLink
Coefficients []float64
StandardErrors []float64
ZValues []float64
PValues []float64
ConfidenceIntervals [][2]float64
LinearPredictors []float64
FittedValues []float64
Residuals []float64
PearsonResiduals []float64
DevianceResiduals []float64
Deviance float64
NullDeviance float64
LogLikelihood float64
NullLogLikelihood float64
AIC float64
BIC float64
PearsonChi2 float64
Dispersion float64
DFResidual int
Iterations int
Converged bool
ConfidenceLevel float64
// contains filtered or unexported fields
}
func (*GLMResult) PredictWithOffset ¶ added in v0.2.19
func (r *GLMResult) PredictWithOffset(typ PredictType, offset insyra.IDataList, newXs ...insyra.IDataList) (*insyra.DataList, error)
PredictWithOffset predicts on new data while applying a per-row offset, as required when the model was fit with an offset.
type HierarchicalResult ¶ added in v0.2.17
type HierarchicalResult struct {
Merge [][2]int
Height []float64
Order []int
Labels []string
Method AgglomerativeMethod
DistMethod string
}
func HierarchicalAgglomerative ¶ added in v0.2.17
func HierarchicalAgglomerative(dataTable insyra.IDataTable, method AgglomerativeMethod) (*HierarchicalResult, error)
type KMeansOptions ¶ added in v0.2.17
type KMeansResult ¶ added in v0.2.17
type KMeansResult struct {
Cluster []int
Centers insyra.IDataTable
TotSS float64
WithinSS []float64
TotWithinSS float64
BetweenSS float64
Size []int
Iter int
IFault int
}
func KMeans ¶ added in v0.2.17
func KMeans(dataTable insyra.IDataTable, centers int, opts ...KMeansOptions) (*KMeansResult, error)
type KNNAlgorithm ¶ added in v0.2.17
type KNNAlgorithm string
type KNNClassificationResult ¶ added in v0.2.17
type KNNClassificationResult struct {
Predictions insyra.IDataList
Classes insyra.IDataList
Probabilities insyra.IDataTable
}
func KNNClassify ¶ added in v0.2.17
func KNNClassify(trainData insyra.IDataTable, trainLabels insyra.IDataList, testData insyra.IDataTable, k int, opts ...KNNOptions) (*KNNClassificationResult, error)
type KNNNeighborsResult ¶ added in v0.2.17
func KNearestNeighbors ¶ added in v0.2.17
func KNearestNeighbors(trainData insyra.IDataTable, testData insyra.IDataTable, k int, opts ...KNNOptions) (*KNNNeighborsResult, error)
type KNNOptions ¶ added in v0.2.17
type KNNOptions struct {
Weighting KNNWeighting
Algorithm KNNAlgorithm
LeafSize int
}
type KNNRegressionResult ¶ added in v0.2.17
type KNNRegressionResult struct {
Predictions []float64
}
func KNNRegress ¶ added in v0.2.17
func KNNRegress(trainData insyra.IDataTable, trainTargets insyra.IDataList, testData insyra.IDataTable, k int, opts ...KNNOptions) (*KNNRegressionResult, error)
type KNNWeighting ¶ added in v0.2.17
type KNNWeighting string
type KruskalWallisResult ¶ added in v0.2.18
type KruskalWallisResult struct {
NTotal int
GroupRankSum []float64 // sum of ranks per group, in input order
// contains filtered or unexported fields
}
KruskalWallisResult holds the result of a Kruskal-Wallis H test.
Statistic = H (tie-corrected); DF = k-1 (number of groups minus 1); CI is unused (nil); EffectSizes contains the rank-based epsilon^2.
func KruskalWallis ¶ added in v0.2.18
func KruskalWallis(groups ...insyra.IDataList) (*KruskalWallisResult, error)
KruskalWallis performs the Kruskal-Wallis H test on >= 2 independent samples. Ranks are assigned with mid-rank ties; H is tie-corrected (divided by 1 - Σ(t^3-t)/(N^3-N)) so the asymptotic chi^2 p-value uses the same construction as R kruskal.test.
** Verified using R **
type KurtosisMethod ¶ added in v0.2.0
type KurtosisMethod int
KurtosisMethod defines available kurtosis calculation methods.
const ( KurtosisG2 KurtosisMethod = iota + 1 // Type 1: g2 (default) KurtosisAdjusted // Type 2: adjusted Fisher kurtosis KurtosisBiasAdjusted // Type 3: bias-adjusted )
type LinearRegressionResult ¶ added in v0.0.4
type LinearRegressionResult struct {
Slope float64
Intercept float64
StandardError float64
StandardErrorIntercept float64
TValue float64
TValueIntercept float64
PValue float64
PValueIntercept float64
ConfidenceIntervalIntercept [2]float64
ConfidenceIntervalSlope [2]float64
Coefficients []float64
StandardErrors []float64
TValues []float64
PValues []float64
ConfidenceIntervals [][2]float64
Residuals []float64
RSquared float64
AdjustedRSquared float64
}
LinearRegressionResult holds the result of both simple and multiple linear regression. For simple regression: Coefficients[0] = intercept, Coefficients[1] = slope. For multiple regression: Coefficients[0] = intercept, Coefficients[1:] = slopes.
func LinearRegression ¶ added in v0.0.4
func LinearRegression(dlY insyra.IDataList, dlXs ...insyra.IDataList) (*LinearRegressionResult, error)
LinearRegression performs ordinary least-squares linear regression.
type LogarithmicRegressionResult ¶ added in v0.2.2
type LogarithmicRegressionResult struct {
Intercept float64
Slope float64
Residuals []float64
RSquared float64
AdjustedRSquared float64
StandardErrorIntercept float64
StandardErrorSlope float64
TValueIntercept float64
TValueSlope float64
PValueIntercept float64
PValueSlope float64
ConfidenceIntervalIntercept [2]float64
ConfidenceIntervalSlope [2]float64
}
LogarithmicRegressionResult holds the result of logarithmic regression y = a + b*ln(x).
func LogarithmicRegression ¶ added in v0.2.2
func LogarithmicRegression(dlY, dlX insyra.IDataList) (*LogarithmicRegressionResult, error)
LogarithmicRegression performs y = a + b*ln(x) regression.
type LogisticRegressionOptions ¶ added in v0.2.19
type LogisticRegressionResult ¶ added in v0.2.19
type LogisticRegressionResult struct {
Coefficients []float64
StandardErrors []float64
ZValues []float64
PValues []float64
ConfidenceIntervals [][2]float64
OddsRatios []float64
OddsRatioCIs [][2]float64
LinearPredictors []float64
FittedProbabilities []float64
Residuals []float64
PearsonResiduals []float64
DevianceResiduals []float64
Deviance float64
NullDeviance float64
LogLikelihood float64
NullLogLikelihood float64
AIC float64
BIC float64
McFaddenR2 float64
CoxSnellR2 float64
NagelkerkeR2 float64
DFResidual int
Iterations int
Converged bool
SeparationDetected bool
Penalized bool
Ridge float64
PositiveClass any
ClassLabels []any
ConfidenceLevel float64
// contains filtered or unexported fields
}
func LogisticRegression ¶ added in v0.2.19
func LogisticRegressionWithOptions ¶ added in v0.2.19
func LogisticRegressionWithOptions(opts LogisticRegressionOptions, dlY insyra.IDataList, dlXs ...insyra.IDataList) (*LogisticRegressionResult, error)
func (*LogisticRegressionResult) Predict ¶ added in v0.2.19
func (r *LogisticRegressionResult) Predict(typ PredictType, newXs ...insyra.IDataList) (*insyra.DataList, error)
type MannWhitneyUResult ¶ added in v0.2.18
type MannWhitneyUResult struct {
U1 float64
U2 float64
Z float64 // standardized z (asymptotic path); NaN for exact
Method string // "exact" or "asymptotic"
// contains filtered or unexported fields
}
MannWhitneyUResult holds the result of a Mann-Whitney U test.
Statistic = min(U1, U2). EffectSizes contains rank-biserial r_rb and CLES A12. CI is the Hodges-Lehmann shift CI at the requested level.
func MannWhitneyU ¶ added in v0.2.18
func MannWhitneyU(data1, data2 insyra.IDataList, alt AlternativeHypothesis, confidenceLevel ...float64) (*MannWhitneyUResult, error)
MannWhitneyU performs the Wilcoxon-Mann-Whitney rank-sum test on two independent samples. Returns U1 (for data1) and U2 (for data2); the statistic field is min(U1, U2). The p-value is the alt-adjusted exact or asymptotic p-value for U1.
confidenceLevel is the level for the Hodges-Lehmann shift CI (default 0.95). When neither sample contains ties (in the combined ranking) and both n1, n2 <= 25, the exact distribution is used; otherwise the asymptotic normal with continuity correction and tie adjustment.
** Verified using R **
type OneWayANOVAResult ¶ added in v0.0.7
type OneWayANOVAResult struct {
Factor ANOVAResultComponent
Within ANOVAResultComponent
TotalSS float64
}
func OneWayANOVA ¶ added in v0.0.6
func OneWayANOVA(groups ...insyra.IDataList) (*OneWayANOVAResult, error)
type PCAResult ¶ added in v0.0.8
type PCAResult struct {
Components insyra.IDataTable // component loadings matrix
Eigenvalues []float64
ExplainedVariance []float64
}
PCAResult contains the results of a Principal Component Analysis.
type PoissonRegressionOptions ¶ added in v0.2.19
type PoissonRegressionResult ¶ added in v0.2.19
type PoissonRegressionResult struct {
Coefficients []float64
StandardErrors []float64
ZValues []float64
PValues []float64
ConfidenceIntervals [][2]float64
IncidenceRateRatios []float64
IRRConfidenceIntervals [][2]float64
LinearPredictors []float64
FittedRates []float64
FittedValues []float64
Residuals []float64
PearsonResiduals []float64
DevianceResiduals []float64
Deviance float64
NullDeviance float64
LogLikelihood float64
NullLogLikelihood float64
AIC float64
BIC float64
PearsonChi2 float64
DispersionStatistic float64
OverDispersed bool
DFResidual int
Iterations int
Converged bool
ConfidenceLevel float64
// contains filtered or unexported fields
}
func PoissonRegression ¶ added in v0.2.19
func PoissonRegressionWithOptions ¶ added in v0.2.19
func PoissonRegressionWithOptions(opts PoissonRegressionOptions, dlY insyra.IDataList, dlXs ...insyra.IDataList) (*PoissonRegressionResult, error)
func (*PoissonRegressionResult) Predict ¶ added in v0.2.19
func (r *PoissonRegressionResult) Predict(typ PredictType, newXs ...insyra.IDataList) (*insyra.DataList, error)
func (*PoissonRegressionResult) PredictWithOffset ¶ added in v0.2.19
func (r *PoissonRegressionResult) PredictWithOffset(typ PredictType, offset insyra.IDataList, newXs ...insyra.IDataList) (*insyra.DataList, error)
PredictWithOffset predicts on new data while applying a per-row offset, as required when the model was fit with an offset (e.g. log-exposure rate models).
type PolynomialRegressionResult ¶ added in v0.2.2
type PolynomialRegressionResult struct {
Coefficients []float64
Degree int
Residuals []float64
RSquared float64
AdjustedRSquared float64
StandardErrors []float64
TValues []float64
PValues []float64
ConfidenceIntervals [][2]float64
}
PolynomialRegressionResult holds the result of polynomial regression.
func PolynomialRegression ¶ added in v0.2.2
func PolynomialRegression(dlY, dlX insyra.IDataList, degree int) (*PolynomialRegressionResult, error)
PolynomialRegression performs polynomial regression of given degree.
type PredictType ¶ added in v0.2.19
type PredictType string
const ( PredictLinear PredictType = "linear" PredictResponse PredictType = "response" PredictClass PredictType = "class" )
type RepeatedMeasuresANOVAResult ¶ added in v0.0.8
type RepeatedMeasuresANOVAResult struct {
Factor ANOVAResultComponent
Subject ANOVAResultComponent
Within ANOVAResultComponent
TotalSS float64
}
func RepeatedMeasuresANOVA ¶ added in v0.2.0
func RepeatedMeasuresANOVA(subjects ...insyra.IDataList) (*RepeatedMeasuresANOVAResult, error)
type SeparationPolicy ¶ added in v0.2.19
type SeparationPolicy string
const ( SepWarn SeparationPolicy = "warn" SepError SeparationPolicy = "error" SepRidge SeparationPolicy = "ridge" )
type SilhouettePoint ¶ added in v0.2.17
type SilhouetteResult ¶ added in v0.2.17
type SilhouetteResult struct {
Points []SilhouettePoint
AverageSilhouette float64
}
func Silhouette ¶ added in v0.2.17
func Silhouette(dataTable insyra.IDataTable, labels insyra.IDataList) (*SilhouetteResult, error)
type SkewnessMethod ¶ added in v0.2.0
type SkewnessMethod int
SkewnessMethod defines available skewness calculation methods.
const ( SkewnessG1 SkewnessMethod = iota + 1 // Type 1: G1 (default) SkewnessAdjusted // Type 2: Adjusted Fisher-Pearson SkewnessBiasAdjusted // Type 3: Bias-adjusted )
type TTestResult ¶ added in v0.0.4
type TTestResult struct {
Mean *float64 // mean of the first group (or the only group)
Mean2 *float64 // mean of the second group (nil if not applicable)
MeanDiff *float64 // mean difference (only for paired t-test)
N int // sample size of the first group (or the only group or paired group)
N2 *int // sample size of the second group (nil if not applicable)
// contains filtered or unexported fields
}
func PairedTTest ¶ added in v0.0.4
func PairedTTest(data1, data2 insyra.IDataList, confidenceLevel ...float64) (*TTestResult, error)
PairedTTest performs a paired-samples t-test comparing the means of two related groups. The data must be paired observations (same subjects measured twice). Parameters:
- data1, data2: The paired data groups to compare (must have same length)
- confidenceLevel: (Optional) Confidence level for the confidence interval (e.g., 0.95 for 95%, 0.99 for 99%) Must be between 0 and 1. If not provided or invalid, defaults to 0.95
** Verified using R **
func SingleSampleTTest ¶ added in v0.0.4
func SingleSampleTTest(data insyra.IDataList, mu float64, confidenceLevel ...float64) (*TTestResult, error)
SingleSampleTTest performs a one-sample t-test comparing the sample mean to a known population mean. Parameters:
- data: The sample data to test
- mu: The hypothesized population mean to compare against
- confidenceLevel: (Optional) Confidence level for the confidence interval (e.g., 0.95 for 95%, 0.99 for 99%) Must be between 0 and 1. If not provided or invalid, defaults to 0.95
** Verified using R **
func TwoSampleTTest ¶ added in v0.0.4
func TwoSampleTTest(data1, data2 insyra.IDataList, equalVariance bool, confidenceLevel ...float64) (*TTestResult, error)
TwoSampleTTest performs a two-sample t-test comparing the means of two independent groups. Parameters:
- data1, data2: The two data groups to compare
- equalVariance: Whether to assume equal variances between groups
- confidenceLevel: (Optional) Confidence level for the confidence interval (e.g., 0.95 for 95%, 0.99 for 99%) Must be between 0 and 1. If not provided or invalid, defaults to 0.95
** Verified using R **
type TwoWayANOVAResult ¶ added in v0.0.7
type TwoWayANOVAResult struct {
FactorA ANOVAResultComponent
FactorB ANOVAResultComponent
Interaction ANOVAResultComponent
Within ANOVAResultComponent
TotalSS float64
}
func TwoWayANOVA ¶ added in v0.2.0
func TwoWayANOVA(factorALevels, factorBLevels int, cells ...insyra.IDataList) (*TwoWayANOVAResult, error)
type VarimaxAlgorithm ¶ added in v0.2.6
type VarimaxAlgorithm string
VarimaxAlgorithm specifies which Varimax implementation to use
const ( VarimaxGPArotation VarimaxAlgorithm = "gparotation" // GPArotation::Varimax VarimaxKaiser VarimaxAlgorithm = "kaiser" // stats::varimax / psych::fa rotate="varimax" )
type WilcoxonTestResult ¶ added in v0.2.18
type WilcoxonTestResult struct {
Z float64 // standardized z (asymptotic path); NaN for exact
Method string // "exact" or "asymptotic"
NEffective int // number of nonzero |d_i| used (zeros dropped under "wilcox")
// contains filtered or unexported fields
}
WilcoxonTestResult holds the result of a Wilcoxon signed-rank test.
Statistic = W+ (sum of positive ranks); DF is unused (nil); CI is the Hodges-Lehmann pseudo-median confidence interval at the requested level; EffectSizes contains the matched-pairs rank-biserial correlation.
The asymptotic z and Method ("exact" vs "asymptotic") report which distributional path produced the p-value. For exact mode Z is NaN.
func PairedWilcoxon ¶ added in v0.2.18
func PairedWilcoxon(data1, data2 insyra.IDataList, alt AlternativeHypothesis, confidenceLevel ...float64) (*WilcoxonTestResult, error)
PairedWilcoxon tests whether the median of (data1 - data2) equals 0, using the Wilcoxon signed-rank test on the paired differences.
confidenceLevel is the level for the Hodges-Lehmann pseudo-median CI of the median paired difference (default 0.95). data1 and data2 must have the same length. See SingleSampleWilcoxon for tie / zero handling.
** Verified using R **
func SingleSampleWilcoxon ¶ added in v0.2.18
func SingleSampleWilcoxon(data insyra.IDataList, mu float64, alt AlternativeHypothesis, confidenceLevel ...float64) (*WilcoxonTestResult, error)
SingleSampleWilcoxon tests whether the median of `data` equals `mu`, using the Wilcoxon signed-rank test on (data - mu).
confidenceLevel is the level for the Hodges-Lehmann pseudo-median CI (default 0.95). Zero differences are dropped before ranking (R's wilcox.test default zero-method = "wilcox"); for tied |d_i| values (after dropping zeros) the asymptotic z with continuity correction is used. Otherwise n_eff <= 50 uses the exact distribution.
** Verified using R **
type ZTestResult ¶ added in v0.2.0
type ZTestResult struct {
Mean float64 // mean of the first group (or the only group)
Mean2 *float64 // mean of the second group (nil if not applicable)
N int // sample size of the first group (or the only group)
N2 *int // sample size of the second group (nil if not applicable)
// contains filtered or unexported fields
}
func SingleSampleZTest ¶ added in v0.2.0
func SingleSampleZTest(data insyra.IDataList, mu float64, sigma float64, alternative AlternativeHypothesis, confidenceLevel float64) (*ZTestResult, error)
func TwoSampleZTest ¶ added in v0.2.0
func TwoSampleZTest(data1, data2 insyra.IDataList, sigma1, sigma2 float64, alternative AlternativeHypothesis, confidenceLevel float64) (*ZTestResult, error)
Source Files
¶
- anova.go
- anova_core.go
- chi_square.go
- clustering.go
- consts.go
- correlation.go
- diag.go
- distutil.go
- factor_analysis.go
- ftest.go
- glm_families.go
- glm_irls.go
- glm_links.go
- glm_predict.go
- glm_result_helpers.go
- glmutil.go
- init.go
- knn.go
- kurtosis.go
- mathutil.go
- moments.go
- nonparam_friedman.go
- nonparam_kw.go
- nonparam_mwu.go
- nonparam_wilcoxon.go
- olsutil.go
- pca.go
- rankutil.go
- regression.go
- regression_glm.go
- regression_logistic.go
- regression_poisson.go
- regression_shared.go
- sampleutil.go
- skewness.go
- structs.go
- ttest.go
- types.go
- ztest.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
fa
fa/GPArotation_GPFoblq.go
|
fa/GPArotation_GPFoblq.go |
|
parutil
Package parutil provides lightweight parallel-for primitives used inside the stats package's internal compute paths.
|
Package parutil provides lightweight parallel-for primitives used inside the stats package's internal compute paths. |