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

Hi all,

In the attached example, there are dayily trading data for two mutual funds in different months. But in my whole sample, there are daily data for various funds in many different months.


I want to run a regression model as below:

y= b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6 + b7*x7 + b8*x8 + e


It is not a ordinary regression model but with contraints:


s.t. (1) b1, b2, ..., b8>=0

       (2) b1+b2+, ..., +b8=1

min Var(e)


When running this regression, I also want to generate a new data file consisting of coefficients, t and p value from each regression on each fund in each month.

for example,

regress when fundcdym=000001200507 (fund 000001 in July 2005), there are 21 obs and the regression result inclueds coefficients, t and p value.

regress when fundcdym=000001200508 (fund 000001 in July 2005), there are 23 obs and the regression result inclueds coefficients, t and p value.

...


Can anybody help me to deal with this? Thanks in advance.


1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

I tried the following with SAS/ETS proc Model but didn't find the results very convincing (given your constraints and your number of observations in each month, I am not certain there can be meaningful OLS solutions)

data rwc;

infile "&SASFORUM\datasets\regression with constraints.csv" dsd firstobs=2;

length fundcd ym $6 Fundcdclsdt fundcdym $12;

input FUNDCD CLSDT :yymmdd10. Fundcdclsdt ym fundcdym y x1-x8;

run;

proc model data=rwc plots=none;

by fundcdym notsorted;

y= b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6 + b7*x7 + b8*x8;

bounds 0 <= b1-b8;

restrict b1+b2+b3+b4+b5+b6+b7+b8 = 1;

fit y / outest=rwcfit;

ods output ParameterEstimates=rwcPE;

run;

PG

PG

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

I tried the following with SAS/ETS proc Model but didn't find the results very convincing (given your constraints and your number of observations in each month, I am not certain there can be meaningful OLS solutions)

data rwc;

infile "&SASFORUM\datasets\regression with constraints.csv" dsd firstobs=2;

length fundcd ym $6 Fundcdclsdt fundcdym $12;

input FUNDCD CLSDT :yymmdd10. Fundcdclsdt ym fundcdym y x1-x8;

run;

proc model data=rwc plots=none;

by fundcdym notsorted;

y= b1*x1 + b2*x2 + b3*x3 + b4*x4 + b5*x5 + b6*x6 + b7*x7 + b8*x8;

bounds 0 <= b1-b8;

restrict b1+b2+b3+b4+b5+b6+b7+b8 = 1;

fit y / outest=rwcfit;

ods output ParameterEstimates=rwcPE;

run;

PG

PG

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1238 views
  • 1 like
  • 2 in conversation