bootstrapping results in table format

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

bootstrapping results in table format

Peter Wagey
Hi R users,
I was struggling to put the results into table format. Would you mind to
show using following data and code how we can put the results into table? I
further would like to have a  confidence interval for each group.


set.seed(1000)
data <- as.data.table(list(x1 = runif(200), x2 = runif(200), group =
runif(200)>0.5))
data.frame(data)
head(data)
stat <- function(x, i) {x[i, c(m1 = mean(x1))]}
A<-data[, list(list(boot(.SD, stat, R = 10))), by = group]$V1

Thanks

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] bootstrapping results in table format

Rolf Turner
On 07/10/17 12:16, Peter Wagey wrote:

> Hi R users,
> I was struggling to put the results into table format. Would you mind to
> show using following data and code how we can put the results into table? I
> further would like to have a  confidence interval for each group.
>
>
> set.seed(1000)
> data <- as.data.table(list(x1 = runif(200), x2 = runif(200), group =
> runif(200)>0.5))
> data.frame(data)
> head(data)
> stat <- function(x, i) {x[i, c(m1 = mean(x1))]}
> A<-data[, list(list(boot(.SD, stat, R = 10))), by = group]$V1

(1) Don't post in html.

(2) Don't send code that makes use of packages that you don't mention
(in this case "data.table").

(3) Don't use "data" as the name of a data object.  There is a base
function called "data" whence you run the risk of getting toadally
incomprehensible error messages as the result of certain syntax errors.
Also see fortune("dog").

cheers,

Rolf Turner


--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] bootstrapping results in table format

David Winsemius

> On Oct 7, 2017, at 1:32 PM, Rolf Turner <[hidden email]> wrote:
>
> On 07/10/17 12:16, Peter Wagey wrote:
>> Hi R users,
>> I was struggling to put the results into table format. Would you mind to
>> show using following data and code how we can put the results into table? I
>> further would like to have a  confidence interval for each group.
>> set.seed(1000)
>> data <- as.data.table(list(x1 = runif(200), x2 = runif(200), group =
>> runif(200)>0.5))
>> data.frame(data)
>> head(data)
>> stat <- function(x, i) {x[i, c(m1 = mean(x1))]}
>> A<-data[, list(list(boot(.SD, stat, R = 10))), by = group]$V1
>
> (1) Don't post in html.
>
> (2) Don't send code that makes use of packages that you don't mention
> (in this case "data.table").

Not to mention the boot package.

>
> (3) Don't use "data" as the name of a data object.  There is a base function called "data" whence you run the risk of getting toadally incomprehensible error messages as the result of certain syntax errors.
> Also see fortune("dog").

Dear Peter;

Rolf makes good points.

What sort of table do you want? Have you looked at the structure of `A`?


str(A)  # output omitted in the interest of brevity

# It's an unnamed list of two 'boot' objects (one for each group), each of which is a named list.

> names(A[[1]])
 [1] "t0"        "t"         "R"         "data"      "seed"      "statistic" "sim"      
 [8] "call"      "stype"     "strata"    "weights"  

> A[[1]]$t0
       m1
0.5158232


---
David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law

______________________________________________
[hidden email] 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.