

The larger this number is the better and if it's close to 0, your model is seriously over fit. Degrees of Freedom: Number of observations minus the number of coefficients (including intercepts).For a normal distribution, the 1st and 3rd quantiles should be 1.5 +/- the std error. Residual standard error: standard deviation of the residuals. codes: this is just a legend for the number of stars next to the p-values The stars to the right indicate how "good" the p-value is. Pr(>|t|): p-value, the smaller the value the better.t-value: Indicates if this value is meaningful in the model.Residuals: The min/max and quantiles for the distribution of the residuals, we would expect the "Median" to be near 0Ĭoefficients: The coefficients of the fitted function and how significant they are. Multiple R-squared: 0.6511,Ědjusted R-squared: 0.6438į-statistic: 89.57 on 1 and 48 DF, p-value: 1.49e-12Ĭall: Original function that was executed Residual standard error: 15.38 on 48 degrees of freedom Take some time reviewing the values below with the definitions that follow as this is a typical output from a regression function in R and you'll be seeing a lot of them. There is more information available if you use the summary() function. The image below shows how the coefficients in R relate to the coefficients in a multiple linear equation. The output above shows the original call that was made and the intercept and slope of the line for th linear regression. You can print out the coefficients for the model by just entering the name of the model: Your plot should now appear similar to the one below. We can then add the regression model as a straight line with "a" and "b" parameters with the "abline()" function.


Note that the order is opposite of the "plot()" command. The tilde character (~) indicates that we want to regress speed as the predictor (independent) variable against distance as the response (dependent) variable.
#Linear regression rstudio code#
The code below specifies the column "dist" within the "cars" table and the column "speed". To create a linear model, you can use the "lm()" function. You can also check the length of a vector or matrix with the "length()" function. You can display data by just typing the name of the variable. Enter the code below to make sure the "stats" library is loaded and then plot speed against distance. To get started, we'll load the "stats" library which contains a number of example data sets including a small table of speeds and distances for cars.
