MATLAB Answers

sbiofitmixed/ nlmefit and weighting two dependent variables

2 views (last 30 days)
Jim Bosley
Jim Bosley on 1 Sep 2019
Commented: Jim Bosley on 7 Nov 2019
I am fitting a trial with two output measurements (for now). These are CONC1 and CONC2. Supposing that they have very different magnitudes, I'd like to set weights for fitting to allow errors in each measurement to have the same effect on parameters estimated. Right now I can nail the larger valued CONC1, but the accuracy of the fit of the smaller CONC2 is poor.
I tried:
mcnc1 = mean(gdata.CONC_1(~isnan(gdata.CONC_1))); % Use NaN data to get mean for concentration 1
mcnc2 = mean(gdata.CONC_2(~isnan(gdata.CONC_2))); % Use NaN data to get mean for concentration 2
erwts = [1/mcnc1 1/mcnc2]; % Set weights so that the two concentrations are about equally weighted
clear opto; % Make sure I have a "clean" optimoptions
opto.Options = statset('Display','iter','TolX',1e-3,'TolFun',1e-3); % Per instructions in sbiofitmixed
opto.ErrorModel = 'combined'; % Per instructions in nlmefit
opto.Weights = erwts; % This does set the value for Opto.Weights.
The problem is, sbiofitmixed gags on this. I get:
Error using nlmefit>parseInVarargin (line 1937)
Unknown parameter name: Weights.
Error in nlmefit (line 401)
Error in sbiofitmixed (line 241)
[results.beta, results.psi, results.stats, results.b] = feval(estimationFunctionName, timeVectorStacked, yVectorStacked,
groupVectorStacked, groupList, yPredictFcn, beta0, nameValuePairs{:});
Error in Fit_PK_nlme_prot (line 66)
[fitcon4, simdat4] = sbiofitmixed( ...
Is their any way to weight the relative errors for CONC1 and CONC2? I suppose I could create a model variable that is 100 times the value for CONC2, and put a column in my dataset that is CONC2*100, and fit them together, but this seems pretty crude. Other estimation functions allow this weighting. Any way to get there with sbiofitmixed?

  1 Comment

Jim Bosley
Jim Bosley on 7 Nov 2019
Bump. Quick rehash: In trying to fit two different concentrations over time, for the same trial, is there an easy way to weight the different concentration errors. I can do this with vectors the size of my datastreams, which seems a little crude.
For measured data values of d1(t) and d2(t), and corresponding model values of m1(t) and m2(t), where m1 and d1 >> m2 and d2, I'd like
Error = (m1-d1)'*(m1-d1)* w1 + (m2-d2)'*(m2-d2)*w2
where w1 and w2 are sclar weights. Or must I create weight vectors based upon the number data points of data, ndata, such as
W1 = w1*ones(ndata,1);
where W1 is a vector and w1 is a scalar?

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!