Skip to contents

Polynomial feature expansion + OLS via stats::poly + stats::lm. Uses raw (not orthogonal) polynomials for parity with scikit-learn's PolynomialFeatures.

Usage

morie_polynomial_regression(x, y, degree = 2L)

Arguments

x

Numeric vector or matrix.

y

Numeric response.

degree

Polynomial degree.

Value

Named list: estimate, se, feature_names, degree, n, method.

Examples

morie_polynomial_regression(x = rnorm(50), y = rnorm(50))
#> $estimate
#> [1]  0.16375851  0.04168190 -0.02893771
#> 
#> $se
#> [1] 0.17569192 0.11612421 0.07272624
#> 
#> $feature_names
#> [1] "(intercept)" "x0"          "x0^2"       
#> 
#> $degree
#> [1] 2
#> 
#> $n
#> [1] 50
#> 
#> $method
#> [1] "Polynomial regression (degree=2)"
#>