[R-SIG-Finance] PerformanceAnalytics - Style Analysis
Thomas Etheber
etheber at gmx.de
Tue Jun 29 12:06:05 CEST 2010
Dear Eric,
dear Brian,
thank you for your helpful comments and your regression example below. I
just updated my R distribution and I am now running:
R: version 2.11.1 (2010-05-31)
PerformanceAnalytics: version 1.0.2.1
It seems that your bugfix for the constrained StyleAnalyiss is not yet
included in the new PerformanceAnalytics. Maybe the timespan between
your fix and the release of PerformanceAnalytics 1.0.2.1 in mid April
was too short to include it.
Eric, if you have fixed the code already, could you please send it to
me? Maybe I can include the code in my actual project, so that I don't
have to wait for the next release of the package.
Regards,
Thomas
Am 23.03.2010 18:59, schrieb Eric Zivot:
> You are right. The correct way to enforce that the regression coefficients
> sum to unity is to impose this in the regression instead of just normalizing
> the coefficients to sum to unity. It is not difficult to do this because it
> is a linear restriction and the restriction can be substituted into the
> linear regression to create another linear regression. I was supposed to add
> this fix to the style.fit() function last year. I'll do it now and send the
> fix off to Brian so he can put it in the PerformanceAnalytics package.
> Briefly, consider the simple linear regression
>
> Y = x1*b1 + x2*b2 + e
>
> The restriction to impose is b1 + b2 = 1. Equivalently, b1 = 1 - b2.
> Substituting into the regression gives
>
> Y = x1*(1 - b2) + x2*b2 + e = x1 + b2*(x2 - x1) + e => Y - x1 = b2*(x2 - x1)
> + e
>
> Therefore, the linear regression to run to impose the restriction b1+b2 = 1
> is
>
> (Y - x1) = b2*(x2 - x1) + e
>
> Once you have b2.hat, then just solve for b1 using the constraint: b1.hat =
> 1 - b2.hat. (Note that it doesn't matter if you define the restriction in
> terms of b1 = 1 - b2 or b2 = 1 - b1.) Of course, to get the right R2 you
> have to base it on Y as the dependent variable and not Y - x1. That is,
> compute the R2 from the fitted values
>
> Y.hat = b1.hat*x1 + b2.hat*x2
>
> Where b1.hat and b2.hat are the restricted least squares coefficients.
>
> Eric Zivot
> Professor and Gary Waterman Distinguished Scholar
> Department of Economics
> Adjunct Professor of Finance
> Adjunct Professor of Statistics
> Box 353330 email: ezivot at u.washington.edu
> University of Washington phone: 206-543-6715
> Seattle, WA 98195-3330
> www: http://faculty.washington.edu/ezivot
>
>
>
>
> -----Original Message-----
> From: r-sig-finance-bounces at stat.math.ethz.ch
> [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Thomas Etheber
> Sent: Tuesday, March 23, 2010 4:03 AM
> To: r-sig-finance at stat.math.ethz.ch
> Subject: [R-SIG-Finance] PerformanceAnalytics - Style Analysis
>
> Dear List,
>
> I had a look at the code of the PerformanceAnalytics package and I use
> this package on a regular basis.
>
> The style.fit function for Style Analysis provides thrree supported
> methods, which can be chosen via a parameter. I am talking of the
> normalized method here. This method requires the regression coefficients
> to sum to 1.
> Indeed the code in Version 1.0.0 says something like this:
>
> [... Default implementation ...]
> column.weights = as.data.frame(coef(column.lm))
> [...]
> if (method == "normalized") {
> column.weights = column.weights/sum(column.weights)
> }
>
> I suppose here we are just scaling the coefficients to sum to 1, in my
> view the regression should a priori deal with this restriction (some
> sort of constrained regression or the like).
> At least if you look at Tabel 2 of Sharpe (1992) the coefficients do not
> support the actual implementation and I think somebody might want to
> have a look at this code fragment.
> Unfortunately I do not know how to implement this kind of restricted
> regression in R, but I believe there are already ways of doing this.
> Perhaps somebody from the list can guide us to the right direction.
>
> Anyway great thx to the authors of this packkage!
> Thomas
>
> PS: In Stata the right command seems to be cnsreg.
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>
>
More information about the R-SIG-Finance
mailing list