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!

2 Kommentare

Seems the function is
u.*(tau-(u<0))
Sara Boni
Sara Boni am 9 Jun. 2022
Ok, great, thank you!

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Gefragt:

am 9 Jun. 2022

Kommentiert:

am 9 Jun. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by