1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Bootstrapping and R

  1. Apr 24, 2013 #1
    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)
    Error in rlogis(N, a, b) : object 'N' not found
    > {
    + 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.

    Thanks in advance
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: Bootstrapping and R
  1. Int x' dV/|r-r'| ? (Replies: 0)

  2. Showing Density in R (Replies: 0)

Loading...