Is it possible to do polynomial regression in the GLM-package within Julia? Considering the similarity with R syntax, I had hoped that
fit(LinearModel, @formula(y ~ poly(x,5)), dataset)
would work (for fitting a degree 5 polynomial). It does not.
Although you are explicitly asking for a GLM.jl solution, let me nonetheless point out the straightforward solution using Polynomials.jl:
using Polynomials
polyfit(x, 5)
See polyfit
for more information.
StatsModels.jl does not provide a poly()
function, but their documentation does provide a complete example that shows how you can add your own poly()
function that will work inside the @formula
macro.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With