malmgrek / gammy

:octopus: Generalized additive models in Python with a Bayesian twist
MIT License
77 stars 4 forks source link

Doubt regarding kron() function #6

Closed Simply-Adi closed 2 years ago

Simply-Adi commented 2 years ago

Hello, thank you for this wonderful library. I stumbled upon the kron() function while exploring it. Could you please clarify whether this function is exactly the same as the tensor smooth product as provided in mgcv package of R.

malmgrek commented 2 years ago

Hello, thanks.

Unfortunately I am not an experienced user of the mgcv package, so I cannot exhaustively answer if the concepts are "exactly the same".

Anyway, in this package's Kron, the two input formulae do not have to be smooth: they can be any Gaussian Processes. In layman terms, a multivariate formula with Kronecker structure means that its multivariate GAM basis functions are just products of lower dimensional (e.g. univariate) basis functions which are eigenvectors of the corresponding lower dimensional covariances.

For more info, see [1, 2]

[1] https://github1s.com/malmgrek/gammy/blob/HEAD/gammy/formulae.py#L159-L160 [2] https://docs.pymc.io/en/v3/pymc-examples/examples/gaussian_processes/GP-Kron.html

Simply-Adi commented 2 years ago

Thank you for the prompt reply. Also, gammy does not seem to support multiple predictors other than x and its derived quantities. Please correct me if I am wrong.

malmgrek commented 2 years ago

Gammy supports multiple predictor models through x. In case of multiple 1D predictor variables, each predictor corresponds to a slice x[:, i]. More general models with an arbitrary number of ND predictors (N may vary), can be defined similarly. You can get code examples from here: https://malmgrek.github.io/gammy/features.html#key-features

Or do you mean something else by "multiple predictors"?

Simply-Adi commented 2 years ago

Oh Yes! I found it. Thank you so much.