Hi schnellinga,
I think that you misunderstand the original model.
Below is your code for the PPS function.
and size (for the size effect). Because of this, there are two coefficients : x[0] and x[1]. If looking at the
original input data sets, you will find two associated columns: adjusted closing price and mktcap, shown below.
Moderator Note:
Output tags also work well for input
However, in your PPS function, you use 3, x[0], x[1], and x[2], instead of one.
Hope that this would help.
Best,
Paul
I think that you misunderstand the original model.
Below is your code for the PPS function.
def PPS(x, wb, nt, excess, size, value, rr): w1= wb + nt * (x[0] * excess) w2= wb + nt * (x[1]* size) w3= wb + nt * (x[2]* value) wret = (w1*excess + w2*size + w3*value).sum() ut = ((1 + wret) ** (1 - rr)) / (1 - rr) u = -(ut.mean()) return uBelow is the original one.
# original one def PPS(x, wb, nt, ret, m12, mktcap, rr): wi = wb + nt * (x[0] * m12 + x[1] * mktcap) wret = (wi * ret).sum(axis=1) ut = ((1 + wret) ** (1 - rr)) / (1 - rr) u = -(ut.mean()) return uAccording to the original model, there are two parameters: 12month returns (for the momentum strategy)
and size (for the size effect). Because of this, there are two coefficients : x[0] and x[1]. If looking at the
original input data sets, you will find two associated columns: adjusted closing price and mktcap, shown below.
df.head() Out[317]:
Moderator Note:
Output tags also work well for input
Output: symbol adjusted close shares_held year month \
Date
2008-01-01 MSFT 25.413656 32.599998 92220260 2008 1
2008-02-01 MSFT 21.286415 27.200001 92220260 2008 2
2008-03-01 MSFT 22.209873 28.379999 92220260 2008 3
2008-04-01 MSFT 22.319431 28.520000 92220260 2008 4
2008-05-01 MSFT 22.244507 28.320000 92220260 2008 5
mktcap day
Date
2008-01-01 3.006380e+09 1
2008-02-01 2.508391e+09 1
2008-03-01 2.617211e+09 1
2008-04-01 2.630122e+09 1
2008-05-01 2.611678e+09 1
For your input data set, i.e., the Fama-French monthly data set, there is no market cap, shown below. >>>ff_factors.head() Out[318]:
Output: Mkt-RF SMB HML
1926-07-31 0.0296 -0.0238 -0.0273
1926-08-31 0.0264 -0.0147 0.0414
1926-09-30 0.0036 -0.0139 0.0012
1926-10-31 -0.0324 -0.0013 0.0065
1926-11-30 0.0253 -0.0016 -0.0038
Because of this, you can test the results for just one parameter: 12-month returns. However, in your PPS function, you use 3, x[0], x[1], and x[2], instead of one.
Hope that this would help.
Best,
Paul
Larz60+ write Jul-27-2022, 03:10 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time, please use bbcode tags on future posts
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time, please use bbcode tags on future posts