Implementation of QUANTREG

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Implementation of QUANTREG

Peter Spangler
I have run a the QUANTREG model using a single continuous predictor and dependent variable. My goal is to 1) save the R implementation code 2) calculate the unstandardized predicted value for each case. 

Output:
Quantile=.5       coefficient        lwr bd    upper db
Purch1                 .47                 .44           .50
 

ID   purch1   purch2
1    10          15
2    15           20
3     20          30
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of QUANTREG

Jon K Peck
Goal (1) is not required for goal (2).
You can save the residuals from SPSSINC QUANTREG as a new dataset.  You get one column for each specified quantile.  Since residuals = actual - predicted, you can just subtract the residuals from the actuals to get the predicted values after matching the residuals back to the input dataset.  Since this procedure does not provide for an ID variable, be careful about any case selection before you match back.

I'm not sure how useful this is, though, since you are predicting quantiles.  The mean residual will usually be negative for quantiles less than .5 and positive for quantiles greater than .5.

You can save the basic R code generated by this command, but in this case it isn't very interesting, and it does not include a number of important lines of code.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Peter Spangler <[hidden email]>
To:        [hidden email],
Date:        10/14/2013 11:48 AM
Subject:        [SPSSX-L] Implementation of QUANTREG
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I have run a the QUANTREG model using a single continuous predictor and dependent variable. My goal is to 1) save the R implementation code 2) calculate the unstandardized predicted value for each case. 

Output:
Quantile=.5       coefficient        lwr bd    upper db
Purch1                 .47                 .44           .50
 

ID   purch1   purch2
1    10          15
2    15           20
3     20          30
Reply | Threaded
Open this post in threaded view
|

Re: Implementation of QUANTREG

Peter Spangler
I was curious to save the implementation code for potential use in a sql database, however, that doesn't sound very promising. 

My understanding of the procedure is that for a given quantile the coefficient predicts the change in the dependent variable. 
For example, for quantile=.5 with coefficient = .47, a 1 unit increase in the IV at the .5 quantile predicts a .47 unit increase in the  DV. It is a useful model for tracking the effect of the IV across a distribution with significantly different variance.



On Mon, Oct 14, 2013 at 11:34 AM, Jon K Peck <[hidden email]> wrote:
Goal (1) is not required for goal (2).
You can save the residuals from SPSSINC QUANTREG as a new dataset.  You get one column for each specified quantile.  Since residuals = actual - predicted, you can just subtract the residuals from the actuals to get the predicted values after matching the residuals back to the input dataset.  Since this procedure does not provide for an ID variable, be careful about any case selection before you match back.

I'm not sure how useful this is, though, since you are predicting quantiles.  The mean residual will usually be negative for quantiles less than .5 and positive for quantiles greater than .5.

You can save the basic R code generated by this command, but in this case it isn't very interesting, and it does not include a number of important lines of code.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:        Peter Spangler <[hidden email]>
To:        [hidden email],
Date:        10/14/2013 11:48 AM
Subject:        [SPSSX-L] Implementation of QUANTREG
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I have run a the QUANTREG model using a single continuous predictor and dependent variable. My goal is to 1) save the R implementation code 2) calculate the unstandardized predicted value for each case. 

Output:
Quantile=.5       coefficient        lwr bd    upper db
Purch1                 .47                 .44           .50
 

ID   purch1   purch2
1    10          15
2    15           20
3     20          30

Reply | Threaded
Open this post in threaded view
|

Re: Implementation of QUANTREG

Jon K Peck
The code generated by a sample quantreg usage is just this
quantreg<-
dep<-"salary"
enter<-list("jobcat", "jobtime")
taus<-c(0.25, 0.75)
missing<-"listwise"
method<-"br"
stderr<-"rank"
plot<-FALSE
quantreg(dep, enter, taus, missing, method, stderr, plot, residualsdataset="resids")

To use this in a database that can run R code, you would need to add code to get the data and do something about the residualsdataset parameter.  I don't know what the database would do about displaying the output.  If you pursue this, it would be interesting to see the result.

As for the result understanding, the description is right, but isn't all the information you need for that covered by the coefficients reported for the different quantiles?  It might be useful to have a table presenting the coefficients by quantile for each variable, but if you opt for the plots, you get a nice picture of how the coefficients depend on the quantile.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Peter Spangler <[hidden email]>
To:        Jon K Peck/Chicago/IBM@IBMUS,
Cc:        "[hidden email]" <[hidden email]>
Date:        10/14/2013 12:54 PM
Subject:        Re: [SPSSX-L] Implementation of QUANTREG




I was curious to save the implementation code for potential use in a sql database, however, that doesn't sound very promising. 

My understanding of the procedure is that for a given quantile the coefficient predicts the change in the dependent variable. 
For example, for quantile=.5 with coefficient = .47, a 1 unit increase in the IV at the .5 quantile predicts a .47 unit increase in the  DV. It is a useful model for tracking the effect of the IV across a distribution with significantly different variance.



On Mon, Oct 14, 2013 at 11:34 AM, Jon K Peck <peck@...> wrote:
Goal (1) is not required for goal (2).
You can save the residuals from SPSSINC QUANTREG as a new dataset.  You get one column for each specified quantile.  Since residuals = actual - predicted, you can just subtract the residuals from the actuals to get the predicted values after matching the residuals back to the input dataset.  Since this procedure does not provide for an ID variable, be careful about any case selection before you match back.


I'm not sure how useful this is, though, since you are predicting quantiles.  The mean residual will usually be negative for quantiles less than .5 and positive for quantiles greater than .5.


You can save the basic R code generated by this command, but in this case it isn't very interesting, and it does not include a number of important lines of code.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM

peck@...
phone:
<a href="tel:720-342-5621" target=_blank>720-342-5621




From:        
Peter Spangler <pspangler@...>
To:        
[hidden email],
Date:        
10/14/2013 11:48 AM
Subject:        
[SPSSX-L] Implementation of QUANTREG
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>





I have run a the QUANTREG model using a single continuous predictor and dependent variable. My goal is to 1) save the R implementation code 2) calculate the unstandardized predicted value for each case. 

Output:
Quantile=.5       coefficient        lwr bd    upper db
Purch1                 .47                 .44           .50
 

ID   purch1   purch2
1    10          15
2    15           20
3     20          30


Reply | Threaded
Open this post in threaded view
|

Re: Implementation of QUANTREG

Peter Spangler
Yes, exactly the task I am looking to see through! 

Yes, I can calculate the equation, for example, using the coefficient for quantile .5 and the average for the predictor variable at the .5 quantile. However, I'd like to know how well the model fits -- pseudo r square -- especially because I have  a DV that has non-normally distributed variance.


On Mon, Oct 14, 2013 at 12:49 PM, Jon K Peck <[hidden email]> wrote:
The code generated by a sample quantreg usage is just this
quantreg<-
dep<-"salary"
enter<-list("jobcat", "jobtime")
taus<-c(0.25, 0.75)
missing<-"listwise"
method<-"br"
stderr<-"rank"
plot<-FALSE
quantreg(dep, enter, taus, missing, method, stderr, plot, residualsdataset="resids")

To use this in a database that can run R code, you would need to add code to get the data and do something about the residualsdataset parameter.  I don't know what the database would do about displaying the output.  If you pursue this, it would be interesting to see the result.

As for the result understanding, the description is right, but isn't all the information you need for that covered by the coefficients reported for the different quantiles?  It might be useful to have a table presenting the coefficients by quantile for each variable, but if you opt for the plots, you get a nice picture of how the coefficients depend on the quantile.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: <a href="tel:720-342-5621" value="+17203425621" target="_blank">720-342-5621




From:        Peter Spangler <[hidden email]>
To:        Jon K Peck/Chicago/IBM@IBMUS,
Cc:        "[hidden email]" <[hidden email]>
Date:        10/14/2013 12:54 PM
Subject:        Re: [SPSSX-L] Implementation of QUANTREG




I was curious to save the implementation code for potential use in a sql database, however, that doesn't sound very promising. 

My understanding of the procedure is that for a given quantile the coefficient predicts the change in the dependent variable. 
For example, for quantile=.5 with coefficient = .47, a 1 unit increase in the IV at the .5 quantile predicts a .47 unit increase in the  DV. It is a useful model for tracking the effect of the IV across a distribution with significantly different variance.



On Mon, Oct 14, 2013 at 11:34 AM, Jon K Peck <[hidden email]> wrote:
Goal (1) is not required for goal (2).
You can save the residuals from SPSSINC QUANTREG as a new dataset.  You get one column for each specified quantile.  Since residuals = actual - predicted, you can just subtract the residuals from the actuals to get the predicted values after matching the residuals back to the input dataset.  Since this procedure does not provide for an ID variable, be careful about any case selection before you match back.


I'm not sure how useful this is, though, since you are predicting quantiles.  The mean residual will usually be negative for quantiles less than .5 and positive for quantiles greater than .5.


You can save the basic R code generated by this command, but in this case it isn't very interesting, and it does not include a number of important lines of code.



Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM

[hidden email]
phone:
<a href="tel:720-342-5621" target="_blank">720-342-5621




From:        
Peter Spangler <[hidden email]>
To:        
[hidden email],
Date:        
10/14/2013 11:48 AM
Subject:        
[SPSSX-L] Implementation of QUANTREG
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>





I have run a the QUANTREG model using a single continuous predictor and dependent variable. My goal is to 1) save the R implementation code 2) calculate the unstandardized predicted value for each case. 

Output:
Quantile=.5       coefficient        lwr bd    upper db
Purch1                 .47                 .44           .50
 

ID   purch1   purch2
1    10          15
2    15           20
3     20          30



Reply | Threaded
Open this post in threaded view
|

Re: Implementation of QUANTREG

Jon K Peck
An R squared equivalent for quantile regression is analogous to but different from the R squared for ordinary regression.

This article suggests a definition in section 1.2.

Goodness of Fit and Related Inference Processes for Quantile Regression
Roger Koenker and José A. F. Machado, JASA, 94:448, pp. 1296-1310

I will look into adding this to the SPSSINC QUANTREG output, but I can't promise a date for that.

Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        Peter Spangler <[hidden email]>
To:        Jon K Peck/Chicago/IBM@IBMUS,
Cc:        "[hidden email]" <[hidden email]>
Date:        10/15/2013 04:11 PM
Subject:        Re: [SPSSX-L] Implementation of QUANTREG



Yes, exactly the task I am looking to see through! 

Yes, I can calculate the equation, for example, using the coefficient for quantile .5 and the average for the predictor variable at the .5 quantile. However, I'd like to know how well the model fits -- pseudo r square -- especially because I have  a DV that has non-normally distributed variance.