Dear David, Dear Jiefei, Many thanks for your comments. I got it now. It works.
Best, Sacha Le lundi 21 octobre 2019 à 22:00:39 UTC+2, David Winsemius <dwinsem...@comcast.net> a écrit : On 10/21/19 9:40 AM, varin sacha via R-help wrote: > Dear R-Experts, > > Here below my reproducible example working but not entirely (working). What I > understand is that there is a problem of libraries library(hbrfit) and ... ? > How can I make it work entirely, many thanks for your precious help. > > ########SIMULATION STUDY 3 variables with 10% outliers n=2000 > install.packages( "robustbase" ) > install.packages( "MASS" ) > install.packages( "quantreg" ) > install.packages( "RobPer" ) > install.packages("devtools") library("devtools") > install_github("kloke/hbrfit") When I attempted to replicate your code, I deciced to issue both of these commands in hte line above on separate lines. If you entered as above there shoiuld have been an error because there needs to be a semicolon to separate more than one distinct command on a single line. > install.packages('http://www.stat.wmich.edu/mckean/Stat666/Pkgs/npsmReg2_0.1.1.tar.gz') > install.packages( "RobStatTM" ) > > > library(robustbase) > library(MASS) > library(quantreg) > library(RobPer) > library(hbrfit) > > library(RobStatTM) > > n<-2000 > > x<-runif(n, 0, 5) > > z <- rnorm(n, 2, 3) > > a <- runif(n, 0, 5) > > y_model<- 0.1*x - 0.5 * z - a + 10 > > y_obs <- y_model +c( rnorm(n*0.9, 0, 0.1), rnorm(n*0.1, 0, 0.5) ) > > > fastMM <- lmrob( y_obs ~ x+z+a) > > Huber <- rlm( y_obs ~ x+z+a) > > Tukey <- rlm( y_obs ~ x+z+a, psi = psi.bisquare ) > > L1 <- rq( y_obs ~ x+z+a, tau = 0.5 ) > > fastTau <- FastTau(model.matrix(~newdata$x+newdata$z+newdata$a),newdata$y_obs) At this point the compiler should emit an error since newdata has not been created: fastTau <- FastTau(model.matrix(~newdata$x+newdata$z+newdata$a),newdata$y_obs) Error in eval(predvars, data, env) : object 'newdata' not found -- David. > > HBR<-hbrfit(y_obs ~ x+z+a) > > DCML <-lmrobdetDCML(y_obs ~ x+z+a) > > > MSE_fastMM<-mean((fastMM$fitted.values - y_model)^2) > > MSE_Huber<-mean((Huber$fitted.values - y_model)^2) > > MSE_Tukey<-mean((Tukey$fitted.values - y_model)^2) > > MSE_L1<-mean((L1$fitted.values - y_model)^2) > > MSE_fastTau<-mean((fastTau$fitted.values - y_model)^2) > > MSE_HBR<-mean((HBR$fitted.values - y_model)^2) > > MSE_DCML<-mean((DCML$fitted.values - y_model)^2) > > > MSE_fastMM > > MSE_Huber > > MSE_Tukey > > MSE_L1 > > MSE_fastTau > > MSE_HBR > > MSE_DCML > > ############### > > ______________________________________________ > R-help@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. [[alternative HTML version deleted]] ______________________________________________ R-help@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.