0

I'd like to use R to fit a cdf to a set of data points of the form ${ (x_i, y_i) }_{i=1}^N$, where the cdf is taken from a parametric family. (For the sake of illustration, imagine, say, the Beta family of cdfs.)

Ordinarily when fitting a distribution parametrically, one would perhaps use MLE. However, instead of choosing the parameters of the distribution family such that the (log-)likelihood is maximized, I would like to choose them such that a different, arbitrary (non-standard) loss function is minimized.

My overall loss function is still additively separable in that it has the form $\mathcal L = \sum_{i=1}^N \ell(y_i, \hat y_i)$, where $\ell$ measures loss for each observation and where $\hat y_i = F(x_i; \hat{\mathbf\theta})$ is the fitted value obtained from fitting the parametric cdf (with parameter vector $\mathbf\theta$).

Some googling suggests that this is basically M-estimation. So my question is, how do I do this in R? The function $\ell$ can be implemented, but I'm unsure as to how to proceed from there. Are there any packages for this, or should I, for a given parametric family $F(\cdot, \mathbf\theta)$, simply plug $F$ into $\ell$ and use optim() or an alternative (which?) to choose the parameters $\mathbf\theta$ minimizing overall loss?

Thank you!

Edit: I forgot to mention I found this function, but it doesn't allow for arbitrary loss functions.

Side note: it seems that SO, unlike other SX sites, does not support embedded TeX for math. Apologies; I could edit this post, but I feel it's actually easier to mentally parse the TeX commands than to try to recreate the formulas poorly using Markdown.

BestGirl
  • 319
  • 1
  • 13
  • This sounds more like a statistical methods question rather than a specific programming question. Asking for help at [stats.se] would be more appropriate. – MrFlick Jan 23 '23 at 14:39
  • Thanks for the tip. It's really about programming -- "how do I do this in R" --, but you're that other sites may also be helpful. – BestGirl Jan 24 '23 at 08:02
  • Do you know how do do this in other language then? Perhaps provide a reference. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Just asking for package recommendations is still considered off topic. – MrFlick Jan 24 '23 at 15:04

0 Answers0