r - Least square minimization -
i hope right place such basic question. found this , this solutions quite articulated, hence not me fundamentals of procedure.
consider random dataset:
x <- c(1.38, -0.24, 1.72, 2.25) w <- c(3, 2, 4, 2) how can find value of μ minimizes least squares equation
:
the package manipulate allows manually change bar model different values of μ, looking more precise procedure "try manually until not find best fit".
note: if question not correctly posted, welcome constructive critics.
you proceed follows:
optim(mean(x), function(mu) sum(w * (x - mu)^2), method = "bfgs")$par # [1] 1.367273 here mean(x) initial guess mu.
Comments
Post a Comment