Creating function arguments from a named list (with an application to stats4::mle)

后端 未结 4 1346
难免孤独
难免孤独 2021-02-06 02:20

I should start by saying what I\'m trying to do: I want to use the mle function without having to re-write my log likelihood function each time I want to try a different model s

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-06 03:02

    It might not be what you're looking for, but I would do this as follows:

    mle2(y ~ dnorm(mu, sigma),parameters=list(mu~x1 + x2), data = df,
        start = list(mu = 1,sigma = 1))
    
    mle2(y ~ dnorm(mu,sigma), parameters = list(mu ~ x1), data = df,
        start = list(mu=1,sigma=1))
    

    You might be able to adapt this formulation for a multinomial, although dmultinom might not work -- you might need to write a Dmultinom() that took a matrix of multinomial samples and returned a (log)probability.

提交回复
热议问题