2.4 C
London
Friday, December 20, 2024
HomeSASRegression in SASHow to Perform Quantile Regression in SAS

How to Perform Quantile Regression in SAS

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

Linear regression is a method we can use to understand the relationship between one or more predictor variables and a response variable.

Typically when we perform linear regression, we’re interested in estimating the mean value of the response variable.

However, we could instead use a method known as quantile regression to estimate any percentile value of the response value such as the 30th percentile, 90th percentile, 98th percentile, etc.

To perform quantile regression in SAS we can use the proc quantreg statement.

The following example shows how to perform quantile regression in SAS in practice.

Example: Performing Quantile Regression in SAS

Suppose we have the following dataset in SAS that shows the number of hours studied and corresponding exam score for students in some class:

/*create dataset*/
data original_data;
    input hours score;
    datalines;
1 75
1 79
2 78
2 83
2 85
3 84
3 84
3 89
4 93
4 88
4 79
4 94
5 96
5 98
;
run;

/*view dataset*/
proc print data=original_data;

Next, we’ll fit a quantile regression model using hours studied as the predictor variable and exam score as the response variable.

We’ll use the model to predict the expected 90th percentile of exam scores based on the number of hours studied:

/*perform quantile regression*/
proc quantreg data=original_data;
    model score = hours / quantile = 0.9;
run;

quantile regression in SAS

From the output, we can see the estimated regression equation:

90th percentile of exam score = 76 + 4.5(hours)

For example, the 90th percentile of scores for all students who study 2 hours is expected to be 85:

90th percentile of exam score = 76 + 4.5*(2) = 85.

The output also displays a scatter plot of the raw data with the fitted regression line overlaid on the plot:

Unlike a typical regression model, the fitted line for this regression model goes through the 90th percentile of each value of the predictor variable instead of the mean value.

Additional Resources

The following tutorials explain how to perform other common tasks in R:

How to Perform Simple Linear Regression in R
How to Perform Multiple Linear Regression in R
How to Perform Quadratic Regression in R

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories