# R Estimate Linear Regression Model without Intercept (Example Code)

In this article you’ll learn how to delete the intercept from a linear regression in R.

## Example Data

```data(iris) # Loading example data head(iris) # Sepal.Length Sepal.Width Petal.Length Petal.Width Species # 1 5.1 3.5 1.4 0.2 setosa # 2 4.9 3.0 1.4 0.2 setosa # 3 4.7 3.2 1.3 0.2 setosa # 4 4.6 3.1 1.5 0.2 setosa # 5 5.0 3.6 1.4 0.2 setosa # 6 5.4 3.9 1.7 0.4 setosa```

## Example: Estimate Linear Regression Model without Intercept

```summary(lm(Sepal.Length ~ 0 + # Specify "0 +" as first predictor Sepal.Width + Petal.Length + Petal.Width + Species, data = iris)) # Call: # lm(formula = Sepal.Length ~ 0 + Sepal.Width + Petal.Length + # Petal.Width + Species, data = iris) # # Residuals: # Min 1Q Median 3Q Max # -0.79424 -0.21874 0.00899 0.20255 0.73103 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # Sepal.Width 0.49589 0.08607 5.761 4.87e-08 *** # Petal.Length 0.82924 0.06853 12.101 < 2e-16 *** # Petal.Width -0.31516 0.15120 -2.084 0.03889 * # Speciessetosa 2.17127 0.27979 7.760 1.43e-12 *** # Speciesversicolor 1.44770 0.28149 5.143 8.68e-07 *** # Speciesvirginica 1.14777 0.35356 3.246 0.00145 ** # --- # Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 # # Residual standard error: 0.3068 on 144 degrees of freedom # Multiple R-squared: 0.9974, Adjusted R-squared: 0.9973 # F-statistic: 9224 on 6 and 144 DF, p-value: < 2.2e-16```

## Further Resources & Related Articles

In addition, you might want to have a look at the related tutorials on my homepage. You can find some posts on related topics such as extracting data and regression models here: