- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a predictive linear regression line for a range of independent variable in base R?
If we want to create a regression line inside scatterplot then lines function can be used with the linear model function lm but if we want to do it for a particular range of independent variable then this range needs to be defined and passed within the lines function. Check out the below example of linear regression model that considers a range of independent variable for prediction.
Consider the below vectors −
Defining the range of x −
Adding the regression line for the prediction of range of x values −
- How to create a plot with dashed regression line in base R?
- How to create vertical line for X variable at median in base R plot
- How to create horizontal line for Y variable at median in base R plot?
- How to change the order of independent variables for regression summary output in R?
- Create scatterplot for two dependent variables and one independent variable in R.
- How to perform group-wise linear regression for a data frame in R?
- How to find the confidence interval for the predictive value using regression model in R?
- How to create a boxplot with log of the variable in base R?
- How to create a horizontal line in a histogram in base R?
- How to create a plot of quadratic regression with fitted values against X in base R?
- How to create a list of regression models for predefined vectors in R?
- How to find residual variance of a linear regression model in R?
- How to add a regression line to a plot in base R if intercept and slope are given?
- How to extract p-values for intercept and independent variables of a general linear model in R?
- How to create horizontal line for a range of values in a plot created by using ggplot2 in R?