R - bootstrapping with control for age and gender

久未见 提交于 2021-01-29 08:19:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!