Thanks. I did the search before I posted and found those threads. However, it does not seem to do what I want. All I want to do is estimate the sample size for a point estimate, not do a GLM. I just want the mean within a margin of error, and to a given CI.
I've tried writing some code to do a simulation (below). Will this do the job? #Generate data from Poission distribution, with lambda = 5 data = rpois(200, lambda = 5) mean(data); var(data) #Parameter Estimates moe = 0.03 # margin of error = +/- 3% sample.size = 168 # number of hunters to sample #Draw sample size from population, calc mean. Run 10,000 iterations d = numeric(10000) for (i in 1:10000) { samp = (sample(data, sample.size, replace = FALSE)) d[i] = mean(samp) } #What are the bounds on the values that correspond to the margin of error? lower=mean(data)-moe upper=mean(data)+moe #values from 'd' based on 90% confidence intervals q25=quantile(d, 0.05) q95=quantile(d,0.95) #top row = bounds on the mean from the margin of error, second row = bounds based on simulated data and sample size, third row = 1 = true, 0 = false in terms of the sample size being adequate to meet requirements of the margin of error. output=rbind(cbind(lower,upper), cbind(q25,q95), cbind(q25>lower, q95<upper)) row.names(output) = c("known", "estimated","True/False") output On 12-Nov-08, at 4:41 PM, David Winsemius wrote: > The first hit for search on "sample size" and "poisson" on Baron's > search engine web interface appears on target: > > http://search.r-project.org/cgi-bin/namazu.cgi?query=%22sample+size%22+poisson&max=100&result=normal&sort=score&idxname=functions&idxname=Rhelp02a > > Getting the same result from your console window requires a couple > of extra back-slashes: > > > RSiteSearch(""sample size" poisson") > Error: syntax error > > RSiteSearch("\"sample size\" poisson") > A search query has been submitted to http://search.r-project.org > The results page should open in your browser shortly. > > -- > David Winsemius > Heritage Labs > > > On Nov 12, 2008, at 2:46 PM, Shawn Morrison wrote: > >> Is there a function in R that will allow me to estimate the sample >> size required from count data (poisson data?), given the known >> variance and desired margin of error and confidence interval? >> >> My specific data set will be based on a survey of hikers that will be >> asked about the number of animals of species 'x' they observed during >> a given period. I need to know the number of hikers to interview. ie, >> I would like to calculate the mean number of species 'x' +/- margin >> of >> error with 95% confidence. >> >> This is a simple exercise for normally distributed continuous data, >> but I'm running into roadblocks for count data. >> >> Sincerely, >> Shawn Morrison >> [[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. > [[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.