How to do nonlinear regression with r

Open R, pay attention to install all installed function packages, and then do nonlinear regression with nls function.

For example, estimate the nonlinear regression statistical model.

Steps:

# Read data and view it

f & lt-read.csv(file="D:/XXX.csv ")

f

# Make a scatter plot between x and y

Drawing (f$y~f$x)

# Estimating β 1 and β2 by nls function

nls(f $ y ~ 1/(β 1+β2 * exp(-f $ x)),data=f,start=list(β 1= 1,β2= 1))

# Add a nonlinear regression line

y & lt-f$y

x & lt-f$x

f & lt-function(β 1,β2,x){ 1/(β 1+β2 * exp(-x))}

f . 1 & lt; -function (x){f (β 1, β2, x) with estimation}.

Curve (f. 1, add=T, col="red ")