行数制限に引っかかったので、連投失礼します。
> #実験データ
> x1<-c(0,2,5,10,30,50)
> y1<-c(1.538,1.121,0.711,0.572,0.283,0.174)
>
> #基質濃度500µMのときのモデル(a=Vmax,b=Km,c=Ki)
> model <- function(param, xx) param$a*500/(param$b*(1+(xx/param$c))+500)
>
> #残差
> resid <- function(p,observed,xx) observed - model(p,xx)
>
> #実行
> res_nls_exp <- nls.lm(par=list(a=2.5, b=250,c=2), fn=resid, observed=y1, xx=x1, control=nls.lm.control(maxiter=1024, nprint=1))
It. 0, RSS = 0.0752933, Par. = 2.5 250 2
It. 1, RSS = 0.0113508, Par. = 2.23705 234.714 1.72311
It. 2, RSS = 0.0113176, Par. = 2.21444 224.71 1.65984
It. 3, RSS = 0.0113175, Par. = 2.22051 226.667 1.66888
It. 4, RSS = 0.0113175, Par. = 2.21709 225.545 1.66311
It. 5, RSS = 0.0113175, Par. = 2.21709 225.545 1.66311
>
> #パラメータの推定値
> nls_a <- res_nls_exp$par$a
> nls_b <- res_nls_exp$par$b
> nls_c <- res_nls_exp$par$c
>
> #プロット
> plot(x1, y1)
> y_hat <- nls_a*500/(nls_b*(1+(sort(x1)/nls_c))+500)
> lines(sort(x1), y_hat, col=2)
>
> #corとsummry
> cor(y1, y_hat)
[1] 0.99644
> res_nls_exp
Nonlinear regression via the Levenberg-Marquardt algorithm
parameter estimates: 2.2170942384704, 225.545234120354, 1.66310717623034
residual sum-of-squares: 0.01132
reason terminated: Relative error in the sum of squares is at most `ftol'.
> summary(res_nls_exp)
Parameters:
Estimate Std. Error t value Pr(>|t|)
a 2.217e+00 4.957e+06 0 1
b 2.255e+02 1.622e+09 0 1
c 1.663e+00 8.244e+06 0 1
Residual standard error: 0.06142 on 3 degrees of freedom
Number of iterations to termination: 5
Reason for termination: Relative error in the sum of squares is at most `ftol'.
> |
|