DataSlingers / MoMA

MoMA: Modern Multivariate Analysis in R
https://DataSlingers.github.io/MoMA
GNU General Public License v2.0
22 stars 4 forks source link

Absorb parameter values into sparsity-type/smoothness-type specification #43

Open Banana1530 opened 5 years ago

Banana1530 commented 5 years ago

Perhaps a similar sort of thing:

u_smoothness = second_order_difference(select = TRUE)

I used a similar pattern for fusion weights in the clustRviz package: it's a bit tricky to get your head around it, but check it out - might have some useful ideas.

Related, but separate, question: if we go this route, should parameter values be in the object or as a second argument?

Originally posted by @michaelweylandt in https://github.com/michaelweylandt/MoMA/pull/42

michaelweylandt commented 5 years ago

clustRviz is here: https://github.com/DataSlingers/clustRviz

The weights argument there can be two things: either a custom weight matrix or a function which is called on the data to build a weight matrix for that specific problem. We'd definitely want to do something similar because there are times when non-standard smoothing matrices make sense (e.g., in the SFPCA paper, we use great circle distances for points on the cortical surface) but it's worth it to make a convenient shortcut for the 95% case of second difference matrices.

Banana1530 commented 5 years ago

Summarizing, the ideal solution to this issue consists of two parts:

  1. create argument functions for smoothness type; and
  2. put parameter values into argument functions.

How clustRviz does this is clever, using tricks in functional programming.

https://github.com/DataSlingers/clustRviz/blob/93f56ab88675656a81f2bcd13a96e7ff181551b2/R/weights.R#L77

Banana1530 commented 5 years ago

A tentative solution is here:

https://github.com/Banana1530/MoMA-1/commit/a4b64dbf5ea73c8e1e9522cc54a181b2cc189c24

(currently broken due to code formatting issues.)