[R] boostrap an nls regression
Paul Johnson
pauljohn32 at gmail.com
Sun Feb 6 07:58:48 CET 2011
Hello!
On Thu, Feb 3, 2011 at 6:27 AM, m234 <mhairialexander at gmail.com> wrote:
>
> II functional response for 2 data sets:
>
> nls(eaten~(a*suppl)/(1+a*h*suppl)
>
> where eaten is the number of prey eaten by a predator and suppl is the
> number of prey initially supplied to the same predator.
>
> I have parameter estimates of 'a' and 'h' for the two populations studied
> and would like to know if there is a significant different in the estimates
> between the two i.e. a1 vs a2, h1 vs h2. I would like to bootstap the data
> to get multiple (~1000) estimates and compare then via a ttest or
> equivalent. Is it possible to do this and obtain multiple estimations which
Hi,
Please read the posting guide--a complete example of your code a link
to a data frame will get you more helpful answers.
I can tell you how to do bootstrap re-sampling on a model that is
estimated from one data set. I wrote up some notes on that last summer
(go to middle of this
http://pj.freefaculty.org/R/SummerCamp2010/PJ-Lectures/functions1.pdf).
I have other intro R material floating about under the R part of that
link.
But I'm a bit stumped by your question for statistical reasons--
nothing to do with R. From a statistical point of view, how do you
test the difference between coefficients from 2 different fitted nls
models, which are based on separate data samples? I don't think
that's a trivial stat question, even if you have large samples and you
only need to calculate that estimated difference one time.
Then I wonder, how would a person do re-sampling when there are 2 data
sets involved. If you know of a cite on that, I'd like to see it.
One avenue I'd consider is to stack the 2 data sets together and
rewrite my nls to estimate one equation with indicator variables
(dummy variables) to separate the estimates for the 2 separate
equations. But there would be some "pooling" tests you'd have to run
first, to justify the idea that the 2 sets of data belong in the same
analysis in the first place.
Know what I mean? Suppose eaten is one long column, for both sets
combined, but create suppl1 and suppl2 that are 0 for "the other" data
set's cases, but suppl for the right one.
Fit this:
combmod <- nls(eaten~(a1*suppl1)/(1+a1*h1*suppl1) +
(a2*suppl2)/(1+a2*h2*suppl2))
This would conceivably allow comparison of a1 and a2. I think. I'm
trying to remember sampling theory on nls.
Well, in summary, I think you've got a harder stat problem than you
have R problem. If you write out the code you use for a whole
exercise to do this 1 time, we might see what to do. But remember to
post the full working example--as much as you have, anyway.
--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas
More information about the R-help
mailing list