Articles

Affichage des articles du août, 2020

More on linear regression... take care of initial point for robust regression

 It is better to supply a initial point for robust regression ! x <- c(0.428571428571429, 0.2, 0.3, 0, 0, 0.2, 0, 0, 0.1, 0, 0.1,    0.1, 0, 0, 0, 0.3, 0.2, 0.3, 0.2, 0.2, 0, 0, 0, 0.2, 0.222222222222222,    0.1, 0, 0.4, 0.3, 0.5, 0, 0.4, 0.5, 0.8, 0.3, 0.1, 0.2, 0, 0.1,    0, 0.1, 0.1, 0.4, 0, 0, 0, 0, 0, 0, 0.333333333333333, 0.444444444444444,    0.2, 0.222222222222222, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0.4, 0, 0, 0, 0, 0.111111111111111, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,    0.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0.2, 0, 0, 0, 0, 0, 0, 0) y <- c(0.369999388816617, 0.152260672623962, 0.392636473518975, 0.107742543910461,         0.105802942749025, 0.147888875829182, 0.0180958542177892, 0.00376865991773073,         0.008...

Create a named vector with names stored in a variable

Often I want create a named vector and the names are stored in a variable. I must use a 2 steps function: names <- paste0("V", 1:100) A <- 1:100 names(A) <- names I search a way to do the same in a single step. Here is the solution: A <- structure(1:100, .Dim = 100L,                     .Dimnames = list(names)) But which one is the faster? names <- paste0("V", 1:100) library(microbenchmark) microbenchmark({     A <- 1:100     names(A) <- names},      {A <- structure(1:100, .Dim = 100L,                     .Dimnames = list(names))},      times = 1000L) Unit: microseconds                                                                 expr  min ...