-R CMD Check ERROR: Running examples in ‘FactorAnalytics-Ex.R’ failed
The error most likely occurred in:
Name: fitTsfmLagLeadBeta
Title: Fit a lagged and lead Betas factor model using time series
regression
Aliases: fitTsfmLagLeadBeta
** Examples
load data from the database
data(managers, package = 'PerformanceAnalytics')
example: A lagged Beetas model with LS fit
fit <- fitTsfmLagLeadBeta(asset.names=colnames(managers[,(1:6)]),LagLeadBeta=2,LagOnly=TRUE, mkt.name="SP500 TR",rf.name="US 3m TR",data=managers) Error in
[.xts(data.xts, , factor.names) : subscript out of bounds Calls: fitTsfmLagLeadBeta -> fitTsfm -> merge -> merge.xts -> [ -> [.xts Execution halted
This ultimately executes and fails at fitTsfm, which appears to be working OK? The fitTsfm example test passes. The issue maybe in the lag transform steps...hence the [.xts Error.
Will be interesting to see what the issue is here.
On Fri, Aug 20, 2021 at 1:32 PM Justin M. Shea @.***> wrote:
This ultimately executes and fails at fitTsfm, which appears to be working OK? The fitTsfm example test passes. The issue maybe in the lag transform steps...hence the [.xts Error.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/braverock/FactorAnalytics/issues/43#issuecomment-902941781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP575Y7EW7PPUNFHUPG2Y53T523WPANCNFSM5BDSUDGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
-- R. Douglas Martin Professor Emeritus in Applied Mathematics and Statistics Founder and Former Director of MS-CFRM Program depts.washington.edu/compfin/ University of Washington
I will check fitTsfmLagLeadBeta() stand alone to make sure it is ok, and post what I find out
Oops, looks like you fixed it
Not yet! Still working through it. Might be an xts issue...getting some odd behavior here during the merge
Got it, thanks.
By the way, once everything is fixed in FA, I am going to enhance that function in two ways:
-
Use the known bias correction as a default option for the current Dimson method.
-
Add the Scholes-Williams method (with bias correction)
You will see the extent to which using one of these methods has a non-trivial impact on beta estimates for micro-cap stocks in the next version of the Robust Time Series Factor Models, by early next week.
Doug
On Fri, Aug 20, 2021 at 2:34 PM Justin M. Shea @.***> wrote:
Not yet! Still working through it. Might be an xts issue...getting some odd behavior here during the merge
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/braverock/FactorAnalytics/issues/43#issuecomment-902970140, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP575YZ6TWFYF3OOHUKHJ63T53C7VANCNFSM5BDSUDGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
-- R. Douglas Martin Professor Emeritus in Applied Mathematics and Statistics Founder and Former Director of MS-CFRM Program depts.washington.edu/compfin/ University of Washington
Sounds compelling! You could open another issues for this and mark it as "feature". Thanks!
On Fri, Aug 20, 2021 at 4:25 PM Justin M. Shea @.***> wrote:
Sounds compelling! You could open another issues and mark it as "feature".
Good thought - will do.
Thanks!
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/braverock/FactorAnalytics/issues/43#issuecomment-903005674, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP575Y46QJIO5JBWOWTX7KDT53P6DANCNFSM5BDSUDGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
-- R. Douglas Martin Professor Emeritus in Applied Mathematics and Statistics Founder and Former Director of MS-CFRM Program depts.washington.edu/compfin/ University of Washington
Last fail on this issue is here:
Name: fitTsfmUpDn
Title: Fit a up and down market factor model using time series
regression
Aliases: fitTsfmUpDn
** Examples
load data
data(managers, package = 'PerformanceAnalytics')
Make syntactically valid column names
colnames(managers) [1] "HAM1" "HAM2" "HAM3" "HAM4" "HAM5"
[6] "HAM6" "EDHEC LS EQ" "SP500 TR" "US 10Y TR" "US 3m TR"
colnames(managers) <- make.names( colnames(managers)) colnames(managers) [1] "HAM1" "HAM2" "HAM3" "HAM4" "HAM5"
[6] "HAM6" "EDHEC.LS.EQ" "SP500.TR" "US.10Y.TR" "US.3m.TR"example: Up and down market factor model with LS fit
fitUpDn <- fitTsfmUpDn(asset.names=colnames(managers[,(1:6)]),mkt.name="SP500.TR", data=managers, fit.method="LS",control=NULL) Error in do.call(lmrobdet.control, control[m2, drop = TRUE]) : second argument must be a list Calls: fitTsfmUpDn -> fitTsfm -> do.call
I could check both this one and the last one. But this is the kind of function level stuff that Kirk could check out, fix, and then I could test run and do the update at github.
Doug
On Fri, Aug 20, 2021 at 5:30 PM Justin M. Shea @.***> wrote:
Name: fitTsfmUpDn Title: Fit a up and down market factor model using time series regression Aliases: fitTsfmUpDn ** Examples load data
data(managers, package = 'PerformanceAnalytics') Make syntactically valid column names
colnames(managers) [1] "HAM1" "HAM2" "HAM3" "HAM4" "HAM5" [6] "HAM6" "EDHEC LS EQ" "SP500 TR" "US 10Y TR" "US 3m TR" colnames(managers) <- make.names( colnames(managers)) colnames(managers) [1] "HAM1" "HAM2" "HAM3" "HAM4" "HAM5" [6] "HAM6" "EDHEC.LS.EQ" "SP500.TR" "US.10Y.TR" "US.3m.TR" example: Up and down market factor model with LS fit
fitUpDn <- fitTsfmUpDn(asset.names=colnames(managers[,(1:6)]),mkt.name=" SP500.TR", data=managers, fit.method="LS",control=NULL) Error in do.call(lmrobdet.control, control[m2, drop = TRUE]) : second argument must be a list Calls: fitTsfmUpDn -> fitTsfm -> do.call
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/braverock/FactorAnalytics/issues/43#issuecomment-903022187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP575Y3EAKNDLGV2EPJ73D3T53XSXANCNFSM5BDSUDGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .
-- R. Douglas Martin Professor Emeritus in Applied Mathematics and Statistics Founder and Former Director of MS-CFRM Program depts.washington.edu/compfin/ University of Washington
Next function failing:
Name: fmmcSemiParam
Title: Semi-parametric factor model Monte Carlo
Aliases: fmmcSemiParam
** Examples
fit a time series factor model for all assets
load data
data(managers, package = 'PerformanceAnalytics')
colnames(managers)
[1] "HAM1" "HAM2" "HAM3" "HAM4" "HAM5"
[6] "HAM6" "EDHEC LS EQ" "SP500 TR" "US 10Y TR" "US 3m TR"
Make syntactically valid column names
colnames(managers) <- make.names( colnames(managers))
colnames(managers)
[1] "HAM1" "HAM2" "HAM3" "HAM4" "HAM5"
[6] "HAM6" "EDHEC.LS.EQ" "SP500.TR" "US.10Y.TR" "US.3m.TR"
fit <- fitTsfm(asset.names=colnames(managers[,(1:6)]),
factor.names=colnames(managers[,(7:9)]),
data=managers)
bootstrap returns using the fitted factor model, Normal dist. for residuals
resid.par <- as.matrix(fit$resid.sd,1,6)
fmmc.returns <- fmmcSemiParam(factor.ret=managers[,(7:9)], beta=fit$beta,
alpha=fit$alpha, resid.par=resid.par)
Error in resid.par[i, ] : subscript out of bounds Calls: fmmcSemiParam -> rnorm Execution halted
Hi @martinrd3D , see above. The example seems to setup the syntax correctly, but the function fails. More to discuss later...
This example works just fine with the following slightly modified code:
data(managers, package = 'PerformanceAnalytics') names(managers)[7:10] <- c("LSEQ","SP500","TBond10Y","RF") # Fix names fit <- fitTsfmLagLeadBeta(asset.names=colnames(managers[,(1:6)]),LagLeadBeta=2, LagOnly=TRUE,mkt.name="SP500",rf.name="RF", data=managers,fit.method="Robust") summary(fit)
I will edit the help file example accordingly, and expect the R CMD Check ERROR to go away. If so, then we can close this issue.
See the comment I just added on this issue # 43.
On Wed, Sep 1, 2021 at 9:15 PM Justin M. Shea @.***> wrote:
Hi @martinrd3D https://github.com/martinrd3D , see above. The example seems to setup the syntax correctly, but the function fails. More to discuss later...
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/braverock/FactorAnalytics/issues/43#issuecomment-911144821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP575YZUXHPX5JQ6EG7VWOLT73273ANCNFSM5BDSUDGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- R. Douglas Martin Professor Emeritus in Applied Mathematics and Statistics University of Washington
Hi @martinrd3D,
I should've been more specific, and was referencing the most recent note posted in this issue, about function fmmcSemiParam.
I fixed the issues associated with fitTsfmLagLeadBeta this weekend and that example runs fine.
Thanks, Justin
On Thu, Sep 2, 2021 at 7:46 AM Justin M. Shea @.***> wrote:
Hi @martinrd3D https://github.com/martinrd3D,
I should've been more specific, and was referencing the most recent note posted about function fmmcSemiParam.
OK, thanks.
Question: Is "FactorAnalytics-Ex.R" just the collection of all the examples in the man pages for all the functions? Else, what?
Doug
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/braverock/FactorAnalytics/issues/43#issuecomment-911766100, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP575Y3ZLKUYZJ76C7BM3A3T76E5XANCNFSM5BDSUDGA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- R. Douglas Martin Professor Emeritus in Applied Mathematics and Statistics University of Washington
After recent enhancement to FitFffm, need to fix a few things that will pop up here e7e0007b2d92163477e30fbe7417fc80f8b46849
@midoshammaa , the last example fails on fmTstats
Name: fmTstats
Title: t-stats and Plots for a fitted Fundamental Factor Model
Aliases: fmTstats fmTstats.ffm
** Examples
data("factorDataSetDjia5Yrs")
Fit a Ffm with style factors only
fit <- fitFfm(data = factorDataSetDjia5Yrs, exposure.vars = c("MKTCAP","ENTVAL","P2B","EV2S"), date.var = "DATE", ret.var = "RETURN", asset.var = "TICKER", fit.method="WLS", z.score = "crossSection")
Compute time series of t-stats and number of significant t-stats
stats = fmTstats(fit, isPlot = TRUE, lwd = 2, color = c("blue", "blue"), z.alpha =1.96)
fit1 <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", exposure.vars = c("SECTOR","MKTCAP","ENTVAL","P2B"), ret.var = "RETURN", date.var = "DATE", addIntercept = TRUE)
Compute time series of t-stats and number of significant t-stats
stats = fmTstats(fit1, isPlot = TRUE, z.alpha = 1.96)
Fit a SECTOR+COUNTRY+Style model with Intercept
Create a COUNTRY column with just 3 countries
factorDataSetDjia5Yrs$COUNTRY = rep(rep(c(rep("US", 1 ),rep("GERMANY", 1 )), 11), 60)
fit.MICM <- fitFfm(data = factorDataSetDjia5Yrs, asset.var = "TICKER", exposure.vars = c("SECTOR", "COUNTRY","P2B", "MKTCAP"), ret.var = "RETURN", date.var = "DATE", addIntercept = TRUE)
Error in R_matrix[[1]] %*% g[[1]][1:K] : non-conformable arguments Calls: fitFfm -> extractRegressionStats -> [ -> [.data.table
@martinrd3D Cleared all ERRORs for now and am closing this issue. We are back down to 1 NOTE, related to data size.
reopening, as many of the items in #69 relate to this, and we are already throwing some new errors as we go through the process of changing data sets as well as FitFfmDT.
For example, this build error related to issues #65
> ### Name: fitFfm
> ### Title: Fit a fundamental factor model using cross-sectional regression
> ### Aliases: fitFfm coef.ffm fitted.ffm residuals.ffm
>
> ### ** Examples
>
>
>
> # Load fundamental and return data
> data("factorDataSetDjia5Yrs")
>
> # fit a fundamental factor model
> exposure.vars <- c("P2B", "MKTCAP")
> fit <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN",
+ date.var="DATE", exposure.vars=exposure.vars)
> names(fit)
[1] "asset.names" "r2" "factor.names" "asset.var"
[5] "date.var" "ret.var" "exposure.vars" "exposures.num"
[9] "exposures.char" "data" "time.periods" "factor.fit"
[13] "beta" "factor.returns" "factor.cov" "resid.var"
[17] "residuals"
>
> # fit a Industry Factor Model with Intercept
> exposure.vars <- c("SECTOR","P2B")
> fit1 <- fitFfm(data=factorDataSetDjia5Yrs, asset.var="TICKER", ret.var="RETURN",
+ date.var="DATE", exposure.vars=exposure.vars, addIntercept=TRUE)
Error in `[.data.frame`(data, , .N, by = c(date.var, obj$exposures.char)) :
unused argument (by = c(date.var, obj$exposures.char))
Calls: fitFfm -> specFfm -> [
Execution halted