r - nls.lm : Non-numeric argument to binary operator error but all my args are numeric -


i trying run nonlinear least squares regression using minpack.lm:nls.lm. equation minimized e = x - p1*t1 -p2*t2 - svdep , t1 , t2 changed sum of squares of e minimized.

gnfun <- function(x, p1, p2, t1, t2, svdep){   x - p1*t1 - p2*t2 - svdep  } start <- list(t1=-0.1095389, t2=0.02329868) gn2 <- nls.lm(par=start, fn=gnfun, x=x1, p1=p1.1, p2=p1.2,       svdep=epsvd1) error in p1 * t1 : non-numeric argument binary operator  x1     x1           x2           x3           x4           x5           x6  7.725156e-08 7.342344e-08 7.334688e-08 7.572031e-08 7.350000e-08 7.441875e-08      x7           x8           x9          x10  7.388281e-08 7.105000e-08 7.357656e-08 7.028438e-08   epsvd1 [1] 3.210028e-05 3.238753e-05 3.160692e-05 3.270296e-05 3.625271e-05 3.167958e-05 [7] 3.667674e-05 3.317648e-05 3.574715e-05 3.335333e-05  p1.1 [1] 0.001156993 0.001159083 0.001158931 0.001162099 0.001160497 0.001158225 [7] 0.001157901 0.001157770 0.001161935 0.001163280  p1.2 [1] 0.005751636 0.005710543 0.005711749 0.005697742 0.005720252 0.005765593 [7] 0.005759443 0.005778480 0.005759381 0.005712900  class(p1.1) [1] "numeric"  class(p1.2) [1] "numeric"  > class(x1) [1] "numeric"  > class(epsvd1) [1] "numeric" 

i cannot figure out why got error 'non-numeric argument binary operator' p1*t1, though p1 , t1 both numeric .

i appreciate advice why getting error message, , need in order run properly.

you need remember passing list , need pull parameters list using [[:

 gnfun <- function(x, p1, p2, par=par, svdep){                 x - p1*par[[1]] - p2*par[[2]] - svdep            }  start <- list(t1=-0.1095389, t2=0.02329868)  gn2 <- nls.lm(par=start, fn=gnfun, x=x1, p1=p1.1, p2=p1.2,                      svdep=epsvd1)  summary(gn2)  parameters:     estimate std. error t value pr(>|t|) t1  0.003322   0.092779   0.036    0.972 t2 -0.006510   0.018755  -0.347    0.737  residual standard error: 2.019e-06 on 8 degrees of freedom number of iterations termination: 2  reason termination: relative error in sum of squares @ `ftol'. 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -