13 Linear Regression
In this section you will find basic instructions for fitting simple and multiple regression models.
Instructions for fitting a s simple linear regression model in Rguroo:
- Use a dataset in your Rguroo account or recreate the example below by importing the cardata dataset from the Rguroo dataset repository called Rguroo Users Guide into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Use the
Analysis
dropdown menu and choose Linear Regression —> Simple Regression. This will open the Simple Regression dialog box (see Figure 13.1)In the Data section, select a Dataset. Then select your predictor and response variables from the Predictor (x) and Response (y) dropdowns.
(Optional) You can obtain predicted values and residuals by selecting the Predictions & Residuals (Observed data) checkbox. Moreover, you can get predictions for new values and perform tests of hypotheses about correlation and slope and obtain confidence intervals for parameters and mean predictions and prediction intervals using both theory-based and bootstrap methods.
Click the Preview icon to view the result.
Instructions for fitting a multiple linear regression model in Rguroo:
- Use a dataset in your Rguroo account or recreate the example below by importing the cardata dataset from the Rguroo dataset repository called Rguroo Users Guide into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Use the
Analysis
dropdown menu and choose Linear Regression —> Simple & Multiple Regression. This will open the Multiple Regression dialog box (see Figure 13.2).Select a Dataset.
In the Model Specification section, select your response variable from the Response drop down.
In the formula textbox, add your predictors. Predictors must be separated by a + sign. To get a model without an intercept, add -1 to your formula. See R documentation for details on how to specify models with interactions using “*” and “:”.
(Optional) Click the to add additional output, including model estimate and diagnostics graphs, diagnostic indices, fitted values, and prediction intervals.
Click the Preview icon to view the result.
Instructions for obtaining prediction intervals in Rguroo:
- Use a dataset in your Rguroo account or recreate the example below by importing the AirPassengers dataset from the Rguroo dataset repository called R datasets into your account.
Click here to see a portion of the dataset.
Open the Analytics toolbox on the left-hand side of the Rguroo window. Use the
Analysis
dropdown menu and choose Linear Regression —> Simple & Multiple Regression. This will open the Multiple Regression dialog box (see Figure 13.3).Select a Dataset.
In the Model Specification section, select your response variable from the Response dropdown.
In the formula textbox, add your predictors. Predictors must be separated by a + sign. To get a model without an intercept, add -1 to your formula. See R documentation for details on how to specify models with interactions using “*” and “:”.
Click the and select the
Fitted Values, Predictions, and Interval Estimates
tab. Here, move Prediction Interval to theSelected
column using drag-and-drop or the menu arrows.Check one or both of the options Internal Data or External Data. Internal data refers to cases that are used to fit the model. External data refers to cases that are not used to fit the model. You specify the external data by adding them to your dataset and setting the response variable column for these cases to NA.
Click the Preview icon to view the result.