问题
I have a very unbalanced dataset ,, thousands of healthy participants and 21 patients (16 male and 5 female) ,, I want to use bootstrapping to define a new sampler but with control of age and gender. this is the method i'm using
parametric_bootstrap_boot <- function(x) {
# Perform bootstrap using boot package
# Estimate mean
mu <- boot(x, samplemean, R=1000)$t0
#Estimate sd
sd <- boot(x, samplesd, R=1000)$t0
# Sample 21 observations
set.seed(1)
samples <- rnorm(21,mu,sd)
return(samples)
}
how can I control for age and gender of the healthy resampling method ?
my data looks like this
Patient ID Age Mean_RR SDNN RMSSD nn50 pnn50 SEX Year of birth.0.0 Date of all cause dementia report.0.0 Source of all cause dementia report.0.0 Date of alzheimer's disease report.0.0 Source of alzheimer's disease report.0.0 Date of vascular dementia report.0.0 Source of vascular dementia report.0.0
1.53E+09 56 1257 397.34 468 2 33.33 Female 1961 NA NA NA NA NA NA
1.53E+09 56 1257 397.34 468 2 33.33 Female 1961 NA NA NA NA NA NA
this is how I call the function
control_BPM <- abs(parametric_bootstrap_boot(control_BPM))
control_SDNN <- abs(parametric_bootstrap_boot(control_SDNN))
control_RMSSD <- abs(parametric_bootstrap_boot(control_RMSSD))
来源:https://stackoverflow.com/questions/64908737/r-bootstrapping-with-control-for-age-and-gender