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

CAPM.beta #166

Open
ggrothendieck opened this issue Aug 26, 2021 · 3 comments
Open

CAPM.beta #166

ggrothendieck opened this issue Aug 26, 2021 · 3 comments

Comments

@ggrothendieck
Copy link

ggrothendieck commented Aug 26, 2021

CAPM.beta help file claims it works with vectors and zoo objects but these fail. Also the error message runs off the edge of the screen and is unreadable.

CAPM.beta(1:10, 1:10)
## Error in checkData(Ra) : 
##    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-

CAPM.beta(zoo(1:10), zoo(1:10))
## Error in checkData(Ra) : 
##   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'. 

@braverock
Copy link
Owner

what part of the error message isn't clear?

x<-zoo(1:10,as.Date(1:10))
CAPM.beta(x,x)
# 1
y<-as.vector(x)
names(y) <- index(x)
CAPM.beta(y,y)
# 1

@braverock
Copy link
Owner

All inputs to CAPM.beta need to be able to be aligned by a time index. If checkData can't align Ra and Rb by the index, there is high chance of user error simply lining up two un-named vectors, or integer(or other non-time)-indexed ordered observations. In the example above, using a Date index (for zoo) or Date-formated names (for the vector) allow checkData to use the index directly for alignment in the case of the zoo object, or infer that the names are likely meant to be a Date index for the vector.

Perhaps you could be a little more clear about the use case that you see where using a non-time index makes sense?

@braverock
Copy link
Owner

Also the error message runs off the edge of the screen and is unreadable.

I just checked this as well, and I can't reproduce this symptom,

I tested

CAPM.beta(1:10, 1:10)

in bash, csh, sh, ash terminals, which are all the terminals that I have installed, and also tested over ssh to a remote machine and tested in the RStudio terminal, and the the error message wraps based on the terminal width for me.

Perhaps terminal settings are to blame here? Or can you provide more information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants