+ Reply to Thread
Results 1 to 3 of 3

Thread: Trying to write R function, binomial distribution

  1. #1
    Points: 9, Level: 1
    Level completed: 17%, Points required for next Level: 41

    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trying to write R function, binomial distribution




    Hello!

    I am looking for some help with an Intro to R homework from a professor who doesn't clearly explain the things we need to know for the homework in class...

    I'm trying to figure out how to write a function to simulate the sampling distribution of the mean when the population has a binomial distribution. The function should have the following form:

    centralLimit = function(nreps, nobs, trials, ps, hist=FALSE, qqnorm=FALSE, ...)

    My already written code defining the variables is here:

    # number of samples
    nreps = 10000
    # number of observations in each sample
    nobs = 100
    # number of trials in each observation
    trials = 5
    # probability of "success" in each trial
    ps = .1

    # generate data
    binomSamps = lapply(rep(nobs,nreps), rbinom, size=trials, prob=ps)

    # compute sample means
    mymeans = sapply(binomSamps, mean)


    Any help would be much appreciated!!

  2. #2
    Points: 9, Level: 1
    Level completed: 17%, Points required for next Level: 41

    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Trying to write R function, binomial distribution

    Any thoughts??

    The follow-up to this is using the written CentralLimit function (from above) with nobs of 5, 10, 50, 100 and 500 and to plot all of the histograms and Q-Q plots

  3. #3
    Points: 8,120, Level: 60
    Level completed: 85%, Points required for next Level: 30

    Posts
    169
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Re: Trying to write R function, binomial distribution


    1. What is your question, exactly?
    2. Typically, most of the forum users do not like to do student's homework. However, you are invited, to condense your problem into a core part, which solution you do not know, as most forum user do with their (job related) R programming problems.
    3. Reposting may make other people misleading think your problem has been solved already.

    Consuli
    Prediction is very difficult, especially about the future. (Niels Bohr)

+ Reply to Thread

           




Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats