# Regression Analysis

## Steps

*for example of data set:*

Qn) A developer of food for pig wish to determine what relationship exists among 'age of a pig' when it starts receiving a newly developed food supplement, the inital weight of the pig and the amount of weight it gains in a week period with the food supplement. The following information is the result of study of eight piglets.

| <p>Piglet number<br></p> | <p>Initial weight (pounds)<br>x1</p> | <p>Initial age (weeks)<br>x2</p> | <p>Weight gain<br>y</p> |
| ------------------------ | :----------------------------------: | :------------------------------: | :---------------------: |
| 1                        |                  39                  |                 8                |            7            |
| 2                        |                  52                  |                 6                |            6            |
| 3                        |                  49                  |                 7                |            8            |
| 4                        |                  46                  |                12                |            10           |
| 5                        |                  61                  |                 9                |            9            |
| 6                        |                  35                  |                 6                |            5            |
| 7                        |                  25                  |                 7                |            3            |
| 8                        |                  55                  |                 4                |            4            |

1. Determine the least square equation that best describes these three variables.
2. Calculate the standard error.
3. How much gain in weight of a pig in a week can we expect with the food supplement if it were 9 weeks old and weighed 48 pounds?
4. Test the significance of the regression coefficients abd overall fit of the regression equation.
5. Conduct the residual analysis.
6. Determine partial correlations, multiple correlation and coefficient of multiple determination. Interpret.

* Goto variable view and add the variables

  ![Variable view](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-15d4f18647ef2c970684223c7283390b042f724f%2FvariableView.png?alt=media)
* Goto data view and add the given data.

  ![Data view](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-42f35e175eea84bd9838101a9404cb7b0edfbe72%2FdataView.png?alt=media)
* Click on **Analyze** tab > **Regression** > **Linear**.

  ![Step](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-104f001732fd381a87868a061f13580628162434%2Fstep.png?alt=media)
* Add the dependent variable in **Dependent** and independent variable in **Independent(s)**. Then click **Statistics**.

  ![Dependent List](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-1a7ed805ce5de1b285bcb46a4dc743bb57ccbaf6%2FdependentList.png?alt=media)
* Tick **Estimates**, **Confidence Intervals**, **Model fit**, **R squared change**, **Descriptives**, **Part and partial correlations** and then **Continue**.

  ![Statistics](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-f6d814600146e441010416deb4750a2268e190a6%2Fstatistics.png?alt=media)
* Click **Produce all partial plots** and **Continue**.

  ![Plots](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-ccbef849ed03230e8e3db5bb35fd3f91a19a4736%2Fplots.png?alt=media)
* Click **Unstandarized** in both tabs and **Continue**.

  ![Save](https://1701689154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlhGYIl7VJdlGnlsVvVWa%2Fuploads%2Fgit-blob-f7bf6575e7d258b843d7824ad90f5a6cada8c66f%2Fsave.png?alt=media)
* Required Output:

  [Output site](https://regression-analysis-output.netlify.app/)

  [Output](https://github.com/sthsuyash/CSIT_Labs/blob/main/3rd_Semester/Statistics-II/Regression_Analysis/assets/Output1.spv) to open in SPSS.
