# Bootstrapping and R

1. Apr 24, 2013

### Artusartos

1. The problem statement, all variables and given/known data

I have the code:

>delta<-function(y,n,sigma,a,b,N){

+T<-rlogis(N,a,b)

+W<-sqrt(n)/(sqrt(2)*pi*sigma)*exp((-n*(y-T)^2)(S*sigma^2))

+d<-mean(T*W)/mean(T)

+return(d)

+}

And I want to compute this M times for y=8,n=7,sigma=2,a=3,b=1,N=1000,M=10000.

2. Relevant equations

3. The attempt at a solution

So this is what I wrote:

>my.sample<-delta(8, 7, 2,3,1,1000)

+M<-10000

+M;d<-numeric(M)

+for(i in 1:M)

+d=delta(y,n,sigma,a,b,N)

+{

>x<-sample(delta, 10000, replace=TRUE)

>M;d<-mean(x)}

But I keep getting errors, so I must be doing something wrong but I'm not sure what.

In other words, this is how it looks like in R:

> my.sample<-delta(8, 7, 2,3,1,1000)
Error in delta(8, 7, 2, 3, 1, 1000) : attempt to apply non-function
> M<-10000
> M;d<-numeric(M)
[1] 10000
> for(i in 1:M)
+ d=delta(y,n,sigma,a,b,N)
> {
+ x<-sample(delta, 10000, replace=TRUE)
+ M;d<-mean(x)}
Error in x[.Internal(sample(length(x), size, replace, prob))] :
object of type 'closure' is not subsettable

I've been trying to fix this for a long time, and it's really frustrating...any help would be appreciated.