non linear regression - R Error: parameters without starting value -


non linear real world data, n=2,600

sample  x values    71.33   74.98   80  85.35   90.03 y values    119.17  107.73  99.72   75  54.59 

i manually graphed formula starting point,

formula:  y = b/x^2+a manual:   y = 800000/x^2-39.5 sum of residuals = 185 correlation forecast actual =0.79  

using nls formula in r, error message:

a_start = -39.5 b_start = 800000 m<-nls(y~b/(x^2)+a, start=list(a=a_start,b=b_start))  error in nls(y~ b/(x^2) + a, start = list(a = a_start, b = b_start)) :  parameters without starting value in 'data': y, x 

not sure missing here.

i can reproduce error. nls function missing argument data in it.

 m<-nls(y ~ b/(x^2)+a, start=list(a=a_start, b=b_start))  # error in nls(y ~ b/(x^2) + a, start = list(a = a_start, b = b_start)) :   # parameters without starting value in 'data': y, x 

now data df created , passed nls function. make sure, insulated expression in i() intended one.

df <- data.frame(x = c(71.33,   74.98 ,  80 , 85.35  , 90.03),                  y = c(119.17,  107.73 , 99.72 ,  75,  54.59)) a_start <- -39.5 b_start <- 800000 m <- nls(y ~ i(b/(x^2+a)), data = df, start=list(a=a_start, b=b_start))  summary(m)  # formula: y ~ i(b/(x^2 + a)) #  # parameters: #   estimate std. error t value pr(>|t|)   #  -1743.2      872.5  -1.998   0.1396   # b 412486.2    89981.4   4.584   0.0195 * #   --- #   signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #  # residual standard error: 9.103 on 3 degrees of freedom #  # number of iterations convergence: 6  # achieved convergence tolerance: 4.371e-06 

read formula man page insulated expression.

?formula 

the man page of formula says

the ^ operator indicates crossing specified degree. example (a+b+c)^2 identical (a+b+c)*(a+b+c) in turn expands formula containing main effects a, b , c second-order interactions

also suggests using i() prevent ambiguity between formula operators , arithmetic operators.

here quote formula man page

avoid confusion, function i() can used bracket portions of model formula operators used in arithmetic sense. example, in formula y ~ + i(b+c), term b+c interpreted sum of b , c.

also man page worth reading

 ?asis 

in function formula. there used inhibit interpretation of operators such "+", "-", "*" , "^" formula operators, used arithmetical operators. interpreted symbol terms.formula.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -