[R] Fast tau-estimator line does ot appear on the plot

varin sacha varinsacha at yahoo.fr
Sat Mar 31 21:52:18 CEST 2018


Many thanks Duncun,

Best,





Le samedi 31 mars 2018 à 18:05:53 UTC+2, Duncan Murdoch <murdoch.duncan at gmail.com> a écrit : 





On 31/03/2018 11:57 AM, varin sacha via R-help wrote:
> Dear R-experts,
> 
> Here below my reproducible R code. I want to add many straight lines to a plot using "abline"
> The last fit (fast Tau-estimator, color yellow) will not appear on the plot. What is going wrong ?
> Many thanks for your reply.
> 

It's not quite reproducible:  you forgot the line to create Dataset. 
It's probably something like

Dataset <- data.frame(Y, Z)

> ##########
> 
> Y=c(2,4,5,4,3,4,2,3,56,5,4,3,4,5,6,5,4,5,34,21,12,13,12,8,9,7,43,12,19,21)
> Z=c(43,2,1,2,34,4,3,4,5,30,4,5,4,3,4,5,56,6,43,21,34,19,12,11,9,34,21,23,2,19)
> reg1<-lm(Z ~ Y)
> plot(Y,Z)
> abline(reg1, col="black")
> 
> install.packages("robustbase")
> library (robustbase)
> reg=lmrob(Z ~ Y, data = Dataset)
> abline(reg, col="green")
> 
> install.packages("MASS")
> library(MASS)
> Huber=rlm(Z ~ Y, data = Dataset)
> abline(Huber,col="red")
> 
> Tukey=rlm(Z ~ Y, data = Dataset,psi=psi.bisquare)
> abline(Tukey,col="purple")
>  
> install.packages("quantreg")
> library(quantreg)
> L1=rq(Z ~ Y, data = Dataset,tau=0.5)
> abline(L1,col="blue")
>  
> install.packages("RobPer")
> library(RobPer)
> FastTau(Z,Y)
> fast=FastTau(Z,Y)
> abline(fast, col="yellow")

abline() doesn't know what to do with the "fast" object.  It isn't a 
vector containing intercept and slope, it's a list containing them.  So 
you'll need something like

abline(unlist(fast), col="yellow")

Duncan Murdoch


> 
> ##########
>  
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



More information about the R-help mailing list