Marginal effects plot with partial residuals from CmdStanFit

Could anyone please direct me to the method how to obtain marginal effects and associated partial residuals from CmdStanFit (fitted using the $sample method from the CmdStanR interface)? I would like to plot them to assess the potential presence of non-linear trends like here:

Would it be possible to use ggeffects (or any other similar package) with CmdStanFit object? Or is the only way to do it coding it within generated quantities block?

The doc is here:

By “marginal effects”, I assume you mean the estimated parameter values? For that, you wan to grab the summary statistics, which is covered in the getting started doc:

Residuals are tricky in Bayes land. Do you want residual vs. point prediction or a distribution of residuals in the posterior? The former has to be done on the outside, but the latter can calculate the residuals in the generated quantities block.