Hi, everyone.
I need to do a median regression and I believe I should use the procedure iml, which I know nothing about. Below is a sample code I had found online at http://www.ats.ucla.edu/stat/sas/webbooks/reg/chapter4/sasreg4.htm and I need your help in understanding what they are. My comments are in blue color.
proc iml ; /*Least absolute values*/
use elemapi2; I think elemapi2 is the dataset
read all;
a = cons || acs_k3 || acs_46 || full || enroll; so a is the independent variables set. cons is the constant, acs_k3, .... and enroll are all independent variables.
b=api00; api00 is the dependent variable
opt= { . 3 0 1 }; opt seems to mean output, but I have no idea what { . 3 0 1 } is. HELP!
call lav(rc,xr,a,b,,opt); /*print out the estimates*/ what is rc and xr? Does opt mean to print out the estimates?
opt= { . 0 . 1 }; opt again. { . 0 . 1 } seems to mean something different from { . 3 0 1 } . What is it?
call lav(rc,xr,a,b,,opt); /*no print out but to create the xr*/
pred = a*t(xr); Calculate the predicted variable
resid = b - pred; calculate the residual
create _temp_ var { api00 cons acs_k3 acs_46 full enroll pred resid}; create a dataset _temp_ to contain all variables, the predicted, and the residual
append; This seems to have something to do with the dataset just created
quit;
After this is run, the result is something like this.
L1 Solution with ASE
Est 17.1505029 1.2690656888 7.2240793844 5.3238408715 -0.124573396 So the Est. here is the coefficients?
ASE 123.531545 6.3559394265 2.2262729207 0.602359504 0.0391932684 And these are the standard errors?
I know these are really dumb questions. But I'm learning from zero. Thanks ahead for your help!
No one answered so far, so I did a google search and found this: SAS/IML(R) 9.2 User's Guide, and it answered most of my questions above, in case anyone sees this and has similar questions.
When I run my median regression, the SAS first shows me :
LS Solution |
Est | -96561.87302 | -0.246300175 | -2.602601178 | 97923.982407 | 181960.48881 | -4.306466041 |
LS Solution |
Est | 458949.097 | -95.96810113 | 98394.076103 | 2.6046454768 | 61681.495377 | -1.738022118 |
After a bunch of LAV (L1) Estimation, which looks like a matrix, it gives me:
L1 Solution with ASE |
Est | 8766.7195889 | -2.788729523 | 0.5995400876 | -213853.6231 | -15320.23666 | 2.87805056 | |
ASE | 5226.9687913 | 0.4589723826 | 0.4946914915 | 43854.291056 | 11406.063615 | 0.6643844441 |
L1 Solution with ASE |
Est | 40554.202816 | -6.862368128 | 27982.148817 | 2.6542477447 | -5710.519722 | 0.76728223 | |
ASE | 45907.755422 | 4.981493735 | 7780.6349503 | 0.3645178223 | 7090.9258689 | 0.2950026359 |
The LS solution and L1 solution estimates are different. Which are the coefficients I want to use?
And, since I have coefficients and standard errors, I can calculate the t value. But if I want to know the p value, is this the same with OLS regression? I mean, how can I know the F value?
No one answered so far, so I did a google search and found this: SAS/IML(R) 9.2 User's Guide, and it answered most of my questions above, in case anyone sees this and has similar questions.
While coding it all through IML is possible, this looks exactly like what PROC QUANTREG should give you. Take a look at the documentation here:
http://support.sas.com/documentation/cdl/en/statug/63347/HTML/default/viewer.htm#qreg_toc.htm
Steve Denham
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.