## How to keep a Fixed Effect constant in NLMEFIT and NLMEFITSA?

### Andres (view profile)

on 1 Jul 2012
Hi everyone
I'm following the example for NLMEFIT (<http://www.mathworks.com/help/toolbox/stats/nlmefit.html>),
and I would like to know if there is any way to keep the some of the beta parameters constant. in the example, they set beta0 = [100 100 100]; but the algorithm estimates all three and gives a final beta=[191.3189 723.7608 346.2517]. My idea is to estimate 2 of the parameters, but the other keep it equal to it's initial value.
I would also like to fix the variance of some of the parameters, anyone knows how to do that? In the example they explain how to set variance to 0 for one parameter, but what if I want an specific variance for a certain parameter?
Andres
Use an anonymous function to specify a logistic growth model:
model=@(PHI,t)(PHI(:,1))./(1+exp(-(t-PHI(:,2))./PHI(:,3)));
Fit the model using nlmefit with default settings (that is, assuming each parameter is the sum of a fixed and a random effect, with no correlation among the random effects):
TIME = repmat(time,5,1);
NUMS = repmat((1:5)',size(time));
beta0 = [100 100 100];
[beta1,PSI1,stats1] = nlmefit(TIME(:),CIRC(:),NUMS(:),... [],model,beta0)
beta1 = 191.3189 723.7608 346.2517
PSI1 = 962.1534 0 0 0 0.0000 0 0 0 297.9881
[beta2,PSI2,stats2,b2] = nlmefit(TIME(:),CIRC(:),... NUMS(:),[],model,beta0,'REParamsSelect',[1 3])
beta2 = 191.3194 723.7628 346.2548
PSI2 = 962.2114 0 0 298.3989
b2 = -28.5250 31.6063 -36.5070 39.0735 -5.6479 10.0097 -0.7638 6.0117 -9.4685 -5.7892

### Tom Lane (view profile)

Answer by Tom Lane

### Tom Lane (view profile)

on 1 Jul 2012

I can't think of any way to fix the variance. To fix a parameter value, I suppose you could write a new function
model=@(PHI,t)(PHI(:,1))./(1+exp(-(t-100)./PHI(:,2)));
or
newmodel=@(PHI,t) model([PHI(:,1),10*ones(size(PHI,1),1),PHI(:,3)],t)
I have not tried this out, so please forgive any typos -- just hoping this gives you an idea.

Andres

on 2 Jul 2012