simstudy icon indicating copy to clipboard operation
simstudy copied to clipboard

User defined distributions

Open assignUser opened this issue 3 years ago • 3 comments

This is of course already possible through using functions in nonrandom distribution. But how about formalizing user defined distributions by allowing to pass either one of the usual dist strings or a double-dot prefixed function name that is then used to generate the data. What do you think @kgoldfeld?

Something like

newDistribution <- function(n, formula, variance, link, dtSim, envir) {
    # some funky new data generation function
}
def <- defData( varname = "ud", dist = "..newDistribution", formula =5)

assignUser avatar Oct 18 '20 18:10 assignUser

It sounds cool in concept - I guess it would be good to come up with a couple of specific examples. Everything that has been introduced into simstudy has had a specific use (for me) or request from someone else, which means they have a specific use in mind. Which is not to say that we can't introduce totally new ideas - but I think they need to be grounded in something tangible - hence the need for an example. And barring any example, maybe we keep the idea around until we do come up with a case to motivate it.

And a more specific questions - how would the data be generated? (Again, a specific example would help here so we could see that in action.)

kgoldfeld avatar Oct 18 '20 18:10 kgoldfeld

I see what you mean.

Well we would just use the provided function via .generate instead of e.g. .genunif. I will think about an example at somepoint 👍

assignUser avatar Oct 18 '20 18:10 assignUser

This was one of the main ideas behind the switch (#75) as it would be much easier to implement new and custom distributions with the new system.

assignUser avatar Jul 08 '21 20:07 assignUser

This has sort of been addressed with the new custom distribution option. I'll keep it open in case the solution does not fully address all the issues here.

kgoldfeld avatar May 13 '24 20:05 kgoldfeld

I think your solution is great and working on a project with 4k open issues has lead me to have a much easier time closing issues :D

assignUser avatar May 14 '24 00:05 assignUser