Hi
Just a copy :-)
Answers please!
Anyway, did my answer resolve your issue?

Petr

From: Clive Nicholas [mailto:cliveli...@googlemail.com]
Sent: Wednesday, November 14, 2012 4:07 AM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: Re: [R] Bootstrapping issues

Thank you for your answer - I will consult the help file to see if it has 
anything to useful to say by way of a solution - but I don't understand why you 
accused me of shouting.

I merely pasted in the R output which contained the heading of the results in 
block letters: I honestly didn't know that this now constituted shouting. I 
don't believe it does. Unless, of course, you objected to my emphasising of 
certain words _like this_. I rather think you'll find that this, too, does not 
contravene any sort of list 'netiquette' - it's commonly found on other 
listservs - and that perhaps you're being rather too sensitive in response.

C
On 13 November 2012 12:53, PIKAL Petr 
<petr.pi...@precheza.cz<mailto:petr.pi...@precheza.cz>> wrote:
Hi


From: Clive Nicholas 
[mailto:cliveli...@googlemail.com<mailto:cliveli...@googlemail.com>]
Sent: Tuesday, November 13, 2012 3:12 AM
To: PIKAL Petr
Cc: r-help@r-project.org<mailto:r-help@r-project.org>
Subject: Re: [R] Bootstrapping issues

Petr Pikal replied:

[...]

> The following works
>
> results <- boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)
>
Actually it does not work either

Correct, but I _did_ get it to work shortly before my initial post (sorry for 
not showing it, but I didn't save the output - silly me).

What seems to happen is that I successfully run the version that _does_ work, 
which I then follow up with successful calls to -plot(results,index=#)- and 
-boot.ci<http://boot.ci>(results,type="bca",index=#)-, then I follow up with 
the unsuccessful version of the code, which won't run and produces the error, 
but when I go back to run the original code, this too produces the same error. 
This, to me at least, is very weird behaviour for R.


> results <- boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)
Error in data[indices, ] : incorrect number of dimensions
>
I am not sure but I suspect your bs function expects some indices vector and it 
is somehow not in accordance with your data.

This code, using different simulated data _does_ run, however:




> mytest<-data.frame(Y=rnorm(500, mean=60, sd=1), X1=sample(c("AAA", "BBB", 
> "CCC", "DDD", "None", NA), size=500, replace=TRUE), X2=sample(c(0.88, 0.99, 
> 1.43, 1.22, 1.1), size=500, replace=TRUE), X3=sample(c("Yes", "No"), 
> size=500, prob=c(0.6,0.4), replace=TRUE))







> bs <- function(formula, data, indices) {

+     mytest <- data[indices,]

+     fit <- lm(formula, data=mytest)

+     return(coef(fit))

+ }

> results <- boot(data=mytest, statistic=bs, R=1000, formula=Y~X1+X2+X3)



Hm. Maybe the difference is in using formula.


> results <- boot(data=test, statistic=bs, R=1000, A~B+C+D+C*D)



>From help page, the fourth parameter is called sim and shall be character 
>vector.



See below.



> results <- boot(data=mytest, statistic=bs, R=1000, Y~X1+X2+X3)

Error in data[indices, ] : incorrect number of dimensions

> results <- boot(data=mytest, statistic=bs, R=1000, formula=Y~X1+X2+X3)

> results



ORDINARY NONPARAMETRIC BOOTSTRAP





Call:

boot(data = mytest, statistic = bs, R = 1000, formula = Y ~ X1 +

    X2 + X3)





Bootstrap Statistics :

       original        bias    std. error

t1* 59.67822240 -0.0060177161  0.29491879

t2*  0.09745349  0.0004995554  0.15627776

t3*  0.24210280 -0.0047317673  0.15018019

t4* -0.03399254 -0.0046603446  0.15884994

t5*  0.15302117 -0.0038503464  0.14045470

t6*  0.15040121  0.0074829413  0.24225957

t7*  0.18454691 -0.0003127565  0.09321305

>




<snip>

Answers please!

Do not shout, please. I presented an answer and if you consulted help page you 
could find out what I also found out.

Regards
Petr

Clive Nicholas (clivenicholas.posterous.com<http://clivenicholas.posterous.com>

[Please DO NOT mail me personally here, but at 
<clivenicho...@hotmail.com<mailto:clivenicho...@hotmail.com>>. Please respond 
to contributions I make in a list thread here. Thanks!]

"My colleagues in the social sciences talk a great deal about methodology. I 
prefer to call it style." -- Freeman J. Dyson



--
Clive Nicholas (clivenicholas.posterous.com<http://clivenicholas.posterous.com>)

[Please DO NOT mail me personally here, but at 
<clivenicho...@hotmail.com<mailto:clivenicho...@hotmail.com>>. Please respond 
to contributions I make in a list thread here. Thanks!]

"My colleagues in the social sciences talk a great deal about methodology. I 
prefer to call it style." -- Freeman J. Dyson

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to