Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-R CMD Check ERROR: Running examples in ‘FactorAnalytics-Ex.R’ failed #43

Open
JustinMShea opened this issue Jul 28, 2021 · 20 comments
Assignees
Labels

Comments

@JustinMShea
Copy link
Collaborator

JustinMShea commented Jul 28, 2021

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

@JustinMShea
Copy link
Collaborator Author

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.

@martinrd3D
Copy link
Collaborator

martinrd3D commented Aug 20, 2021 via email

@martinrd3D
Copy link
Collaborator

I will check fitTsfmLagLeadBeta() stand alone to make sure it is ok, and post what I find out

@martinrd3D
Copy link
Collaborator

Oops, looks like you fixed it

@JustinMShea
Copy link
Collaborator Author

Not yet! Still working through it. Might be an xts issue...getting some odd behavior here during the merge

@martinrd3D
Copy link
Collaborator

martinrd3D commented Aug 20, 2021 via email

@JustinMShea
Copy link
Collaborator Author

JustinMShea commented Aug 20, 2021

Sounds compelling! You could open another issues for this and mark it as "feature". Thanks!

@martinrd3D
Copy link
Collaborator

martinrd3D commented Aug 20, 2021 via email

@JustinMShea
Copy link
Collaborator Author

JustinMShea commented Aug 21, 2021

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

@martinrd3D
Copy link
Collaborator

martinrd3D commented Aug 21, 2021 via email

JustinMShea added a commit that referenced this issue Aug 21, 2021
JustinMShea added a commit that referenced this issue Aug 21, 2021
JustinMShea added a commit that referenced this issue Aug 22, 2021
 and `StockReturns` discussed in #34
JustinMShea added a commit that referenced this issue Aug 22, 2021
…which get filled in by "." during merge.xts.
@JustinMShea
Copy link
Collaborator Author

JustinMShea commented Oct 4, 2021

After recent enhancement to FitFffm, need to fix a few things that will pop up here e7e0007

@JustinMShea
Copy link
Collaborator Author

JustinMShea commented Oct 20, 2021

@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

JustinMShea added a commit that referenced this issue Nov 17, 2021
…scores6, results in an error in fitFfm and fitFfmDT
JustinMShea added a commit that referenced this issue Dec 10, 2021
@JustinMShea
Copy link
Collaborator Author

@martinrd3D Cleared all ERRORs for now and am closing this issue. We are back down to 1 NOTE, related to data size.

@JustinMShea
Copy link
Collaborator Author

JustinMShea commented Dec 20, 2021

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

@JustinMShea JustinMShea reopened this Dec 20, 2021
JustinMShea added a commit that referenced this issue Dec 22, 2021
…ck error in #43, but ran into #73. Reprioritize project board issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants