How to translate this function into matlab?

Hello everyone, I am trying to translate this R function to compute the pseudo-R-squared in MATLAB. I did
rho <- function(u,tau=.5)u*(tau - (u < 0))
V <- sum(rho(f$resid, f$tau))
I did the following, but I get the error: "Array indices must be positive integers or logical values."
function rho = TickFunction(u,tau)
%Tick function to evaluate a quantile regression model performance
%u is the residuals of the fitted model
%tau is the quantile of interest
rho = u(tau - (u<0));
end
Anyone could help?
Thanks!

Answers (0)

Asked:

on 9 Jun 2022

Commented:

on 9 Jun 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!