This is a similar to question to Trilateration for n points and the enquirer has posted the answer since there were no answers.
From the parent post, the code is shown for Mathematica and has two variables (X,Y) in output.
I am having a difficulty in creating the same function in R using the nls
function.
I have tried the following:
data <- data.frame( signal = c(98,94,66,49),x=c(6,5,4,4),y=c(6,7,7,6))
weighted_distance <- function(signal, y, x)
{
return(y - (signal^-1)*10*x)
}
NLS_x <- nls(y ~ weighted_distance(signal,y,x), data = data,start = list(x=2,y=1))
I am getting the following error:
Error in numericDeriv(form[[3L]], names(ind), env) :
'Missing value or an infinity produced when evaluating the model'
I understand that the formula written in the code is incorrect as the denominator is taken directly as the signal rather than multiplying with a constant signifying the distance.
But I do not understand how to proceed with the problem and represent it in a simpler way for the weighted non-linear squares estimation in R.