0% found this document useful (0 votes)
84 views

Nonlinear Model

Non-linear regression models the relationship between dependent and independent variables when the data shows a curvy trend rather than a linear one. It uses a nonlinear function and the nls() function in R to find coefficients that minimize the residual error between the data points and regression line. The confidence intervals produced by nls() indicate how well the initial coefficient values fit the nonlinear model.

Uploaded by

Divya B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views

Nonlinear Model

Non-linear regression models the relationship between dependent and independent variables when the data shows a curvy trend rather than a linear one. It uses a nonlinear function and the nls() function in R to find coefficients that minimize the residual error between the data points and regression line. The confidence intervals produced by nls() indicate how well the initial coefficient values fit the nonlinear model.

Uploaded by

Divya B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

NON- LINEAR MODEL

Non linear regression is used to show the association between response and predictor variable. It is an
extended of linear regression model.
Non - linear regression models have at least one parameter in a dataset as a nonlinear.
Non-Linear regression is a type of polynomial regression. It is a method to model a non -linear
relationship between the dependent and independent variables. It is used in place when the data shows
a curvy trend, and linear regression would not produce very accurate results when compared to non-
linear regression. This is because in linear regression it is pre-assumed that the data is linear.
In non-linear function, the points plotted on the graph are not linear and thus, do not give a curve or
line on the graph. So, non-linear regression analysis is used to alter the parameters of the function to
obtain a curve or regression line that is closed to your data.
Mathematical Formula:

where,
r is residual or error value between 2 points.

Above mathematical function to find minimum residual function can be performed in R


using resid() function.
Regression analysis is widely used in all types of business issues to perform a smart decision or
predicting the future by altering a factor of their business.
To perform this, Non-Linear Least Square approach is used to minimize the total sum of squares of
residual values or error values i.e., the difference between vertical points on the graph from regression
line and will fit the non-linear function accordingly.
In Least Square regression issued to generate a regression model here the computation is begin with a
well - defined model and over some particular values for the coefficients.
nls() function is used to generate more accurate values along with the confidence intervals.
In R Non linear Least Square function is represented as
Syntax
nls(formula, data, start)

• formula : formula with parameter and variables


• data: contains data frame
• start : named list

Example

We will consider a nonlinear model with assumption of initial values of its coefficients. Next we will
see what is the confidence intervals of these assumed values so that we can judge how well these values
fir into the model.
So let's consider the below equation for this purpose −
a = b1*x^2+b2
Let's assume the initial coefficients to be 1 and 3 and fit these values into nls() function.

xvalues <- c(1.6,2.1,2,2.23,3.71,3.25,3.4,3.86,1.19,2.21)


yvalues <- c(5.19,7.43,6.94,8.11,18.75,14.88,16.06,19.12,3.21,7.58)

# Give the chart file a name.


png(file = "nls.png")

# Plot these values.


plot(xvalues,yvalues)

# Take the assumed values and fit into the model.


model <- nls(yvalues ~ b1*xvalues^2+b2,start = list(b1 = 1,b2 = 3))

# Plot the chart with new data by fitting it to a prediction from 100 data points.
new.data <- data.frame(xvalues = seq(min(xvalues),max(xvalues),len = 100))

lines(new.data$xvalues,predict(model,newdata = new.data))

# Save the file.


dev.off()

# Get the sum of the squared residuals.


print(sum(resid(model)^2))

# Get the confidence intervals on the chosen values of the coefficients.


print(confint(model))

When we execute the above code, it produces the following result −


[1] 1.081935
Waiting for profiling to be done...
2.5% 97.5%
b1 1.137708 1.253135
b2 1.497364 2.496484
We can conclude that the value of b1 is more close to 1 while the value of b2 is more close to 2 and not
3.
In R the ’nlstools’ packages provides a number of tools to perform nonlinear regression, the package
have different functions which can help users to create nls() objects and helps to perform experiments.
Feature of ‘nlstools’

• Provide summary intervals, error, estimates and correlation matrix etc.


• Visualization of curves.
• Error models validity.
• Shows the nature of correlation.

You might also like