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

a4ahcxval error due to character in window() function #8

Open
danaim opened this issue Dec 3, 2021 · 4 comments
Open

a4ahcxval error due to character in window() function #8

danaim opened this issue Dec 3, 2021 · 4 comments

Comments

@danaim
Copy link

danaim commented Dec 3, 2021

a4ahcxval() throws an error:
Error in h(simpleError(msg, call)) : error in evaluating the argument 'object' in selecting a method for function 'FLStocks': assignment of an object of class “character” is not valid for @‘range’ in an object of class “FLStock”; is(value, "numeric") is not TRUE
maybe replace lines 148 -149 in xval.R with:
stocks <- FLStocks(lapply(names(stocks), function(x) window(stocks[[x]], end=an(x))))

Thank you,
Danai

@iagomosqueira
Copy link
Member

iagomosqueira commented Dec 3, 2021

Is this with the objects in the package? Have you tried running a4adiags/demo/demo.R? I am adding an example run to xcval help page

data(sol274)

fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) +
  s(replace(age, age > 8, 8), k=4) +
  s(year, k=22, by=as.numeric(age==1))
qmod <- list(~s(age, k=3), ~s(age, k=3))
vmod <- list(~s(age, k=3), ~s(age, k=3), ~s(age, k=3))
srmod <- ~factor(year)

xval <- a4ahcxval(stock, indices, fmodel=fmod, qmodel=qmod, vmodel=vmod)

plotXval(xval$indices)

@danaim
Copy link
Author

danaim commented Dec 3, 2021

I've tried to run the example in the vignette, using the data('sol274'). The an(x) solved the problem and now I am getting a xval output. But plotXval() is not found.

@iagomosqueira
Copy link
Member

I'll check, but window works on character, the year dimname, so no need for an().

plotXval is in ggplotFL, which should be loaded by a4ahcxval

@danaim
Copy link
Author

danaim commented Dec 3, 2021

I reinstalled ggplotFL and plotXvar works fine now,
Thanks a lot

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