# Minitab Help 13: Weighted Least Squares & Logistic Regressions

Minitab Help 13: Weighted Least Squares & Logistic Regressions##
Minitab^{®}

## Galton peas (nonconstant variance and weighted least squares)

- Perform a linear regression analysis to fit an ordinary least squares (OLS) simple linear regression model of Progeny vs Parent (click "Storage" in the regression dialog to store fitted values).
- Select Calc > Calculator to calculate the weights variable = \(1/SD^{2}\) and Perform a linear regression analysis to fit a weighted least squares (WLS) model (click "Options" in the regression dialog to set the weights variable and click "Storage" to store fitted values).
- Create a basic scatterplot< of the data and click Editor > Add > Calculated Line to add a regression line for each model using the stored fitted values.

## Computer-assisted learning (nonconstant variance and weighted least squares)

- Create a basic scatterplot of the data.
- Perform a linear regression analysis to fit an OLS model (click "Storage" to store the residuals and the fitted values).
- Create a basic scatterplot of the OLS residuals vs num.responses.
- Select Calc > Calculator to calculate the absolute residuals and Create a basic scatterplot of the absolute OLS residuals vs num.responses.
- Perform a linear regression analysis of absolute residuals vs num.responses (click "Storage" to store the fitted values).
- Select Calc > Calculator to calculate the weights variable = \(1/(\text{fitted values})^{2}\), Perform a linear regression analysis to fit a WLS model (click "Options" to set the weights variable and click "Storage" to store standardized residuals and fitted values).
- Create a basic scatterplot< of the data and click Editor > Add > Calculated Line to add a regression line for each model using the stored fitted values.
- Create a basic scatterplot of the WLS standardized residuals vs num.responses.

## Market share (nonconstant variance and weighted least squares)

- Perform a linear regression analysis to fit an OLS model (click "Storage" to store the residuals and fitted values).
- Create a basic scatterplot of the OLS residuals vs fitted values but select "With Groups" to mark the points by Discount.
- Select Stat > Basic Statistics > Display Descriptive Statistics to calculate the residual variance for Discount=0 and Discount=1.
- Select Calc > Calculator to calculate the weights variable = 1/variance for Discount=0 and Discount=1, Perform a linear regression analysis to fit a WLS model (click "Options" to set the weights variable and click "Storage" to store standardized residuals and fitted values).
- Create a basic scatterplot of the WLS standardized residuals vs fitted values.

## Home price (nonconstant variance and weighted least squares)

- Select Calc > Calculator to calculate log transformations of the variables.
- Perform a linear regression analysis to fit an OLS model (click "Storage" to store the residuals and fitted values).
- Create a basic scatterplot of the OLS residuals vs fitted values.
- Perform a linear regression analysis of absolute residuals vs fitted values (click "Storage" to store the fitted values).
- Select Calc > Calculator to calculate the weights variable = \(1/(\text{fitted values})^{2}\), Perform a linear regression analysis to fit a WLS model (click "Options" to set the weights variable and click "Storage" to store standardized residuals and fitted values).
- Create a basic scatterplot of the WLS standardized residuals vs fitted values.

### Leukemia remission (logistic regression)

- Select Stat > Regression > Binary Logistic Regression > Fit Binary Logistic Model, make sure "Response in binary response/frequency format" is selected, put REMISS in the "Response" box, and put CELL, SMEAR, INFIL, LI, BLAST, and TEMP in the "Continuous predictors" box. Before clicking "OK," click "Results" and select "Expanded tables" for "Display of results."
- Repeat but with just LI as a single predictor.
- Fit a logistic regression model of REMISS vs LI.
- Select Stat > Regression > Binary Fitted Line Plot to create a scatterplot of REMISS vs LI with a fitted line based on the logistic regression model.
- Before clicking "OK" in the Regression Dialog, click "Options" and type "10" into the box labeled "Number of groups for Hosmer-Lemeshow test." This will result in a new table in the output titled "Goodness-of-Fit Tests" with results for Deviance (not valid for this example), Pearson (also not valid for this example), and Hosmer-Lemeshow goodness-of-fit tests.
- Before clicking "OK" in the Regression Dialog, click "Graphs" and select "Residuals versus Order" to create residual plots using deviance residuals. To change to Pearson residuals, click "Options" in the Regression Dialog and select "Pearson" for "Residuals for diagnostics."

### Disease outbreak (logistic regression)

- Select Stat > Regression > Binary Logistic Regression > Fit Binary Logistic Model, make sure "Response in binary response/frequency format" is selected, put Disease in the "Response" box, and put Age, Middle, Lower, and Sector in the "Continuous predictors" box. Before clicking "OK," click "Model," shift-select the four predictors in the top-left box, click "Add" next to "Interactions through order 2," but remove the "Middle*Lower" interaction from the "Terms in the model" box since it is meaningless.
- Repeat but with the five interactions removed.
- Repeat but with the five interactions included and before clicking "OK," click "Options" and select "Sequential (Type I)" for "Deviances for tests."

### Toxicity and insects (logistic regression using event/trial data format)

- Select Stat > Regression > Binary Logistic Regression > Fit Binary Logistic Model, select "Response in event/trial format," put Deaths in the "Number of events" box, put SampSize in the "Number of trials" box, and put "Dose" in the "Continuous predictors" box. Change "Event name" to "Death" if you like (optional). Before clicking "OK," click "Results" and select "Expanded tables" for "Display of results."
- Select Calc > Calculator to calculate observed probabilities as Deaths/SampSize.
- Before clicking "OK" in the Regression Dialog, click "Storage" and select "Fits (event probabilities)."
- Select Stat > Regression > Binary Fitted Line Plot to create a scatterplot of observed probabilities vs Dose with a fitted line based on the logistic regression model.

### Poisson example (Poisson regression)

- Select Graph > Scatterplot to create a scatterplot of the data.
- Select Stat > Regression > Poisson Regression > Fit Poisson Model, put y in the "Response" box, and put x in the "Continuous predictors" box. Before clicking "OK," click "Results" and select "Expanded tables" for "Display of results."
- Before clicking "OK" in the Regression Dialog, click "Graphs" and select "Residuals versus Fits" to create residual plots using deviance residuals. To change to Pearson residuals, click "Options" in the Regression Dialog and select "Pearson" for "Residuals for diagnostics."