2017-09-21 2 views
0

ダイオードの電圧 - 電流特性(以下のコード)の近似を構築する際に問題がありました。非線形回帰を構築して近似の誤差を見つける方法

library(ggplot2) 
chart <- ggplot() + geom_point(data = mat,aes(x = x, y = y)) + 
stat_smooth(method = 'nls', formula = 'y~a*(exp(x/b) - 1)', 
     method.args = list(start=c(a=0.1646, b=9.5e-8)),se=FALSE) 
chart 

mat

mat <- structure(list(x = c(0, 0.25, 0.27, 0.29, 0.31, 0.33, 0.34, 0.36, 
0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 
0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 
0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68), y = c(4L, 
5L, 6L, 7L, 8L, 10L, 13L, 16L, 20L, 23L, 28L, 37L, 43L, 55L, 
67L, 81L, 94L, 118L, 143L, 187L, 225L, 272L, 340L, 430L, 510L, 
626L, 900L, 1020L, 1220L, 1640L, 1850L, 2360L, 2930L, 3570L, 
4290L, 5000L, 6570L, 7390L, 9230L, 9960L)), .Names = c("x", "y" 
), class = "data.frame", row.names = c(NA, -40L)) 

近似ラインが建設されていません!何が問題ですか?近似誤差を見つけるには?

答えて

1

こんばんは:)

は、私は通常、これらのケースのための初期ggplotにaesdataを置きます。私がそれをしたとき、それは警告を投げた。私はnlsを単独で試してみましたが、そこにエラーがあります。私はこれを調査し、問題を解決してプロットの問題が解決するかどうかを確認することをお勧めします。コード:スロー

chart <- ggplot(data = mat, aes(x = x, y = y)) + geom_point() + 
    stat_smooth(method = 'nls', formula = 'y~a*(exp(x/b) - 1)', 
       method.args = list(start=c(a=0.1646, b=9.5e-8)),se=FALSE) 
chart 

nls('y~a*(exp(x/b) - 1)', mat, start=c(a=0.1646, b=9.5e-8)) 

エラーは次のとおりです。

Error in numericDeriv(form[[3L]], names(ind), env) : 
Missing value or an infinity produced when evaluating the model 

編集:常にあなたの出発点を確認してください。

a=0.1646 
b=9.5e-8 
y <- a*(exp(mat$x/b) - 1) 
y 
plot(mat$x, y) 

形質転換は、私は、スタイルのためのこのリンクをたどっほぼすべてのinfinites

を生成します: https://plot.ly/ggplot2/stat_smooth/

乾杯、 ジョニー

関連する問題