Hi, I have read the help page and it was helpful but, I am having concerns because each time I run this code I get the same value. I expected that each time I run the code, I will get different values due to random sampling. How do I get this randomization? The values shouldn?t be the same each time the code is run, correct? result <- boot(n_data, statistic = DataSummary, R = 100). Best, Bryan Mac bryanmac.24 at gmail.com> On Sep 29, 2016, at 12:16 PM, ruipbarradas at sapo.pt wrote: > > Hello, > > Read the help page ?boot::boot. > For instance, try the following. > > > library(boot) > > x <- rnorm(100) > stat <- function(x, f) mean(x[f]) > boot(x, stat, R = 100) > > Hope this helps, > > Rui Barradas > > > > Citando bryan.mac24 <bryan.mac24 at gmail.com>: > >> Hi all, >> I am wondering how to conduct bootstrapping in R. I need bootstrap 100 times. The trick I need to figure out is how to do get a random sample of 100 out of the total number of case. >> Best, >> BM >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. > > >[[alternative HTML version deleted]]
Dear Bryan You are not resetting the seed each time by any chance? Michael On 01/10/2016 02:44, Bryan Mac wrote:> Hi, > > I have read the help page and it was helpful but, I am having concerns because each time I run this code I get the same value. > I expected that each time I run the code, I will get different values due to random sampling. > > How do I get this randomization? The values shouldn?t be the same each time the code is run, correct? > > > result <- boot(n_data, statistic = DataSummary, R = 100). > > > Best, > > Bryan Mac > bryanmac.24 at gmail.com > > > >> On Sep 29, 2016, at 12:16 PM, ruipbarradas at sapo.pt wrote: >> >> Hello, >> >> Read the help page ?boot::boot. >> For instance, try the following. >> >> >> library(boot) >> >> x <- rnorm(100) >> stat <- function(x, f) mean(x[f]) >> boot(x, stat, R = 100) >> >> Hope this helps, >> >> Rui Barradas >> >> >> >> Citando bryan.mac24 <bryan.mac24 at gmail.com>: >> >>> Hi all, >>> I am wondering how to conduct bootstrapping in R. I need bootstrap 100 times. The trick I need to figure out is how to do get a random sample of 100 out of the total number of case. >>> Best, >>> BM >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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. >> >> >> > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >-- Michael http://www.dewey.myzen.co.uk/home.html
Dear Bryan, Did you try to include formula in the boot command? like: results <- boot(data, statistic, R, formula) All the best, Christoph> On 1 Oct 2016, at 19:24, Michael Dewey <lists at dewey.myzen.co.uk> wrote: > > Dear Bryan > > You are not resetting the seed each time by any chance? > > Michael > > On 01/10/2016 02:44, Bryan Mac wrote: >> Hi, >> >> I have read the help page and it was helpful but, I am having concerns because each time I run this code I get the same value. >> I expected that each time I run the code, I will get different values due to random sampling. >> >> How do I get this randomization? The values shouldn?t be the same each time the code is run, correct? >> >> >> result <- boot(n_data, statistic = DataSummary, R = 100). >> >> >> Best, >> >> Bryan Mac >> bryanmac.24 at gmail.com >> >> >> >>> On Sep 29, 2016, at 12:16 PM, ruipbarradas at sapo.pt wrote: >>> >>> Hello, >>> >>> Read the help page ?boot::boot. >>> For instance, try the following. >>> >>> >>> library(boot) >>> >>> x <- rnorm(100) >>> stat <- function(x, f) mean(x[f]) >>> boot(x, stat, R = 100) >>> >>> Hope this helps, >>> >>> Rui Barradas >>> >>> >>> >>> Citando bryan.mac24 <bryan.mac24 at gmail.com>: >>> >>>> Hi all, >>>> I am wondering how to conduct bootstrapping in R. I need bootstrap 100 times. The trick I need to figure out is how to do get a random sample of 100 out of the total number of case. >>>> Best, >>>> BM >>>> [[alternative HTML version deleted]] >>>> >>>> ______________________________________________ >>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>>> 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. >>> >>> >>> >> >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > > -- > Michael > http://www.dewey.myzen.co.uk/home.html > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
On 9/30/2016 6:44 PM, Bryan Mac wrote:> Hi, > > I have read the help page and it was helpful but, I am having concerns because each time I run this code I get the same value. > I expected that each time I run the code, I will get different values due to random sampling. > > How do I get this randomization? The values shouldn?t be the same each time the code is run, correct? > > > result <- boot(n_data, statistic = DataSummary, R = 100). > > > Best, > > Bryan Mac > bryanmac.24 at gmail.com > > > >> On Sep 29, 2016, at 12:16 PM, ruipbarradas at sapo.pt wrote: >> >> Hello, >> >> Read the help page ?boot::boot. >> For instance, try the following. >> >> >> library(boot) >> >> x <- rnorm(100) >> stat <- function(x, f) mean(x[f]) >> boot(x, stat, R = 100) >> >> Hope this helps, >> >> Rui Barradas >> >> >> >> Citando bryan.mac24 <bryan.mac24 at gmail.com>: >> >>> Hi all, >>> I am wondering how to conduct bootstrapping in R. I need bootstrap 100 times. The trick I need to figure out is how to do get a random sample of 100 out of the total number of case. >>> Best, >>> BM >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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. >> >> >> > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >Bryan, You haven't told us anything about the structure of your data, or the definition of the DataSummary function. We are left to guess what you are doing. The posting guide calls for a reproducible example. At a minimum give us some sample data (myabe use dput()), the definition of DataSummary, the code you use to set up and call the boot() funtion, and examples of your output that shows you "getting the same answer." Someone may then be able to do more than guess at what the problem is. Dan -- Daniel Nordlund Port Townsend, WA USA
> On 01 Oct 2016, at 16:11 , Daniel Nordlund <djnordlund at gmail.com> wrote: > > You haven't told us anything about the structure of your data, or the definition of the DataSummary function.Yes. Just let me add that a common error with boot() is not to pay attention to the required form of the statistic= function argument. It should depend on the data and a set of indices and (for nonparametic bootstrap) it is the indices that are random. Typical mistakes are to completely ignore the index argument, or to write clumsy code that ignores the data specification, as in coef(lm(df$y~df$x, data=d[f])). -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com