BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jennie
Calcite | Level 5

I am trying to solve the following...

W = pX

X is an i x 1 vector of known values (i is the number of observations in my sample)

p is a constant and is negative (it is unknown).

W is an i x1 vector of unknown values.

The sum of the values in W needs to equal zero. (w1 + w2 + w3 + ...+ wi = 0)

I am trying to solve for W.

I am not sure how to set up this problem so that I can solve for W.

Is this something that I can do using proc OPTMODEL?

If so, can you please help show me how I can set it up?

If not, can you please recommend an alternative that might work?

I know that I am asking a lot but I have been struggling with this all day and any help or advice is appreciated!

I have tried using the documentation, but I am unsure of how to set up the constraints (the sum of w's is zero and that p is negative constant).

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

Yes, you can do this using PROC OPTMODEL.

If you have declared W as:

var W {1..i};

You can express the constraint that W sums to zero as follows:

con SumToZero:

     sum {j in 1..i} W = 0;

To make p negative, include a slightly negative upper bound in the variable declaration:

var p <= -1e-6;

View solution in original post

2 REPLIES 2
RobPratt
SAS Super FREQ

Yes, you can do this using PROC OPTMODEL.

If you have declared W as:

var W {1..i};

You can express the constraint that W sums to zero as follows:

con SumToZero:

     sum {j in 1..i} W = 0;

To make p negative, include a slightly negative upper bound in the variable declaration:

var p <= -1e-6;

jennie
Calcite | Level 5

Thanks Rob,

This is very helpful.

J

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 945 views
  • 0 likes
  • 2 in conversation