Skip to content

bootstrap sample with R

3 messages · Ethan Johnsons, Dimitris Rizopoulos, John Sorkin

#
How do you draw a bootstrap sample of size 9, with replacement, from
the random dataset I drew?   Is there a function for it in R?

9 random samples.
[1]  1.2071538  0.3183367 -1.4237989 -0.4050909  0.9953866  0.9588178  0.9180879
[8] -0.1509696 -1.2230688


thx

ej
#
you need ?sample(), e.g.,

x <- rnorm(9)
sample(x, replace = TRUE)


I hope it helps.

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
      http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Ethan Johnsons <ethan.johnsons at gmail.com>:
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
#
Ethan,
It is quite easy if you use the sample function with replace=TRUE:
[1]  0.0625366 -0.1225751  0.1335859 -1.5930572  0.2493484 -0.1926270
-0.5615023
[8]  0.7537500  1.4977661
[1]  1.4977661  0.1335859  0.0625366  0.2493484 -0.1225751  1.4977661 
0.7537500
[8]  0.2493484  0.0625366

John

John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC,
University of Maryland School of Medicine Claude D. Pepper OAIC,
University of Maryland Clinical Nutrition Research Unit, and
Baltimore VA Center Stroke of Excellence

University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524

(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
jsorkin at grecc.umaryland.edu
How do you draw a bootstrap sample of size 9, with replacement, from
the random dataset I drew?   Is there a function for it in R?

9 random samples.
[1]  1.2071538  0.3183367 -1.4237989 -0.4050909  0.9953866  0.9588178 
0.9180879
[8] -0.1509696 -1.2230688


thx

ej

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html 
and provide commented, minimal, self-contained, reproducible code.

Confidentiality Statement:
This email message, including any attachments, is for the so...{{dropped}}