Advanced Programming

For questions related to the advanced programming course
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jcub
Calcite | Level 5

I'm a little confused. I'm actually working on an assignment using SAS IML and we are supposed to recreate the analysis of variance table from using the proc GLM procedure. As part of this we are supposed to utilize GROUP_N, GROUP_MEAN, and OVERALL_MEAN variables and use the Sum of Squares model equation with these variables. However, since the SS equation requires the difference in means to be squared, this can't be done because the matrixes are not square (they are 1x5 vectors). Is there a way to get SAS to input each aspect of the column into the equation individually and then add everything together?

 

To provide clarity, I have a continuous dependent variable and an independent categorical variable consisting of 5 levels and am trying to use the equation:

jcub_1-1622846394372.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

To get sum of squares in PROC IML, you can use the ## subscript reduction operator.

 

ssq=y(##,); /* sum of squares down the columns */
ssq2=y(,##); /* sum of squares across the rows */

Of course, to use this in your formula, you would have to subtract off the mean first. I assume you can do that yourself.

 

For all of these types of sum of squares formulas, there is also an expanded formula that is equivalent and allows a different computation that doesn't specifically involved subtracting off the mean.

--
Paige Miller

View solution in original post

3 REPLIES 3
Ksharp
Super User
Plz post some real data and output you want . that would be better understand your question.
And why not post it at IML forum ,since it is an IML question and @Rick_SAS is there .
Rick_SAS
SAS Super FREQ

I assume the dot indicates the mean over the subscripted dimension. Double-dot indicates the mean over both rows and columns (the grand mean).

 

If Y is a matrix, then 

Y_bar_doubledot = Y[:];  /* grand mean */

Y_i_dot = Y[i, :];    /* mean for the i_th row */

There is no problem with taking the squares because the expressions in the summation are scalar values for each value of i. 

PaigeMiller
Diamond | Level 26

To get sum of squares in PROC IML, you can use the ## subscript reduction operator.

 

ssq=y(##,); /* sum of squares down the columns */
ssq2=y(,##); /* sum of squares across the rows */

Of course, to use this in your formula, you would have to subtract off the mean first. I assume you can do that yourself.

 

For all of these types of sum of squares formulas, there is also an expanded formula that is equivalent and allows a different computation that doesn't specifically involved subtracting off the mean.

--
Paige Miller

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Autotuning Deep Learning Models Using SAS

Follow along as SAS’ Robert Blanchard explains three aspects of autotuning in a deep learning context: globalized search, localized search and an in parallel method using SAS.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 4310 views
  • 1 like
  • 4 in conversation