Not sure I understand your question, but if the function is not directly observed, and you want to do inference on this latent variable, the code you wrote above is correct.
Not sure I understand your question, but if the function is not directly observed, and you want to do inference on this latent variable, the code you wrote above is correct.