# SAS/STAT Nonparametric Regression Procedure – PROC GAM

## 1. Objective

In our journey of SAS/STAT Tutorials, we learned many types of analysis procedures, today we are going to discuss a SAS/STAT Nonparametric Regression. In this tutorial, we are going to explore the procedures of SAS/STAT Nonparametric Regression: PROC ADAPTIVEREG, PROC GAM, PROC GAMPL, PROC LOESS, and PROC TPSPLINE with examples & syntax.
So, let’s begin with SAS/STAT Nonparametric Regression.

Join DataFlair on Telegram!!

## 2. What is SAS/STAT NonParametric Regression?

SAS/STAT Nonparametric Regression falls under a category of regression analysis where the variable that is to be predicted (predictor) does not take a form that is predetermined but, is constructed from information that is derived from the original data.
In SAS/STAT nonparametric regression, you do not specify the functional form of your choice. You specify the dependent variable, the outcome, and the covariates. Nonparametric Regression in SAS/STAT is basically used for prediction, but it is also reliable even if hypotheses of linear regression are not verified.
Let’s see Top 2 SAS Post Processing Procedure – PROC SCORE & PROC PLM

## 3. Procedures for Non-Parametric Regression in SAS/STAT

Following procedures are used to perform a SAS/STAT Nonparametric Regression of a sample data. Each procedure has a different syntax and is used with different type of data in different contexts. Let us explore each one of these.

The ADAPTIVEREG procedure is useful for building regression models when you have many variables to choose from and the response is either continuous or categorical. It specifically builds nonparametric regression models. It is useful in situations when we want an accurate prediction and the relationship between the predictors and response is unknown.

```PROC ADAPTIVEREG DATASET;
Class variable;
MODEL VARIABLE <options> ;```

```proc adaptivereg data=sashelp.class;
class name;
model age= height weight / dist=normal;
run;```

Read about SAS Nonlinear Regression Procedure – PROC NLIN &amp; PROC TRANSREG

### b. PROC GAM

GAM stands for generalized additive models. It builds models that come under the nonparametric class of regression. In this procedure, there is no assumption of linearity and it is used when the dependent variable is not distributed normally.
Let’s Explore SAS /STAT ANOVA – 8 Procedures for Calculating Analysis of Variance
A Syntax of PROC GAM-

```PROC  GAM dataset <options>;
Class < variable> ;
MODEL <dependent variable>;```

PROC GAM Example-

```proc gam data=sashelp.class;
model age =spline(height)
spline(weight) / dist=normal;
run;```

The keyword spline suggests that there could be nonlinearity in the model and the PROC GAM and MODEL statements are required.

### c. PROC GAMPL

The GAMPL provides a model fitting for generalized additive models, which are highly versatile statistical models that find different applications in different industries. These models are basically used for unknown data which is complex and which exhibits non-linear relationships between the response and the predictors. They can be used for almost all distributions. In SAS/STAT, it can be run in two ways- single machine mode and distributed mode.
Do you know about SAS/STAT Categorical Data Analysis Procedure
A Syntax of PROC GAMPL-

```PROC  GAMPL dataset <options>;
Class < variable> ;
Model  response <(response-options)> = <PARAM(effects)> <spline-effects> </ model-options>;```

PROC GAMPL and MODEL statements are required.
PROC GAMPL Example-

```ods graphics on;
proc gampl data=sashelp.class plots=all;
model age = param(height weight) spline(height)
spline(weight) / dist=poisson;
run;```

### d. PROC LOESS

The PROC LOESS in SAS/STAT performs nonparametric regression. It makes no assumption of parametric form of regression. This procedure is useful when you don’t know the parametric form of data and when there are too many outliers in the data.
A Syntax of PROC LOESS-

```PROC  LOESS dataset <options>;
MODEL <options>;```

PROC LOESS Example-

```ods graphics on;
proc loess data=sashelp.class plots=all;
model age=height;
run;```

Let’s learn 4 Important SAS/STAT Longitudinal Data Analysis Procedures

### e. PROC TPSPLINE

The TPSPLINE procedure is used to fit a nonparametric regression model by using the penalized least squares method. It provides options for handling large data sets, supports multiple dependent variables and enables you to choose a particular model by specifying the model degrees of freedom or smoothing parameter. It fits the data with a flexible model in which the number of effective parameters can be as large as the number of unique design points.
A Syntax of PROC TPSPLINE-

```PROC  TPSPLINE dataset <options>;
MODEL dependents = <variables> (variables)</ options>;```

The PROC TPSPLINE and MODEL statements are required statements.
Let’s revise 6 Important SAS Market Research Procedures
PROC TPSPLINE Example-

```ods graphics on;
proc tpspline data=sashelp.class plots=all;
model age=(height weight)  ;
run;```