Visualization of linear model without intercept
To visualize the linear model without intercept, we add zero and plus(+) sign in front of the fitting formula. Then, we use the plot() and the abline() functions to visualize the linear regression model.
Example: Here, is a plot with a linear regression model without the intercept.
R
# sample data frame sample_data <- data.frame ( x1= c (2,3,5,4,8), x2= c (0,3,5,6,23), y= c (1,6,9,15,29)) # fit linear model linear_model <- lm (y~x1+x2+0, data=sample_data) # visualize linear model plot ( sample_data$x1, sample_data$y, col= "blue" , pch=16, xlim= c (0,10)) points ( sample_data$x2, sample_data$y, col= "red" , pch=16 ) abline (linear_model, col= "green" , lwd=2 ) |
Output:
Remove Intercept from Regression Model in R
In this article, we will discuss how to remove intercept from the Regression model in the R Programming Language.
Contact Us