データセットに1 - exp(x)
関数を適合させたいが、最初の値に大きな重みを付ける。しかし、次のコードは、このような方法で動作していない。ここで 最初の値に大きな重みを付ける1 - exp(x)を適合させる:R
x <-sqrt((0.05)^2+(0.05)^2)*seq(from = 1, to = 20, by = 1)
y <- c(11,20,27,32,35,36,36.5,25,16,9,4,1,7.87e-16,2.07e-15,-9.36e-16,1.61e-15,-3.81e-16,3.92e-16,7.65e-16,-8.26e-16)
temp <- data.frame(cbind(x,y))
we <- 1/(log1p(seq_along(x)))
# fit non-linear model
mod <- nls(y ~ (1 - exp(a + b * x)), data = temp, start = list(a = 0, b = 0), weights = we)
#add fitted curve
lines(temp$x, predict(mod, list(x = temp$x)))
が出力されます。重みの
おかげで、私のデータが既に掲載されています。 – mountainlake