Simulations study not working entirely...

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Simulations study not working entirely...

R help mailing list-2
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") 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)

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

###############

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Simulations study not working entirely...

Wang Jiefei
Hi Varin,

I did not look inside your code yet but I have a few suggestions. First I
think your problem should be described in more detail, just saying you have
a problem is not enough for us to diagnose. Second Your example depends on
too many other packages and I'm not sure if you need all of them to
reproduce the error. A minimum example will be appreciated. finally, if
this is a package problem as you said, it might be better to ask the
question in https://github.com/kloke/hbrfit/issues since the author
definitely knows the context more than us and might be able to provide a
solution for your question.

Best,
Jiefei

On Mon, Oct 21, 2019 at 12:41 PM varin sacha via R-help <
[hidden email]> 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") 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)
>
> 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
>
> ###############
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Simulations study not working entirely...

Wang Jiefei
In reply to this post by R help mailing list-2
Hi,

After I install all dependencies your example seems fine

```
> MSE_fastMM
[1] 2.629064e-05
>
> MSE_Huber
[1] 1.826184e-05
>
> MSE_Tukey
[1] 2.622499e-05
>
> MSE_L1
[1] 1.044155e-05
>
> MSE_fastTau
[1] NaN
>
> MSE_HBR
[1] 1.60821e-05
>
> MSE_DCML
[1] 9.519007e-06
>
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods
base

other attached packages:
 [1] hbrfit_0.02       Rfit_0.23.0       RobStatTM_1.0.1   fit.models_0.5-14
 [5] RobPer_1.2.2      rgenoud_5.8-3.0   BB_2019.10-1      quantreg_5.51
 [9] SparseM_1.77      MASS_7.3-51.4     robustbase_0.93-5
```

There is no error or warning, except that  MSE_fastTau is an NaN. What
problem are you looking for?

Best,
Jiefei

On Mon, Oct 21, 2019 at 12:41 PM varin sacha via R-help <
[hidden email]> 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") 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)
>
> 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
>
> ###############
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Simulations study not working entirely...

R help mailing list-2
 Dear Wang,

Really appreciated but I have tried dependencies=TRUE and it still does not work.
Is it because my R version is 3.6.1 ? sessionInfo() at the end of the message

install.packages( "robustbase",dependencies=TRUE )
install.packages( "MASS" ,dependencies=TRUE )
install.packages( "quantreg" ,dependencies=TRUE )
install.packages( "RobPer",dependencies=TRUE  )
install.packages("devtools",dependencies=TRUE )  install_github("kloke/hbrfit",dependencies=TRUE) install.packages('http://www.stat.wmich.edu/mckean/Stat666/Pkgs/npsmReg2_0.1.1.tar.gz',dependencies=TRUE )
install.packages( "RobStatTM",dependencies=TRUE  )

library(robustbase)
library(MASS)
library(quantreg)
library(RobPer)
library(hbrfit)
library(RobStatTM)

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
Random number generation:
RNG:     Mersenne-Twister 
Normal:  Inversion 
Sample:  Rounding 
locale:[1] fr_CH.UTF-8/fr_CH.UTF-8/fr_CH.UTF-8/C/fr_CH.UTF-8/fr_CH.UTF-8
attached base packages:[1] stats     graphics  grDevices utils     datasets  methods   base    
loaded via a namespace (and not attached):[1] compiler_3.6.1







Le lundi 21 octobre 2019 à 20:12:02 UTC+2, Wang Jiefei <[hidden email]> a écrit :





Hi,

After I install all dependencies your example seems fine

```
> MSE_fastMM
[1] 2.629064e-05
>
> MSE_Huber
[1] 1.826184e-05
>
> MSE_Tukey
[1] 2.622499e-05
>
> MSE_L1
[1] 1.044155e-05
>
> MSE_fastTau
[1] NaN
>
> MSE_HBR
[1] 1.60821e-05
>
> MSE_DCML
[1] 9.519007e-06
>
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252  
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
 [1] hbrfit_0.02       Rfit_0.23.0       RobStatTM_1.0.1   fit.models_0.5-14
 [5] RobPer_1.2.2      rgenoud_5.8-3.0   BB_2019.10-1      quantreg_5.51    
 [9] SparseM_1.77      MASS_7.3-51.4     robustbase_0.93-5
```

There is no error or warning, except that  MSE_fastTau is an NaN. What problem are you looking for?

Best,
Jiefei

On Mon, Oct 21, 2019 at 12:41 PM varin sacha via R-help <[hidden email]> 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") 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)
>
> 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
>
> ###############
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Simulations study not working entirely...

Wang Jiefei
What problem you have encountered? I still do not know your question.
Please elaborate on your question and post the error message or
something else that prevents you from running the code.

Thanks,
Jiefei

On Mon, Oct 21, 2019 at 3:13 PM varin sacha <[hidden email]> wrote:

>  Dear Wang,
>
> Really appreciated but I have tried dependencies=TRUE and it still does
> not work.
> Is it because my R version is 3.6.1 ? sessionInfo() at the end of the
> message
>
> install.packages( "robustbase",dependencies=TRUE )
> install.packages( "MASS" ,dependencies=TRUE )
> install.packages( "quantreg" ,dependencies=TRUE )
> install.packages( "RobPer",dependencies=TRUE  )
> install.packages("devtools",dependencies=TRUE )
> install_github("kloke/hbrfit",dependencies=TRUE) install.packages('
> http://www.stat.wmich.edu/mckean/Stat666/Pkgs/npsmReg2_0.1.1.tar.gz',dependencies=TRUE
> )
> install.packages( "RobStatTM",dependencies=TRUE  )
>
> library(robustbase)
> library(MASS)
> library(quantreg)
> library(RobPer)
> library(hbrfit)
> library(RobStatTM)
>
> sessionInfo()
> R version 3.6.1 (2019-07-05)
> Platform: x86_64-apple-darwin15.6.0 (64-bit)
> Running under: macOS Sierra 10.12.6
> Matrix products: default
> BLAS:
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
> LAPACK:
> /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
> Random number generation:
> RNG:     Mersenne-Twister
> Normal:  Inversion
> Sample:  Rounding
> locale:[1] fr_CH.UTF-8/fr_CH.UTF-8/fr_CH.UTF-8/C/fr_CH.UTF-8/fr_CH.UTF-8
> attached base packages:[1] stats     graphics  grDevices utils
> datasets  methods   base
> loaded via a namespace (and not attached):[1] compiler_3.6.1
>
>
>
>
>
>
>
> Le lundi 21 octobre 2019 à 20:12:02 UTC+2, Wang Jiefei <[hidden email]>
> a écrit :
>
>
>
>
>
> Hi,
>
> After I install all dependencies your example seems fine
>
> ```
> > MSE_fastMM
> [1] 2.629064e-05
> >
> > MSE_Huber
> [1] 1.826184e-05
> >
> > MSE_Tukey
> [1] 2.622499e-05
> >
> > MSE_L1
> [1] 1.044155e-05
> >
> > MSE_fastTau
> [1] NaN
> >
> > MSE_HBR
> [1] 1.60821e-05
> >
> > MSE_DCML
> [1] 9.519007e-06
> >
> > sessionInfo()
> R version 3.6.0 (2019-04-26)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows >= 8 x64 (build 9200)
>
> Matrix products: default
>
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] splines   stats     graphics  grDevices utils     datasets  methods
> base
>
> other attached packages:
>  [1] hbrfit_0.02       Rfit_0.23.0       RobStatTM_1.0.1
> fit.models_0.5-14
>  [5] RobPer_1.2.2      rgenoud_5.8-3.0   BB_2019.10-1      quantreg_5.51
>
>  [9] SparseM_1.77      MASS_7.3-51.4     robustbase_0.93-5
> ```
>
> There is no error or warning, except that  MSE_fastTau is an NaN. What
> problem are you looking for?
>
> Best,
> Jiefei
>
> On Mon, Oct 21, 2019 at 12:41 PM varin sacha via R-help <
> [hidden email]> 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") 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)
> >
> > 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
> >
> > ###############
> >
> > ______________________________________________
> > [hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Simulations study not working entirely...

David Winsemius
In reply to this post by R help mailing list-2

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
>
> ###############
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Simulations study not working entirely...

R help mailing list-2
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 <[hidden email]> 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
>
> ###############
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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.