Statistical programming, matrix languages, and more

Running LMS regression

Reply
N/A
Posts: 0

Running LMS regression

Hi,

I'm trying to run a LMS regression in SAS/IML, and can successfully get it to run, but I am having trouble controlling the output. I have 15 independent variables and need the output labeled, but it comes out as var1, var2, etc.

Here is what I have:

proc iml ;
use WORK.auto;
read all var {&input &model1} into model1;
title "MODEL 1";
title2 "5% CENTRALITY BY VALUE";
a = model1[1:59,2:16];
b = model1[1:59,1];

optn = j(8,1,.);
optn[2]= 1;
optn[3]= 1;
optn[8]= 1;
call lms(sc,coef,wgt,optn,b,a);
close work.auto;
quit;

If anyone knows how to get the parameter estimates etc in the output to have the variable names, please let me know.

Thanks!
SAS Super FREQ
Posts: 3,630

Re: Running LMS regression

The variable names in the ODS tables are obviously being hard-coded as VAR1-VAR16, and I don't think you can change that portion of the output. The problem, of course, is that the LMS routine takes a matrix of explanatory variable (your 'a' matrix), so it actually doesn't know the names of the data set variables from which the matrix was created.

It would be a good idea to extend the LMS routine to provide the functionality you want.

You can, however, use ODS output to save the tables to a data set and then use the DATA step or PROC IML to rename the variables. If you are interested in that, here is some sample code:

%let input = MPG_Highway;
%let model1 = EngineSize Horsepower Weight Length;

proc iml ;
use Sashelp.cars; /* you'll have this if you have SAS/GRAPH */
read all var {&input &model1} into model1;
close Sashelp.cars;

a = model1[,2:ncol(model1)];
b = model1[,1];
optn = j(8,1,.);
optn[2]= 1; optn[3]= 1; optn[8]= 1;

*ods trace on / listing;
ods output EstCoeff=ParamEst; /* write one or more tables to data sets */
call lms(sc,coef,wgt,optn,b,a);
ods output close;

/* read data with names 'VAR1':'VARn' and 'Intercep' */
use ParamEst;
read all var _NUM_ into x[colname=oldVarNames];
close ParamEst;

/* rewrite data with new names */
varNames = {&model1} || "Intercep";
create ParamEst from x[colname=varNames];
append from x;
close ParamEst;
quit;

proc print data=ParamEst;
run;
N/A
Posts: 0

Re: Running LMS regression

Thanks!
Ask a Question
Discussion stats
  • 2 replies
  • 238 views
  • 0 likes
  • 2 in conversation