SecreC 2 language  2.8.0 (2023.09)
Language and standard library reference
Functions

Functions

template<domain D :shared3p >
D float32 linearRegression (D int32[[2]] variables, D int32[[1]] dependent, int64 method)
 
template<domain D :shared3p >
D float64 linearRegression (D int64[[2]] variables, D int64[[1]] dependent, int64 method)
 
template<domain D :shared3p >
D float32 linearRegression (D float32[[2]] variables, D float32[[1]] dependent, int64 method)
 
template<domain D :shared3p >
D float64 linearRegression (D float64[[2]] variables, D float64[[1]] dependent, int64 method)
 

Detailed Description

Fitting of linear models with multiple explanatory variables.

Note
D - shared3p protection domain
Supported types - int32 / int64 / float32 / float64
You can pass an empty matrix as the variables argument to specify a null model with just intercept.
Parameters
variables- a matrix where each column is a sample of an explanatory variable
dependent- sample vector of dependent variable
method- a constant indicating which algorithm to use (LINEAR_REGRESSION_INVERT, LINEAR_REGRESSION_LU_DECOMPOSITION or LINEAR_REGRESSION_GAUSS)
Returns
returns vector {β_1, β_1, …, β_n} such that y ≈ β_1 * x_1 + β_2 * x_2 + … + β_(n-1) * x_(n-1) + β_n where y is the dependent variable and x_i are the explanatory variables.
Leakage
None

Function Documentation

◆ linearRegression() [1/4]

D float32 linearRegression ( D float32[[2]]  variables,
D float32[[1]]  dependent,
int64  method 
)

◆ linearRegression() [2/4]

D float64 linearRegression ( D float64[[2]]  variables,
D float64[[1]]  dependent,
int64  method 
)

◆ linearRegression() [3/4]

D float32 linearRegression ( D int32[[2]]  variables,
D int32[[1]]  dependent,
int64  method 
)

◆ linearRegression() [4/4]

D float64 linearRegression ( D int64[[2]]  variables,
D int64[[1]]  dependent,
int64  method 
)