エラーを再現できます。 nls
関数に引数data
がありません。
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
データdf
が作成され、nls関数に渡されます。 I()
の絶縁された式が意図されたものであることを確認してください。
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|)
# a -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 to convergence: 6
# Achieved convergence tolerance: 4.371e-06
絶縁された式については、マニュアルページを参照してください。
?formula
formula
のマニュアルページは
The^operator indicates crossing to the specified degree. For example (a+b+c)^2 is identical to (a+b+c)*(a+b+c) which in turn expands to a formula containing the main effects for a, b and c together with their second-order interactions
は、また、それは、式演算子と算術演算子の間の曖昧さを防ぐために、I()
を使用することを提案することを言います。
が、ここでは式のmanページ
avoid this confusion, the function I() can be used to bracket those portions of a model formula where the operators are used in their arithmetic sense. For example, in the formula y ~ a + I(b+c), the term b+c is to be interpreted as the sum of b and c.
から別の引用はまた、このmanページは
?AsIs
In function formula. There it is used to inhibit the interpretation of operators such as "+", "-", "*" and "^" as formula operators, so they are used as arithmetical operators. This is interpreted as a symbol by terms.formula.
サティッシュを読む価値がある、ありがとう! – aSportsguy
はい、完全に、そして変更はうまくいった!私は貿易によってプログラマーではないので、Rのドキュメントの一部を読むのが難しいか、またはここで特定の構文解を見つけることができます。 。 。 – aSportsguy