Function 'extract' for other package that build a 'stanfit' object

HI!

I would like use the function \mathtt{extract} for a \mathtt{stanfit} object. The model was created in \mathtt{TMB} (is not a bayesian software) but with the library \mathtt{tmbstan} I can obtain this type of object directly. When I want use this function appear the following error:

extract(fit_1)
Error in UseMethod(“extract_”) :
no applicable method for ‘extract_’ applied to an object of class “stanfit”

but, my model is a \mathtt{stanfit} object:

class(fit_1)
[1] “stanfit”
attr(,“package”)
[1] “rstan”

My question is, how works this function and how I could (eventually) connect it with \mathtt{tmbstan}?

Thanks!

1 Like

You may have to use rstan::extract to avoid namespace conflicts.

1 Like

Thanks @bgoodri!! this works perfectly