I would like to use the parameters estimated by the nls function
I am performing a non linear regression on data using the m1<-nls(y1~v1*x/(k1+x))
function.
I can display the predicted v1 and k1 values that are stored in m1.
How can I assign these values to a specific variable (sort of "parameter <- v1")?
v1 and k1 object do not exist ("Error: object 'v1' not found")
>\> m1<-nls(y1~v1*x/(k1+x))
>\> m1
> Nonlinear regression model
> model: y1 ~ v1 * x/(k1 + x)
> data: parent.frame()
> v1 k1
> 16.83 30.05
> residual sum-of-squares: 0.8571
> Number of iterations to convergence: 5
> Achieved convergence tolerance: 1.4e-06
>\> parameter <- v1
>
Error: object 'v1' not found
This gives a vector of coefficients
co <- coef(m1)
and this gives them individually:
v1 <- coef(m1)[["v1"]]
k1 <- coef(m1)[["k1"]]
or if you just want to compute an expression using the coefficients:
with(as.list(coef(m1)), k1 + v1)
This would work to copy all individual elements of coef(m1)
to your workspace:
list2env(as.list(coef(m1)), .GlobalEnv)