PerformanceAnalytics - Style Analysis- plotting R squared over time

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

PerformanceAnalytics - Style Analysis- plotting R squared over time

Philipp Haumueller
Dear all,

I am running some analysis based on an asset factor model (Sharpe model -
Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
calculating weights etc. works fine I would also like to calculate/plot
rolling R-squared values of the Sharpe model over time? Are there any
suggestions how to run this?

Your help is greatly appreciated - thx,

Phil    
--



        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Peter Carl-2
Phil,

The function page.RollingStyle in PApages (also on RForge) shows something
of a brute-force way to do it.  I'm sure there's a better way, but that
should work for you.

pcc
--
Peter Carl
http://www.braverock.com/~peter

> Dear all,
>
> I am running some analysis based on an asset factor model (Sharpe model -
> Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
> calculating weights etc. works fine I would also like to calculate/plot
> rolling R-squared values of the Sharpe model over time? Are there any
> suggestions how to run this?
>
> Your help is greatly appreciated - thx,
>
> Phil
> --
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> [hidden email] 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.
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Philipp Haumueller
In reply to this post by Philipp Haumueller
Hi Carl,
 
 Many thanks for your quick reply. Just a follow up on  this. While I have
installed PA pages I wasn't too successful in finding  further information
in respect of implementing the function.page RollingStyle which would allow
me to plot the R-squared over time for my returns based analysis  
(Sharpe-model).Would you mind pointing me to some further information?
 
  Also, is there a straightforward way to chart or calculate each factor
weight
 so  that the values can be read easily (while chart.RollingStyle. gives a  
good graphical impression of the styles, I'd also be interested in
obtaining  an idea of the exact weightings at some point in time, e.g.
showing  min/max over time and potentially also some kind of summary
statistics like avg or sd of the style attributes)
 
 Some help on this would be awesome - thks.
 
 Phil

>         -------- Original-Nachricht --------
> Datum: Tue, 6 Sep 2011 09:38:37 -0500
> Von: "Peter Carl" <[hidden email]>
> An: "Philipp Haumueller" <[hidden email]>
> CC: [hidden email]
> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-  
> plotting R squared over time
>
>         Phil,
>
> The function page.RollingStyle in PApages (also on RForge) shows
> something
> of a brute-force way to do it.  I'm sure there's a better way, but that
> should work for you.
>
> pcc
> --
> Peter Carl
> http://www.braverock.com/~peter
>
> > Dear all,
> >
> > I am running some analysis based on an asset factor model (Sharpe model
> -
> > Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
> > calculating weights etc. works fine I would also like to calculate/plot
> > rolling R-squared values of the Sharpe model over time? Are there any
> > suggestions how to run this?
> >
> > Your help is greatly appreciated - thx,
> >
> > Phil
> > --
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > [hidden email] 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.
> >
>
>
>  
   
--



        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Peter Carl-2
Take a look at the code itself - it implements what you are asking for.
In particular, pay attention to the rollapply functions.

> page.RollingStyle
function (R.fund, R.style, method = c("constrained", "unconstrained",
    "normalized"), leverage = FALSE, selection = "none", width = 12,
    main = paste(colnames(R.fund)[1], " Rolling ", width, "-Month Style
Weights",
        sep = ""), space = 0, ...)
{
    R.fund = checkData(R.fund[, 1, drop = FALSE], method = "zoo")
    R.style = checkData(R.style, method = "zoo")
    method = method[1]
    columns.fund = ncol(R.fund)
    columns.style = ncol(R.style)
    columnnames.fund = colnames(R.fund)
    columnnames.style = colnames(R.style)
    merged.assets = na.omit(merge(R.fund, R.style))
    result = rollapply(data = merged.assets, FUN = function(x) {
        t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
            -1, drop = FALSE], method = method, leverage = leverage,
            selection = selection)$weights)
    }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
        align = "right")
    fit = rollapply(data = merged.assets, FUN = function(x) {
        t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
            -1, drop = FALSE], method = method, leverage = leverage,
            selection = selection)$R.squared)
    }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
        align = "right")
    colnames(result) = columnnames.style
    rows = nrow(result)
    ymax = max(c(1, result))
    ymin = min(c(-1, result))
    op <- par(oma = c(2, 0, 4, 0), mar = c(0, 4, 0, 4))
    layout(matrix(c(1:columns.style, columns.style + 1, columns.style +
        2), nc = 1, byrow = TRUE))
    for (i in 1:columns.style) {
        if (even(i))
            yaxis.right = TRUE
        else yaxis.right = FALSE
        chart.TimeSeries(result[, i, drop = F], type = "h", lend = "butt",
            xaxis = FALSE, main = "", ylab = colnames(result)[i],
            ylim = c(ymin, ymax), yaxis.right = yaxis.right,
            ...)
    }
    positives = result
    for (column in 1:ncol(result)) {
        for (row in 1:nrow(result)) {
            positives[row, column] = max(0, result[row, column])
        }
    }
    negatives = result
    for (column in 1:ncol(result)) {
        for (row in 1:nrow(result)) {
            negatives[row, column] = min(0, result[row, column])
        }
    }
    sumpositives = zoo(apply(positives, 1, sum), order.by = index(positives))
    sumnegatives = zoo(apply(negatives, 1, sum), order.by = index(negatives))
    net = apply(result, 1, sum)
    if (even(columns.style + 1))
        yaxis.right = TRUE
    else yaxis.right = FALSE
    chart.TimeSeries(cbind(sumpositives, sumnegatives), type = "h",
        lend = "butt", xaxis = FALSE, main = "", ylab = "Total",
        yaxis.right = yaxis.right, ...)
    lines(1:rows, net)
    if (even(columns.style + 2))
        yaxis.right = TRUE
    else yaxis.right = FALSE
    chart.TimeSeries(fit, type = "l", xaxis = TRUE, main = "",
        ylab = "AdjR^2", ylim = c(0, 1), yaxis.right = yaxis.right,
        ...)
    mtext(main, side = 3, outer = TRUE, font = 2, cex = 1.2,
        line = 1)
    par(op)
}

--
Peter Carl
http://www.braverock.com/~peter

> Hi Carl,
>
>  Many thanks for your quick reply. Just a follow up on  this. While I have
> installed PA pages I wasn't too successful in finding  further information
> in respect of implementing the function.page RollingStyle which would
> allow
> me to plot the R-squared over time for my returns based analysis
> (Sharpe-model).Would you mind pointing me to some further information?
>
>   Also, is there a straightforward way to chart or calculate each factor
> weight
>  so  that the values can be read easily (while chart.RollingStyle. gives a
> good graphical impression of the styles, I'd also be interested in
> obtaining  an idea of the exact weightings at some point in time, e.g.
> showing  min/max over time and potentially also some kind of summary
> statistics like avg or sd of the style attributes)
>
>  Some help on this would be awesome - thks.
>
>  Phil
>>         -------- Original-Nachricht --------
>> Datum: Tue, 6 Sep 2011 09:38:37 -0500
>> Von: "Peter Carl" <[hidden email]>
>> An: "Philipp Haumueller" <[hidden email]>
>> CC: [hidden email]
>> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>> plotting R squared over time
>>
>>         Phil,
>>
>> The function page.RollingStyle in PApages (also on RForge) shows
>> something
>> of a brute-force way to do it.  I'm sure there's a better way, but that
>> should work for you.
>>
>> pcc
>> --
>> Peter Carl
>> http://www.braverock.com/~peter
>>
>> > Dear all,
>> >
>> > I am running some analysis based on an asset factor model (Sharpe
>> model
>> -
>> > Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
>> > calculating weights etc. works fine I would also like to
>> calculate/plot
>> > rolling R-squared values of the Sharpe model over time? Are there any
>> > suggestions how to run this?
>> >
>> > Your help is greatly appreciated - thx,
>> >
>> > Phil
>> > --
>> >
>> >
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > [hidden email] 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.
>> >
>>
>>
>>
>
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Philipp Haumueller
Many thanks. I tried to implement this, but still seem to miss something.

Here's a contrived example.Using 10.5 years of monthly fund data, I use
a stock market and a real estate index to "explain" the returns of the
fund. What I would like to do is to plot the R-squared over time with the
function.RollingStyle I proceed as follows:
 
head(Rfund.z)
  2000-01-31   2000-03-02   2000-03-31   2000-05-01  
2000-05-31   2000-07-01
-0.033951898  0.052783466 -0.020335698 -0.006613730  0.008663712 
0.091497179

 head(Rstyle.z)
               Stocks.z        RE.z
2000-01-31 -0.058851033  0.01968497
2000-03-02  0.002817568 -0.03427083
2000-03-31  0.066951099  0.06969885

Applying the page.RollingStyle function yields an error message

> page.RollingStyle (Rfund.z, Rstyle.z, method="constrained",
leverage=FALSE)

Error in checkData(R.fund) :
  The data cannot be converted into a time series.  If you are trying to
pass in names from a data object with one column, you should use the form
'data[rows, columns, drop = FALSE]'.  Rownames should have standard date
formats, such as '1985-03-15'.
In addition: Warning message:
In rollapply.zoo(data = merged.assets, FUN = function(x) { :
  na.pad argument is deprecated


Would be great, if someone could provide me with a brief explanation of
what exactly is going wrong here. Many thanks, Cheers,
Phil




>            
> -------- Original-Nachricht --------
> Datum: Tue, 6 Sep 2011 16:01:14 -0500
> Von: "Peter Carl" <[hidden email]>
> An: "Philipp Haumueller" <[hidden email]>
> CC: [hidden email]
> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-  
> plotting R squared over time
>
>             Take a look at the code itself - it implements what you are
> asking for.
> In particular, pay attention to the rollapply functions.
>
> > page.RollingStyle
> function (R.fund, R.style, method = c("constrained", "unconstrained",
>     "normalized"), leverage = FALSE, selection = "none", width = 12,
>     main = paste(colnames(R.fund)[1], " Rolling ", width, "-Month Style
> Weights",
>         sep = ""), space = 0, ...)
> {
>     R.fund = checkData(R.fund[, 1, drop = FALSE], method = "zoo")
>     R.style = checkData(R.style, method = "zoo")
>     method = method[1]
>     columns.fund = ncol(R.fund)
>     columns.style = ncol(R.style)
>     columnnames.fund = colnames(R.fund)
>     columnnames.style = colnames(R.style)
>     merged.assets = na.omit(merge(R.fund, R.style))
>     result = rollapply(data = merged.assets, FUN = function(x) {
>         t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>             -1, drop = FALSE], method = method, leverage = leverage,
>             selection = selection)$weights)
>     }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>         align = "right")
>     fit = rollapply(data = merged.assets, FUN = function(x) {
>         t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>             -1, drop = FALSE], method = method, leverage = leverage,
>             selection = selection)$R.squared)
>     }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>         align = "right")
>     colnames(result) = columnnames.style
>     rows = nrow(result)
>     ymax = max(c(1, result))
>     ymin = min(c(-1, result))
>     op <- par(oma = c(2, 0, 4, 0), mar = c(0, 4, 0, 4))
>     layout(matrix(c(1:columns.style, columns.style + 1, columns.style +
>         2), nc = 1, byrow = TRUE))
>     for (i in 1:columns.style) {
>         if (even(i))
>             yaxis.right = TRUE
>         else yaxis.right = FALSE
>         chart.TimeSeries(result[, i, drop = F], type = "h", lend =
> "butt",
>             xaxis = FALSE, main = "", ylab = colnames(result)[i],
>             ylim = c(ymin, ymax), yaxis.right = yaxis.right,
>             ...)
>     }
>     positives = result
>     for (column in 1:ncol(result)) {
>         for (row in 1:nrow(result)) {
>             positives[row, column] = max(0, result[row, column])
>         }
>     }
>     negatives = result
>     for (column in 1:ncol(result)) {
>         for (row in 1:nrow(result)) {
>             negatives[row, column] = min(0, result[row, column])
>         }
>     }
>     sumpositives = zoo(apply(positives, 1, sum), order.by =
> index(positives))
>     sumnegatives = zoo(apply(negatives, 1, sum), order.by =
> index(negatives))
>     net = apply(result, 1, sum)
>     if (even(columns.style + 1))
>         yaxis.right = TRUE
>     else yaxis.right = FALSE
>     chart.TimeSeries(cbind(sumpositives, sumnegatives), type = "h",
>         lend = "butt", xaxis = FALSE, main = "", ylab = "Total",
>         yaxis.right = yaxis.right, ...)
>     lines(1:rows, net)
>     if (even(columns.style + 2))
>         yaxis.right = TRUE
>     else yaxis.right = FALSE
>     chart.TimeSeries(fit, type = "l", xaxis = TRUE, main = "",
>         ylab = "AdjR^2", ylim = c(0, 1), yaxis.right = yaxis.right,
>         ...)
>     mtext(main, side = 3, outer = TRUE, font = 2, cex = 1.2,
>         line = 1)
>     par(op)
> }
>
> --
> Peter Carl
> http://www.braverock.com/~peter
>
> > Hi Carl,
> >
> >  Many thanks for your quick reply. Just a follow up on  this. While I
> have
> > installed PA pages I wasn't too successful in finding  further
> information
> > in respect of implementing the function.page RollingStyle which would
> > allow
> > me to plot the R-squared over time for my returns based analysis
> > (Sharpe-model).Would you mind pointing me to some further information?
> >
> >   Also, is there a straightforward way to chart or calculate each
> factor
> > weight
> >  so  that the values can be read easily (while chart.RollingStyle.
> gives a
> > good graphical impression of the styles, I'd also be interested in
> > obtaining  an idea of the exact weightings at some point in time, e.g.
> > showing  min/max over time and potentially also some kind of summary
> > statistics like avg or sd of the style attributes)
> >
> >  Some help on this would be awesome - thks.
> >
> >  Phil
> >>         -------- Original-Nachricht --------
> >> Datum: Tue, 6 Sep 2011 09:38:37 -0500
> >> Von: "Peter Carl" <[hidden email]>
> >> An: "Philipp Haumueller" <[hidden email]>
> >> CC: [hidden email]
> >> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
> >> plotting R squared over time
> >>
> >>         Phil,
> >>
> >> The function page.RollingStyle in PApages (also on RForge) shows
> >> something
> >> of a brute-force way to do it.  I'm sure there's a better way, but
> that
> >> should work for you.
> >>
> >> pcc
> >> --
> >> Peter Carl
> >> http://www.braverock.com/~peter
> >>
> >> > Dear all,
> >> >
> >> > I am running some analysis based on an asset factor model (Sharpe
> >> model
> >> -
> >> > Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
> >> > calculating weights etc. works fine I would also like to
> >> calculate/plot
> >> > rolling R-squared values of the Sharpe model over time? Are there
> any
> >> > suggestions how to run this?
> >> >
> >> > Your help is greatly appreciated - thx,
> >> >
> >> > Phil
> >> > --
> >> >
> >> >
> >> >
> >> > [[alternative HTML version deleted]]
> >> >
> >> > _______________________________________________
> >> > [hidden email] 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.
> >> >
> >>
> >>
> >>
> >
> > --
> > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
> >
>
>
>
       
--



        [[alternative HTML version deleted]]


_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Peter Carl-2
Phil,

I think the error message is clear - the data series you're using as the
"fund" data, Rfund.z, isn't being recognized as a format that is
convertible to a time series object (for conversion into an xts object).
Look at ?as.xts and consider constructing xts objects for both timeseries.
 Or you might use Return.read from PerformanceAnalytics to load the series
in from a csv file.

pcc
--
Peter Carl
http://www.braverock.com/~peter

> Many thanks. I tried to implement this, but still seem to miss something.
>
> Here's a contrived example.Using 10.5 years of monthly fund data, I use
> a stock market and a real estate index to "explain" the returns of the
> fund. What I would like to do is to plot the R-squared over time with the
> function.RollingStyle I proceed as follows:
>  
> head(Rfund.z)
>   2000-01-31   2000-03-02   2000-03-31   2000-05-01  
> 2000-05-31   2000-07-01
> -0.033951898  0.052783466 -0.020335698 -0.006613730  0.008663712 
> 0.091497179
>
>  head(Rstyle.z)
>                Stocks.z        RE.z
> 2000-01-31 -0.058851033  0.01968497
> 2000-03-02  0.002817568 -0.03427083
> 2000-03-31  0.066951099  0.06969885
>
> Applying the page.RollingStyle function yields an error message
>
>> page.RollingStyle (Rfund.z, Rstyle.z, method="constrained",
> leverage=FALSE)
>
> Error in checkData(R.fund) :
>   The data cannot be converted into a time series.  If you are trying to
> pass in names from a data object with one column, you should use the form
> 'data[rows, columns, drop = FALSE]'.  Rownames should have standard date
> formats, such as '1985-03-15'.
> In addition: Warning message:
> In rollapply.zoo(data = merged.assets, FUN = function(x) { :
>   na.pad argument is deprecated
>
>
> Would be great, if someone could provide me with a brief explanation of
> what exactly is going wrong here. Many thanks, Cheers,
> Phil
>
>
>
>
>>
>> -------- Original-Nachricht --------
>> Datum: Tue, 6 Sep 2011 16:01:14 -0500
>> Von: "Peter Carl" <[hidden email]>
>> An: "Philipp Haumueller" <[hidden email]>
>> CC: [hidden email]
>> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>> plotting R squared over time
>>
>>             Take a look at the code itself - it implements what you are
>> asking for.
>> In particular, pay attention to the rollapply functions.
>>
>> > page.RollingStyle
>> function (R.fund, R.style, method = c("constrained", "unconstrained",
>>     "normalized"), leverage = FALSE, selection = "none", width = 12,
>>     main = paste(colnames(R.fund)[1], " Rolling ", width, "-Month Style
>> Weights",
>>         sep = ""), space = 0, ...)
>> {
>>     R.fund = checkData(R.fund[, 1, drop = FALSE], method = "zoo")
>>     R.style = checkData(R.style, method = "zoo")
>>     method = method[1]
>>     columns.fund = ncol(R.fund)
>>     columns.style = ncol(R.style)
>>     columnnames.fund = colnames(R.fund)
>>     columnnames.style = colnames(R.style)
>>     merged.assets = na.omit(merge(R.fund, R.style))
>>     result = rollapply(data = merged.assets, FUN = function(x) {
>>         t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>>             -1, drop = FALSE], method = method, leverage = leverage,
>>             selection = selection)$weights)
>>     }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>>         align = "right")
>>     fit = rollapply(data = merged.assets, FUN = function(x) {
>>         t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>>             -1, drop = FALSE], method = method, leverage = leverage,
>>             selection = selection)$R.squared)
>>     }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>>         align = "right")
>>     colnames(result) = columnnames.style
>>     rows = nrow(result)
>>     ymax = max(c(1, result))
>>     ymin = min(c(-1, result))
>>     op <- par(oma = c(2, 0, 4, 0), mar = c(0, 4, 0, 4))
>>     layout(matrix(c(1:columns.style, columns.style + 1, columns.style +
>>         2), nc = 1, byrow = TRUE))
>>     for (i in 1:columns.style) {
>>         if (even(i))
>>             yaxis.right = TRUE
>>         else yaxis.right = FALSE
>>         chart.TimeSeries(result[, i, drop = F], type = "h", lend =
>> "butt",
>>             xaxis = FALSE, main = "", ylab = colnames(result)[i],
>>             ylim = c(ymin, ymax), yaxis.right = yaxis.right,
>>             ...)
>>     }
>>     positives = result
>>     for (column in 1:ncol(result)) {
>>         for (row in 1:nrow(result)) {
>>             positives[row, column] = max(0, result[row, column])
>>         }
>>     }
>>     negatives = result
>>     for (column in 1:ncol(result)) {
>>         for (row in 1:nrow(result)) {
>>             negatives[row, column] = min(0, result[row, column])
>>         }
>>     }
>>     sumpositives = zoo(apply(positives, 1, sum), order.by =
>> index(positives))
>>     sumnegatives = zoo(apply(negatives, 1, sum), order.by =
>> index(negatives))
>>     net = apply(result, 1, sum)
>>     if (even(columns.style + 1))
>>         yaxis.right = TRUE
>>     else yaxis.right = FALSE
>>     chart.TimeSeries(cbind(sumpositives, sumnegatives), type = "h",
>>         lend = "butt", xaxis = FALSE, main = "", ylab = "Total",
>>         yaxis.right = yaxis.right, ...)
>>     lines(1:rows, net)
>>     if (even(columns.style + 2))
>>         yaxis.right = TRUE
>>     else yaxis.right = FALSE
>>     chart.TimeSeries(fit, type = "l", xaxis = TRUE, main = "",
>>         ylab = "AdjR^2", ylim = c(0, 1), yaxis.right = yaxis.right,
>>         ...)
>>     mtext(main, side = 3, outer = TRUE, font = 2, cex = 1.2,
>>         line = 1)
>>     par(op)
>> }
>>
>> --
>> Peter Carl
>> http://www.braverock.com/~peter
>>
>> > Hi Carl,
>> >
>> >  Many thanks for your quick reply. Just a follow up on  this. While I
>> have
>> > installed PA pages I wasn't too successful in finding  further
>> information
>> > in respect of implementing the function.page RollingStyle which would
>> > allow
>> > me to plot the R-squared over time for my returns based analysis
>> > (Sharpe-model).Would you mind pointing me to some further information?
>> >
>> >   Also, is there a straightforward way to chart or calculate each
>> factor
>> > weight
>> >  so  that the values can be read easily (while chart.RollingStyle.
>> gives a
>> > good graphical impression of the styles, I'd also be interested in
>> > obtaining  an idea of the exact weightings at some point in time, e.g.
>> > showing  min/max over time and potentially also some kind of summary
>> > statistics like avg or sd of the style attributes)
>> >
>> >  Some help on this would be awesome - thks.
>> >
>> >  Phil
>> >>         -------- Original-Nachricht --------
>> >> Datum: Tue, 6 Sep 2011 09:38:37 -0500
>> >> Von: "Peter Carl" <[hidden email]>
>> >> An: "Philipp Haumueller" <[hidden email]>
>> >> CC: [hidden email]
>> >> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>> >> plotting R squared over time
>> >>
>> >>         Phil,
>> >>
>> >> The function page.RollingStyle in PApages (also on RForge) shows
>> >> something
>> >> of a brute-force way to do it.  I'm sure there's a better way, but
>> that
>> >> should work for you.
>> >>
>> >> pcc
>> >> --
>> >> Peter Carl
>> >> http://www.braverock.com/~peter
>> >>
>> >> > Dear all,
>> >> >
>> >> > I am running some analysis based on an asset factor model (Sharpe
>> >> model
>> >> -
>> >> > Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
>> >> > calculating weights etc. works fine I would also like to
>> >> calculate/plot
>> >> > rolling R-squared values of the Sharpe model over time? Are there
>> any
>> >> > suggestions how to run this?
>> >> >
>> >> > Your help is greatly appreciated - thx,
>> >> >
>> >> > Phil
>> >> > --
>> >> >
>> >> >
>> >> >
>> >> > [[alternative HTML version deleted]]
>> >> >
>> >> > _______________________________________________
>> >> > [hidden email] 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.
>> >> >
>> >>
>> >>
>> >>
>> >
>> > --
>> > Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>> > belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>> >
>>
>>
>>
>
> --
> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Kenton Russell
I got the same error and data is definitely xts.  I will try to debug today.  Looks like my function works fine on a cumulative basis or if I use for loop but does not work with rollapply.

Kent

On Sep 7, 2011, at 6:13 AM, "Peter Carl" <[hidden email]> wrote:

> Phil,
>
> I think the error message is clear - the data series you're using as the
> "fund" data, Rfund.z, isn't being recognized as a format that is
> convertible to a time series object (for conversion into an xts object).
> Look at ?as.xts and consider constructing xts objects for both timeseries.
> Or you might use Return.read from PerformanceAnalytics to load the series
> in from a csv file.
>
> pcc
> --
> Peter Carl
> http://www.braverock.com/~peter
>
>> Many thanks. I tried to implement this, but still seem to miss something.
>>
>> Here's a contrived example.Using 10.5 years of monthly fund data, I use
>> a stock market and a real estate index to "explain" the returns of the
>> fund. What I would like to do is to plot the R-squared over time with the
>> function.RollingStyle I proceed as follows:
>> Â
>> head(Rfund.z)
>> Â  2000-01-31Â Â  2000-03-02Â Â  2000-03-31Â Â  2000-05-01Â Â
>> 2000-05-31Â Â  2000-07-01
>> -0.033951898Â  0.052783466 -0.020335698 -0.006613730Â  0.008663712Â
>> 0.091497179
>>
>> Â head(Rstyle.z)
>>                Stocks.z        RE.z
>> 2000-01-31 -0.058851033Â  0.01968497
>> 2000-03-02Â  0.002817568 -0.03427083
>> 2000-03-31Â  0.066951099Â  0.06969885
>>
>> Applying the page.RollingStyle function yields an error message
>>
>>> page.RollingStyle (Rfund.z, Rstyle.z, method="constrained",
>> leverage=FALSE)
>>
>> Error in checkData(R.fund) :
>>   The data cannot be converted into a time series.  If you are trying to
>> pass in names from a data object with one column, you should use the form
>> 'data[rows, columns, drop = FALSE]'.  Rownames should have standard date
>> formats, such as '1985-03-15'.
>> In addition: Warning message:
>> In rollapply.zoo(data = merged.assets, FUN = function(x) { :
>> Â  na.pad argument is deprecated
>>
>>
>> Would be great, if someone could provide me with a brief explanation of
>> what exactly is going wrong here. Many thanks, Cheers,
>> Phil
>>
>>
>>
>>
>>>
>>> -------- Original-Nachricht --------
>>> Datum: Tue, 6 Sep 2011 16:01:14 -0500
>>> Von: "Peter Carl" <[hidden email]>
>>> An: "Philipp Haumueller" <[hidden email]>
>>> CC: [hidden email]
>>> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>>> plotting R squared over time
>>>
>>>            Take a look at the code itself - it implements what you are
>>> asking for.
>>> In particular, pay attention to the rollapply functions.
>>>
>>>> page.RollingStyle
>>> function (R.fund, R.style, method = c("constrained", "unconstrained",
>>>    "normalized"), leverage = FALSE, selection = "none", width = 12,
>>>    main = paste(colnames(R.fund)[1], " Rolling ", width, "-Month Style
>>> Weights",
>>>        sep = ""), space = 0, ...)
>>> {
>>>    R.fund = checkData(R.fund[, 1, drop = FALSE], method = "zoo")
>>>    R.style = checkData(R.style, method = "zoo")
>>>    method = method[1]
>>>    columns.fund = ncol(R.fund)
>>>    columns.style = ncol(R.style)
>>>    columnnames.fund = colnames(R.fund)
>>>    columnnames.style = colnames(R.style)
>>>    merged.assets = na.omit(merge(R.fund, R.style))
>>>    result = rollapply(data = merged.assets, FUN = function(x) {
>>>        t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>>>            -1, drop = FALSE], method = method, leverage = leverage,
>>>            selection = selection)$weights)
>>>    }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>>>        align = "right")
>>>    fit = rollapply(data = merged.assets, FUN = function(x) {
>>>        t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>>>            -1, drop = FALSE], method = method, leverage = leverage,
>>>            selection = selection)$R.squared)
>>>    }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>>>        align = "right")
>>>    colnames(result) = columnnames.style
>>>    rows = nrow(result)
>>>    ymax = max(c(1, result))
>>>    ymin = min(c(-1, result))
>>>    op <- par(oma = c(2, 0, 4, 0), mar = c(0, 4, 0, 4))
>>>    layout(matrix(c(1:columns.style, columns.style + 1, columns.style +
>>>        2), nc = 1, byrow = TRUE))
>>>    for (i in 1:columns.style) {
>>>        if (even(i))
>>>            yaxis.right = TRUE
>>>        else yaxis.right = FALSE
>>>        chart.TimeSeries(result[, i, drop = F], type = "h", lend =
>>> "butt",
>>>            xaxis = FALSE, main = "", ylab = colnames(result)[i],
>>>            ylim = c(ymin, ymax), yaxis.right = yaxis.right,
>>>            ...)
>>>    }
>>>    positives = result
>>>    for (column in 1:ncol(result)) {
>>>        for (row in 1:nrow(result)) {
>>>            positives[row, column] = max(0, result[row, column])
>>>        }
>>>    }
>>>    negatives = result
>>>    for (column in 1:ncol(result)) {
>>>        for (row in 1:nrow(result)) {
>>>            negatives[row, column] = min(0, result[row, column])
>>>        }
>>>    }
>>>    sumpositives = zoo(apply(positives, 1, sum), order.by =
>>> index(positives))
>>>    sumnegatives = zoo(apply(negatives, 1, sum), order.by =
>>> index(negatives))
>>>    net = apply(result, 1, sum)
>>>    if (even(columns.style + 1))
>>>        yaxis.right = TRUE
>>>    else yaxis.right = FALSE
>>>    chart.TimeSeries(cbind(sumpositives, sumnegatives), type = "h",
>>>        lend = "butt", xaxis = FALSE, main = "", ylab = "Total",
>>>        yaxis.right = yaxis.right, ...)
>>>    lines(1:rows, net)
>>>    if (even(columns.style + 2))
>>>        yaxis.right = TRUE
>>>    else yaxis.right = FALSE
>>>    chart.TimeSeries(fit, type = "l", xaxis = TRUE, main = "",
>>>        ylab = "AdjR^2", ylim = c(0, 1), yaxis.right = yaxis.right,
>>>        ...)
>>>    mtext(main, side = 3, outer = TRUE, font = 2, cex = 1.2,
>>>        line = 1)
>>>    par(op)
>>> }
>>>
>>> --
>>> Peter Carl
>>> http://www.braverock.com/~peter
>>>
>>>> Hi Carl,
>>>>
>>>> Many thanks for your quick reply. Just a follow up on  this. While I
>>> have
>>>> installed PA pages I wasn't too successful in finding  further
>>> information
>>>> in respect of implementing the function.page RollingStyle which would
>>>> allow
>>>> me to plot the R-squared over time for my returns based analysis
>>>> (Sharpe-model).Would you mind pointing me to some further information?
>>>>
>>>>  Also, is there a straightforward way to chart or calculate each
>>> factor
>>>> weight
>>>> so  that the values can be read easily (while chart.RollingStyle.
>>> gives a
>>>> good graphical impression of the styles, I'd also be interested in
>>>> obtaining  an idea of the exact weightings at some point in time, e.g.
>>>> showing  min/max over time and potentially also some kind of summary
>>>> statistics like avg or sd of the style attributes)
>>>>
>>>> Some help on this would be awesome - thks.
>>>>
>>>> Phil
>>>>>        -------- Original-Nachricht --------
>>>>> Datum: Tue, 6 Sep 2011 09:38:37 -0500
>>>>> Von: "Peter Carl" <[hidden email]>
>>>>> An: "Philipp Haumueller" <[hidden email]>
>>>>> CC: [hidden email]
>>>>> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>>>>> plotting R squared over time
>>>>>
>>>>>        Phil,
>>>>>
>>>>> The function page.RollingStyle in PApages (also on RForge) shows
>>>>> something
>>>>> of a brute-force way to do it.  I'm sure there's a better way, but
>>> that
>>>>> should work for you.
>>>>>
>>>>> pcc
>>>>> --
>>>>> Peter Carl
>>>>> http://www.braverock.com/~peter
>>>>>
>>>>>> Dear all,
>>>>>>
>>>>>> I am running some analysis based on an asset factor model (Sharpe
>>>>> model
>>>>> -
>>>>>> Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
>>>>>> calculating weights etc. works fine I would also like to
>>>>> calculate/plot
>>>>>> rolling R-squared values of the Sharpe model over time? Are there
>>> any
>>>>>> suggestions how to run this?
>>>>>>
>>>>>> Your help is greatly appreciated - thx,
>>>>>>
>>>>>> Phil
>>>>>> --
>>>>>>
>>>>>>
>>>>>>
>>>>>>    [[alternative HTML version deleted]]
>>>>>>
>>>>>> _______________________________________________
>>>>>> [hidden email] 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.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>>>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>>>>
>>>
>>>
>>>
>>
>> --
>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>>
>
> _______________________________________________
> [hidden email] 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.
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

braverock
On Wed, 2011-09-07 at 06:28 -0500, Kent Russell wrote:
>
> I got the same error and data is definitely xts.  I will try to debug
> today.  Looks like my function works fine on a cumulative basis or if
> I use for loop but does not work with rollapply.
<...>
> >> head(Rfund.z)
> >> Â  2000-01-31Â Â  2000-03-02Â Â  2000-03-31Â Â  2000-05-01Â Â
> >> 2000-05-31Â Â  2000-07-01
> >> -0.033951898Â  0.052783466 -0.020335698 -0.006613730Â
> 0.008663712Â
> >> 0.091497179

This doesn't look like xts. An xts object of even one column will
display with your dates as the index, and observations as rows.

Your second, two column, series does look like an appropriately
formatted xts object or matrix.

Regards,

  - Brian

--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Peter Carl-2
In reply to this post by Kenton Russell
The error, "The data cannot be converted into a time series," is thrown by
checkData, a function that makes sure the data is xtsible.  It won't throw
the error if it is a timeseries that can be converted to xts.  If you are
seeing a different error, please follow the posting guidelines and provide
a reproducible example.

pcc
--
Peter Carl
http://www.braverock.com/~peter

> I got the same error and data is definitely xts.  I will try to debug
> today.  Looks like my function works fine on a cumulative basis or if I
> use for loop but does not work with rollapply.
>
> Kent
>
> On Sep 7, 2011, at 6:13 AM, "Peter Carl" <[hidden email]> wrote:
>
>> Phil,
>>
>> I think the error message is clear - the data series you're using as the
>> "fund" data, Rfund.z, isn't being recognized as a format that is
>> convertible to a time series object (for conversion into an xts object).
>> Look at ?as.xts and consider constructing xts objects for both
>> timeseries.
>> Or you might use Return.read from PerformanceAnalytics to load the
>> series
>> in from a csv file.
>>
>> pcc
>> --
>> Peter Carl
>> http://www.braverock.com/~peter
>>
>>> Many thanks. I tried to implement this, but still seem to miss
>>> something.
>>>
>>> Here's a contrived example.Using 10.5 years of monthly fund data, I use
>>> a stock market and a real estate index to "explain" the returns of the
>>> fund. What I would like to do is to plot the R-squared over time with
>>> the
>>> function.RollingStyle I proceed as follows:
>>> Â
>>> head(Rfund.z)
>>> Â  2000-01-31Â Â  2000-03-02Â Â  2000-03-31Â Â  2000-05-01Â Â
>>> 2000-05-31Â Â  2000-07-01
>>> -0.033951898Â  0.052783466 -0.020335698 -0.006613730Â  0.008663712Â
>>> 0.091497179
>>>
>>> Â head(Rstyle.z)
>>>                Stocks.z      Â
>>>  RE.z
>>> 2000-01-31 -0.058851033Â  0.01968497
>>> 2000-03-02Â  0.002817568 -0.03427083
>>> 2000-03-31Â  0.066951099Â  0.06969885
>>>
>>> Applying the page.RollingStyle function yields an error message
>>>
>>>> page.RollingStyle (Rfund.z, Rstyle.z, method="constrained",
>>> leverage=FALSE)
>>>
>>> Error in checkData(R.fund) :
>>>   The data cannot be converted into a time series.  If you are
>>> trying to
>>> pass in names from a data object with one column, you should use the
>>> form
>>> 'data[rows, columns, drop = FALSE]'.  Rownames should have standard
>>> date
>>> formats, such as '1985-03-15'.
>>> In addition: Warning message:
>>> In rollapply.zoo(data = merged.assets, FUN = function(x) { :
>>> Â  na.pad argument is deprecated
>>>
>>>
>>> Would be great, if someone could provide me with a brief explanation of
>>> what exactly is going wrong here. Many thanks, Cheers,
>>> Phil
>>>
>>>
>>>
>>>
>>>>
>>>> -------- Original-Nachricht --------
>>>> Datum: Tue, 6 Sep 2011 16:01:14 -0500
>>>> Von: "Peter Carl" <[hidden email]>
>>>> An: "Philipp Haumueller" <[hidden email]>
>>>> CC: [hidden email]
>>>> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>>>> plotting R squared over time
>>>>
>>>>            Take a look at the code itself - it implements what you are
>>>> asking for.
>>>> In particular, pay attention to the rollapply functions.
>>>>
>>>>> page.RollingStyle
>>>> function (R.fund, R.style, method = c("constrained", "unconstrained",
>>>>    "normalized"), leverage = FALSE, selection = "none", width = 12,
>>>>    main = paste(colnames(R.fund)[1], " Rolling ", width, "-Month Style
>>>> Weights",
>>>>        sep = ""), space = 0, ...)
>>>> {
>>>>    R.fund = checkData(R.fund[, 1, drop = FALSE], method = "zoo")
>>>>    R.style = checkData(R.style, method = "zoo")
>>>>    method = method[1]
>>>>    columns.fund = ncol(R.fund)
>>>>    columns.style = ncol(R.style)
>>>>    columnnames.fund = colnames(R.fund)
>>>>    columnnames.style = colnames(R.style)
>>>>    merged.assets = na.omit(merge(R.fund, R.style))
>>>>    result = rollapply(data = merged.assets, FUN = function(x) {
>>>>        t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>>>>            -1, drop = FALSE], method = method, leverage = leverage,
>>>>            selection = selection)$weights)
>>>>    }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>>>>        align = "right")
>>>>    fit = rollapply(data = merged.assets, FUN = function(x) {
>>>>        t(style.fit(R.fund = x[, 1, drop = FALSE], R.style = x[,
>>>>            -1, drop = FALSE], method = method, leverage = leverage,
>>>>            selection = selection)$R.squared)
>>>>    }, width = width, by = 1, by.column = FALSE, na.pad = FALSE,
>>>>        align = "right")
>>>>    colnames(result) = columnnames.style
>>>>    rows = nrow(result)
>>>>    ymax = max(c(1, result))
>>>>    ymin = min(c(-1, result))
>>>>    op <- par(oma = c(2, 0, 4, 0), mar = c(0, 4, 0, 4))
>>>>    layout(matrix(c(1:columns.style, columns.style + 1, columns.style +
>>>>        2), nc = 1, byrow = TRUE))
>>>>    for (i in 1:columns.style) {
>>>>        if (even(i))
>>>>            yaxis.right = TRUE
>>>>        else yaxis.right = FALSE
>>>>        chart.TimeSeries(result[, i, drop = F], type = "h", lend =
>>>> "butt",
>>>>            xaxis = FALSE, main = "", ylab = colnames(result)[i],
>>>>            ylim = c(ymin, ymax), yaxis.right = yaxis.right,
>>>>            ...)
>>>>    }
>>>>    positives = result
>>>>    for (column in 1:ncol(result)) {
>>>>        for (row in 1:nrow(result)) {
>>>>            positives[row, column] = max(0, result[row, column])
>>>>        }
>>>>    }
>>>>    negatives = result
>>>>    for (column in 1:ncol(result)) {
>>>>        for (row in 1:nrow(result)) {
>>>>            negatives[row, column] = min(0, result[row, column])
>>>>        }
>>>>    }
>>>>    sumpositives = zoo(apply(positives, 1, sum), order.by =
>>>> index(positives))
>>>>    sumnegatives = zoo(apply(negatives, 1, sum), order.by =
>>>> index(negatives))
>>>>    net = apply(result, 1, sum)
>>>>    if (even(columns.style + 1))
>>>>        yaxis.right = TRUE
>>>>    else yaxis.right = FALSE
>>>>    chart.TimeSeries(cbind(sumpositives, sumnegatives), type = "h",
>>>>        lend = "butt", xaxis = FALSE, main = "", ylab = "Total",
>>>>        yaxis.right = yaxis.right, ...)
>>>>    lines(1:rows, net)
>>>>    if (even(columns.style + 2))
>>>>        yaxis.right = TRUE
>>>>    else yaxis.right = FALSE
>>>>    chart.TimeSeries(fit, type = "l", xaxis = TRUE, main = "",
>>>>        ylab = "AdjR^2", ylim = c(0, 1), yaxis.right = yaxis.right,
>>>>        ...)
>>>>    mtext(main, side = 3, outer = TRUE, font = 2, cex = 1.2,
>>>>        line = 1)
>>>>    par(op)
>>>> }
>>>>
>>>> --
>>>> Peter Carl
>>>> http://www.braverock.com/~peter
>>>>
>>>>> Hi Carl,
>>>>>
>>>>> Many thanks for your quick reply. Just a follow up on  this. While I
>>>> have
>>>>> installed PA pages I wasn't too successful in finding  further
>>>> information
>>>>> in respect of implementing the function.page RollingStyle which would
>>>>> allow
>>>>> me to plot the R-squared over time for my returns based analysis
>>>>> (Sharpe-model).Would you mind pointing me to some further
>>>>> information?
>>>>>
>>>>>  Also, is there a straightforward way to chart or calculate each
>>>> factor
>>>>> weight
>>>>> so  that the values can be read easily (while chart.RollingStyle.
>>>> gives a
>>>>> good graphical impression of the styles, I'd also be interested in
>>>>> obtaining  an idea of the exact weightings at some point in time,
>>>>> e.g.
>>>>> showing  min/max over time and potentially also some kind of summary
>>>>> statistics like avg or sd of the style attributes)
>>>>>
>>>>> Some help on this would be awesome - thks.
>>>>>
>>>>> Phil
>>>>>>        -------- Original-Nachricht --------
>>>>>> Datum: Tue, 6 Sep 2011 09:38:37 -0500
>>>>>> Von: "Peter Carl" <[hidden email]>
>>>>>> An: "Philipp Haumueller" <[hidden email]>
>>>>>> CC: [hidden email]
>>>>>> Betreff: Re: [R-SIG-Finance] PerformanceAnalytics - Style Analysis-
>>>>>> plotting R squared over time
>>>>>>
>>>>>>        Phil,
>>>>>>
>>>>>> The function page.RollingStyle in PApages (also on RForge) shows
>>>>>> something
>>>>>> of a brute-force way to do it.  I'm sure there's a better way, but
>>>> that
>>>>>> should work for you.
>>>>>>
>>>>>> pcc
>>>>>> --
>>>>>> Peter Carl
>>>>>> http://www.braverock.com/~peter
>>>>>>
>>>>>>> Dear all,
>>>>>>>
>>>>>>> I am running some analysis based on an asset factor model (Sharpe
>>>>>> model
>>>>>> -
>>>>>>> Style Analyses) in the Package PerformanceAnalytics/R-Forge.While
>>>>>>> calculating weights etc. works fine I would also like to
>>>>>> calculate/plot
>>>>>>> rolling R-squared values of the Sharpe model over time? Are there
>>>> any
>>>>>>> suggestions how to run this?
>>>>>>>
>>>>>>> Your help is greatly appreciated - thx,
>>>>>>>
>>>>>>> Phil
>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>    [[alternative HTML version deleted]]
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> [hidden email] 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.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>>>>> belohnen Sie mit bis zu 50,- Euro!
>>>>> https://freundschaftswerbung.gmx.de
>>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
>>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
>>>
>>
>> _______________________________________________
>> [hidden email] 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.
>>
>

_______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

tonyp
Philipp,

Try first:

as.timeSeries(your data)

if it does not work, check the mode of the data
mode(your data)

That should be numeric.

Hope that helps.
Reply | Threaded
Open this post in threaded view
|

Re: PerformanceAnalytics - Style Analysis- plotting R squared over time

Jeffrey Ryan
Try str() or better yet dput() the data or subset of it to let us actually see the problem as opposed to guessing.

as.xts would be more illustrative in thi case as well, since that is the end goal.

Jeff

Jeffrey Ryan    |    Founder    |    [hidden email]

www.lemnica.com

On Sep 7, 2011, at 4:08 PM, tonyp <[hidden email]> wrote:

> Philipp,
>
> Try first:
>
> as.timeSeries(your data)
>
> if it does not work, check the mode of the data
> mode(your data)
>
> That should be numeric.
>
> Hope that helps.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/PerformanceAnalytics-Style-Analysis-plotting-R-squared-over-time-tp3793434p3797276.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> [hidden email] 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.

_______________________________________________
[hidden email] 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.