This is an extended comment rather than an answer.
LinearModelFit
vs NonlinearModelFit
While using NonlinearModelFit
is more straightforward (in my opinion), you'll likely have fewer convergence issues with LinearModelFit
if you have large datasets as both give (essentially) the same results and LinearModelFit
doesn't need starting values:
SeedRandom[12345];
x = Range[1, 20];
n = 10;
y = 200/n + 2 x + RandomVariate[NormalDistribution[0, 4], 20];
data = Transpose[{x, y}];
ListPlot[data]
lm = LinearModelFit[data, {1/n, z}, z];
nlm = NonlinearModelFit[data, c/n + b z, {c, b}, z];
lm["BestFitParameters"]
(* {211.42453245272156, 1.741387448625845} *)
nlm["BestFitParameters"]
(* {c -> 211.4245324527219, b -> 1.741387448625842} *)
How do you specify the uncertainty of a predictor variable?
It sounds like this is your real question is about $n$ being a predictor variable rather than a parameter to be estimated. This also violates the assumption that the predictors are fixed and known. You can't get around that problem with anything that NonlinearModelFit
has to offer.
If the variability of the predictor variable is small enough, then you don't have to worry about it. However, you first need to characterize the unstated amount and kind of variability that $n$ has. For example, is the standard deviation of distribution associated with $n$ small compared to the range of $n$ values you expect to use?
You might consider the following links: Bayesian approach and Error-in-variables.
Questions on data structure
Do $c$ and $d$ (and the error variance) vary among your many
datasets? If they do, then it doesn't matter at all if you're only
interested in predictions. You'll get the same predictions if you
use $c/n$ or $c$ or $c^2$.
Is $n$ a predictor variable (i.e., each data point in a data set have
potentially a different value of $n$) or just some value you set? If
$c$ and $d$ and the error variance are common to all datasets, then you'll need to include $n$ as a predictor variable in the combined dataset given to NonlinearModelFit
.
Weights -> 1 / nvalues
? $\endgroup$