Skip to content

Weighted Optimization

1 message · Jan van der Laan

#
You will have to modify your likelihood in such a way that it also  
includes the weights. If your likelihood has the following form: l =  
sum(log p_i) you could for example add the weights to the likelihood:  
lw = sum(w_i * log p_i) (although I am not sure that this is the  
correct way to add the weights in your case)

Therefore, you will have to change your functions negllh and se to
also accepts the weights as input parameters:

negllh <- function([PARAMETERS YOU HAVE ALREADY HERE], weights, ...) }{ ... }
se <- function([PARAMETERS YOU HAVE ALREADY HERE], weights, ...) { ... }

You can then call optim adding weights as additional parameter which
gets passed on to negllh and se:

gh.fit = try(optim(vega, negllh,hessian = se,pdf = gh.pdf,
           tmp.data = data, transf = transform, const.pars = vars[!opt.pars],
           silent = silent, par.names = names(vars), weights = w, ...))

HTH,

Jan



Quoting JASON SCALLY <j.scally at student.qut.edu.au>: