jakobdambon/varycoef

Good Formula Implementation

Closed this issue · 2 comments

Be able to use formula notation like y ~ (x1 | s1 + ... + sd) + (x2 || s1 + ... + sd) + x3 to define a GP-based SVC model, where:

  • (x1 | s1 + ... + sd) is a fixed and random effect (SVC) with coordinates s1 to sd.
  • (x1 || s1 + ... + sd) like above, but || indicates an SVC without fixed effect / mean.
  • x3 is only a fixed effect without random effect (SVC)

An SVC for the intercept is only added when a 1 is provided.

Gilles has implemented the formula notation in abn. I believe it was too complicated as he has done it from scratch (dissecting the formula argument). Possibly use the standard/"stats" approach as in lm to get the model.matrix stuff and a second iteration for the random part. I am not much of a regexp'er, hence glancing at abn would be inspiring for me.

Calls with formulas are supported in the following way:

  • Use the formula and data argument in the SVC_mle.formula method
  • To differentiate between fixed and random effects, i.e., similar to X and W matrices. Use argument RE_formula to provide other covariates for the random effect than the ones used by argument formula. By default, if RE_formula is not provided, the same as in the argument formula are used.
  • A model trained with a formula call stores formulas. When the predict.SVC_mle method is called, one can provide the data in the argument newdata. Using the formulas stored in the model fit, the covariate matrices for newX and newW are constructed.
  • If newX and newW are already provided, they are overwritten by the covariate matrices obtained from the formulas.