statistics-bootstrap

R: Bootstrapped binary mixed-model logistic regression using bootMer() of the new lme4 package

本秂侑毒 提交于 2019-12-20 17:32:08
问题 I want to use the new bootMer() feature of the new lme4 package (the developer version currently). I am new to R and don't know which function should I write for its FUN argument. It says it needs a numerical vector, but I have no idea what that function will perform. So I have a mixed-model formula which is cast to the bootMer(), and have a number of replicates. So I don't know what that external function does? Is it supposed to be a template for bootstrapping methods? Aren't bootstrapping

How to bootstrap a function with replacement and return the output

假如想象 提交于 2019-12-13 07:02:57
问题 I am trying to take two randomly drawn subsamples from a data frame, extract the means of a column in the subsamples and calculate the difference between means. The below function and use of replicate within do.call should work as far as I can tell, but I keep getting an error message: Example data: > dput(a) structure(list(index = 1:30, val = c(14L, 22L, 1L, 25L, 3L, 34L, 35L, 36L, 24L, 35L, 33L, 31L, 30L, 30L, 29L, 28L, 26L, 12L, 41L, 36L, 32L, 37L, 56L, 34L, 23L, 24L, 28L, 22L, 10L, 19L),

Bootstrap by groups with Boot package

偶尔善良 提交于 2019-12-13 05:39:49
问题 I have a "my.dataset" like this: ID Species SEX Category V1 V2 V3 87790 Caniceps F F_Caniceps -0.34 -0.55 0.61 199486 Caniceps F F_Caniceps -0.34 -0.56 0.63 199490 Caniceps F F_Caniceps -0.37 -0.54 0.57 199493 Caniceps F F_Caniceps -0.35 -0.54 0.58 200139 Caniceps F F_Caniceps -0.39 -0.51 0.51 393151 Caniceps M M_Caniceps -0.36 -0.56 0.55 393154 Caniceps M M_Caniceps -0.36 -0.55 0.55 486210 Caniceps M M_Caniceps -0.41 -0.50 0.45 811945 Hyemalis F F_Hyemalis -0.35 -0.54 0.55 811947 Hyemalis F

How to randomly draw from subsets of data and bootstrap a statistic test in R

会有一股神秘感。 提交于 2019-12-12 20:55:30
问题 I have a dataset containing two variables and I wish to statistically test whether they are related in a bootstrap loop (i.e. using Spearman’s rank correction with cor.test(...) ). Most of the measurements in my dataset are from independent sample units (let’s call the units plants), although some measurements come from the same plant. To deal with issues of pseudoreplication, I wish to bootstrap the statistic test a number of times, using only one measurement from each plant in each run of

cluster one-dimensional data using pvclust

自古美人都是妖i 提交于 2019-12-11 09:14:17
问题 Thanks for taking time read this question. I have some one-dimensional data to cluster in R. The basic hclust command works fine. But the pvclust command, however, does not take one-dimensional data, and keeps saying: Error in hclust(distance, method = method.hclust) : must have n >= 2 objects to cluster I found a work-around, that I added some all-zero rows to the data. So the data becomes: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 7.424 14.251 15.957 1.542 2.451 20.836 13.534

Non-parametric bootstrapping on the highest level of clustered data using boot() function from {boot} in R

十年热恋 提交于 2019-12-11 04:03:49
问题 I have two-level hierarchical data and I'm trying to perform non-parametric bootstrap sampling on the highest level, i.e., randomly sampling the highest-level clusters with replacement while keeping the original within-cluster data. I want to achieve this using the boot() function in the {boot} package, for the reason that I then would like to build BCa confidence intervals using boot.ci() which requires a boot object. Here follows my unlucky attempt - running a debug on the boot call showed

bootstrapping/resampling matrix by row in R

走远了吗. 提交于 2019-12-11 03:12:15
问题 I have a matrix x with 20 rows and 10 columns. I need to sample (with replacement) 5 rows at a time and calculate column means. I need to repeat this procedure by 15 times and report the column means for each time. As an example, I used resample library in R to perform this. # Create a random matrix library("resample") set.seed(1234) x <- matrix( round(rnorm(200, 5)), ncol=10) ## Bootstrap 15 times by re sampling 5 rows at a time. k <- bootstrap(x,colMeans,B = 15,block.size=5) My concern with

R: bootstrapped mixed model binary logistic regression

牧云@^-^@ 提交于 2019-12-10 11:36:19
问题 I need to bootstrap my mixed model binary logistic regression. The model itself works fine (and is approved and corrected by an expert friend), but the bootstrapped version is buggy. The bootstrapped version was previously approved by another expert friend (in CrossValidated but later mods removed my post saying it does not belong on CrossValidated). But the same code happened to work for a simple fixed-effects multiple logistic regression (although in that case too there were lots of

R bootstrap weighted mean by group with data table

爱⌒轻易说出口 提交于 2019-12-10 11:00:48
问题 I am trying to combine two approaches: Bootstrapping multiple columns in data.table in a scalable fashion with Bootstrap weighted mean in R Here is some random data: ## Generate sample data # Function to randomly generate weights set.seed(7) rtnorm <- function(n, mean, sd, a = -Inf, b = Inf){ qnorm(runif(n, pnorm(a, mean, sd), pnorm(b, mean, sd)), mean, sd) } # Generate variables nps <- round(runif(3500, min=-1, max=1), 0) # nps value which takes 1, 0 or -1 group <- sample(letters[1:11], 3500

bootstrap weighted mean in R

我与影子孤独终老i 提交于 2019-12-08 04:08:59
问题 I know how to bootstrap the mean of a vector: library(boot) samplemean <- function(x, d) { return(mean(x[d])) } results_qsec <- boot(data=mtcars$qsec, statistic = samplemean, R=1000) but how do I bootstrap the weighted mean, considering for instance values are in mtcars$qsec and weights on these values are in mtcars$wt ? 回答1: The trick is to specify the weights for weighted.mean as part of the ... argument to boot . Here I use j for the weights, and pass it through as a data frame, to match