[R] Error in FastTau(formula, data = d) : unused argument(s) (data = d)
varin sacha
v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sun Mar 22 00:14:28 CET 2020
Dear R-helpers,
Another problem with FastTau function from the RobPer packages. Any solution to solve my problem would be highly appreciated.
# # # # # # # # # # # # # # # # # # # # # # # #
install.packages( "boot",dependencies=TRUE )
install.packages( "RobPer",dependencies=TRUE )
library(boot)
library(RobPer)
n<-200
b<-runif(n, 0, 5)
z <- rnorm(n, 2, 3)
a <- runif(n, 0, 5)
y_model<- 0.1*b - 0.5 * z - a + 10
y_obs <- y_model +c( rnorm(n*0.9, 0, 0.1), rnorm(n*0.1, 0, 0.5) )
df<-data.frame(b,z,a,y_obs)
# function to obtain MSE
MSE <- function(data, indices, formula){
d <- data[indices, ] # allows boot to select sample
fit <- FastTau(formula, data = d)
ypred <- predict(fit)
mean((d[["y_obs"]]-ypred)^2)
}
# Make the results reproducible
set.seed(1234)
# bootstrapping with 600 replications
results <- boot(data = df, statistic = MSE,
R = 600, formula = model.matrix(~b+z+a))
str(results)
boot.ci(results, type="bca" )
# # # # # # # # # # # # # # # # # # # # # # # # #
More information about the R-help
mailing list