Displaying 1 result from an estimated 1 matches for "fitnorm_meansd".
Did you mean:
fitnorm_mean
2017 Jun 23
0
optim() has a non-consistent way to send parameter for different methods
...one, of
course, we know which parameter it is, but it makes things
non-consistent between methods.
It would be better that same convention is used for different method.
Marc
Tested in R-3.4.0
For example, here:
@@@@@@@@@@@
Method BFGS
@@@@@@@@@@@
# The names of values in par are transmitted
fitnorm_meansd<-function(par, val) {
print(par)
-sum(dnorm(x=val, mean=par["mean"], sd=par["sd"], log = TRUE))
}
val <- rnorm(100, mean=20, sd=2)
p<-c(mean=20, sd=2)
result<-optim(par=p, fn=fitnorm_meansd, val=val, method="BFGS")
The print(par) shows the named vec...