rregressionpredictrobust

How to calculate fitted values for robust regression models


I'm using robustreg package in R to fit robust regression models, my models are based on iteratively reweighted least squares, the least squares in these models are weighted using Tukey's Bisquare Psi Function and Huber Psi Function, to estimate the models I used the following codes:

 RobBS <- robustRegBS(UND~FA+FS+IPOV+ROA+NI+IPOR+Pd+MP30+D20,data=IPO, m=TRUE, max.it=1000)

RobH <- robustRegH(UND~FA+FS+IPOV+ROA+NI+IPOR+Pd+MP30+D20,data=IPO, m=TRUE, max.it=1000)

But the function does only return the coefficients, weights and the mean squared errors, so I needed to find the fitted values, to this end I used the functions fitted() and predict() with the object of outputs obtained from the two functions, but it didn't work, is there any R package that is specially made for this case? I mean a package that can calculate the fitted values of robust regression models.


Solution

  • The package itself is likely the way to go. It seems that the creator of the package had little awareness of the class functionality of R. The package contains a function fit_rcpp, using help(fit_rcpp) the documentation states that it will give the robust prediction of y, given a design X and coefficients b (Not well explained either).

    So for this specific package you could obtain the estimates using this function.

    model_matrix <- model.matrix(UND ~ FA + FS + IPOV + ROA + NI + IPOR + Pd + MP30 + D20, data = IPO)
    fit_rcpp(model_matrix, RobBS$coefficients)
    fit_rcpp(model_matrix, RobH$coefficients)