I have data for 5 replicates that were drawn from the same model and I want to fit all 5 replicates together so that I can find out the shared parameters. Specifically, if I have the underlying distribution -

$$y = Ae^{-mx} + c$$

and then I have 5 output files with x and y (x is the same for all replicates). I want to fit all these together to estimate $A$, $m$ and $c$.

The outputs y1,...y5 should be independent.

y = c(y1, y2, y3, y4, y5)
x = c(x1, x2, x3, x4, x5)

And then I estimate my shared parameters using nls.

nls(y ~ Ae^-mx+ c)

My question is that if it is appropriate to generate a combined file to estimate the shared parameters or the replicates/ samples need to be handled differently?

  • $\begingroup$ Your model specification is missing an error term. $\endgroup$
    – Glen_b
    Commented Aug 12, 2014 at 17:24

1 Answer 1


If the parameters and the distribution of the error term are the same in each case, you can simply combine them all into one larger sample and fit the model.

It's even possible to estimate some parameters in common, while others are unique to a given data set.

So your supposition looks like it's correct.

  • $\begingroup$ When I do this in R, the output contains multiple fitted lines - there nls has one parameter for the model but I essentially get 5 fitted lines. Shouldnt there be just one fit? Specifically, I am using fit <- nls(y ~ (C + A*exp(-m * x)), start=val, control=list(maxiter=1000, warnOnly=TRUE)) $\endgroup$
    – user19758
    Commented Aug 12, 2014 at 18:08
  • $\begingroup$ What are the dimensions of y and x ? Did you fail to stack them up? $\endgroup$
    – Glen_b
    Commented Aug 12, 2014 at 23:22
  • $\begingroup$ For each replicate (x1,y1), I have 1000 rows for x1 and y1. There are 5 such replicates (x1,x2,x3,x4,x5) and so the fitted values include 5000 rows. For stacking, I am just combining the x and y values using, y = c(y1, y2, y3, y4, y5) x = c(x1, x2, x3, x4, x5). Note: x values in x1..x5 arrays are the same; The y values vary a little across replicates. nls estimates one value of A, c and m but the fitted file contains 5000 rows. The output plot has 1 exponential and 4 linear curves. However, upon inspection, I noticed that the fitted values for the same for replicates. Thanks for your help. $\endgroup$
    – user19758
    Commented Aug 13, 2014 at 2:02
  • $\begingroup$ It's not clear - did that solve your problem or is there some outstanding issue? $\endgroup$
    – Glen_b
    Commented Aug 13, 2014 at 2:57
  • $\begingroup$ No outstanding issue. Thanks for your suggestions and help in resolving the issue. $\endgroup$
    – user19758
    Commented Aug 13, 2014 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.