Timur Elzhov <Timur.Elzhov at jinr.ru> writes:
> Dear R-experts!
>
> I have y(x) data, dim(y) == dim(x) == c(2000, 2)
> I'd like to fit them with nls:
>
> fit.result <- nls ( y ~ f(x, p1, p2, p3),
> start = list(p1 = ... , p2 = .. , p3 = ..)
> )
>
> Actually I want to fit y[,1] ~ x[,1] and y[,2] ~ x[,2]
> *simulaneously*, with the same parameters set {p1, p2, p3}.
>
> I tried to feed R tha above formula, R errors with:
> >> Error in qr.qty(QR, resid) : qr and y must have the same number
of rows
> I'm sorry, but I don't understand anything about 'qr'.. :-(
The error message is an internal error caused by the mismatch of
dimensions. The nls function assumes that the left hand side of the
formula evaluates to a vector, not a matrix. It happens that the
mismatch is detected within a manipulation of a QR decomposition.
> So, is it posiible to decide my problem with nls()?
> with other fitting function?
You probably want to use the Box-Draper multiresponse parameter
estimation criterion as described in chapter 4 of Bates and Watts,
"Nonlinear Regression Analysis and Its Applications", Wiley, 1988.
There is a generalization of the Gauss-Newton algorithm for
uniresponse nonlinear least squares given there. As far as I know that
algorithm has not been implemented in R.
You may want to try to minimize the determinant of the crossproduct of
the residual matrix directly with nlm or optim. If the matrix of
observed responses is y and the matrix of predicted responses is
f(p1,p2,p3) then the Box-Draper criterion is
prod(svd(y-f(p1,p2,p3), nu=0, nv=0)$d)^2
You wish to minimize that with respect to p1, p2, and p3.