This example uses the LinRegInternal and LinReg functions to find the coefficients of the variables that determine the selling price of a home in a given neighborhood. The response variable, SellingPrice (the selling price of the house in dollars) is modeled on these independent (predictor) variables:
- House size (in square feet)
- Lot size (in square feet)
- Number of bedrooms
- Whether the kitchen counter is granite (0 or 1)
- Whether the bathrooms are upgraded (0 or 1)
Input
housesize | lotsize | bedrooms | granite | upgradedbathroom | sellingprice |
---|---|---|---|---|---|
2397 | 14156 | 4 | 1 | 0 | 189900 |
2200 | 9600 | 4 | 0 | 1 | 195000 |
4032 | 10150 | 5 | 0 | 1 | 197900 |
3529 | 9191 | 6 | 0 | 0 | 205000 |
3247 | 10061 | 5 | 1 | 1 | 224900 |
2983 | 9365 | 5 | 0 | 1 | 230000 |
3536 | 19994 | 6 | 1 | 1 | 325000 |
3198 | 9669 | 5 | 1 | 1 |
The LinRegInternal function skips the last row of housing_data because it contains a NULL value.
SQL Call
SELECT * FROM LinReg ( ON LinRegInternal ( ON housing_data AS "input" ) AS "input" PARTITION BY 1 ) AS dt;
Output
coefficient_name | value_col |
---|---|
Intercept | -21739.2966650368 |
housesize | -26.9307835091457 |
lotsize | 6.33452410459345 |
granite | 7140.67629349537 |
upgradedbathroom | 43179.1998888263 |
bedrooms | 44293.7605841832 |