[R] nls question

Göran Broström gb at stat.umu.se
Tue Feb 15 00:26:08 CET 2000


I have two functions, tids1 and tids2:

tids1 <- function(W, w)
  {
    nls(W ~ w %*% beta,
        data = parent.frame(0),
        start = list(beta = rep(0, ncol(w)) ) )
}
    
tids2 <- function(W, w)
{
  X.1 <- w[, 1]
  X.2 <- w[, 2]
  
  nls(W ~ X.1 * beta1 + X.2 * beta2,
      data = parent.frame(0),
      start = list(beta1 = 0, beta2 = 0))
}

I want something like tids1, but only tids2 works:

> tids1(Y, X)
Error in qr.qty(QR, resid) : qr and y must have the same number of rows

> tids2(Y, X)
Nonlinear regression model
  model:  W ~ X.1 * beta1 + X.2 * beta2 
   data:  parent.frame 0 
   beta1    beta2 
1.200331 1.027278 
 residual sum-of-squares:  5.358129 

Q: How do I write a _general_ tids2?
----------------------------------------------------------
 Göran Broström                      tel: +46 90 786-5223
 Department of Statistics            fax: +46 90 786-6614
 Umeå University                                         
 SE-90187 Umeå, Sweden              email: gb at stat.umu.se
                                                        
 http://www.stat.umu.se/egna/gb    ftp://capa.stat.umu.se
----------------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list