regression - getting complex-valued Jacobian Matrix using NonLinearModel.fit in matlab -
i trying use nonlinearmodel.fit()
function in matlab regress 2 variables. however, getting following error:
error using internal.stats.getscheffeparam>validateparameters (line 182) if non-empty, jw must numeric, real matrix. error in internal.stats.getscheffeparam (line 110) [j,vf,vp,jw,intopt,tolsvd,tole,vq,usingj] = validateparameters(j,vf,vp,jw,intopt,tolsvd,tole,vq,allowedintopt); error in nlinfit (line 340) sch = internal.stats.getscheffeparam('weightedjacobian',j(~nans,:),'intopt','observation','vq',vq); error in nonlinearmodel/fitter (line 1121) [model.coefs,~,j_r,model.coefficientcovariance,model.mse,model.errormodelinfo,~] = ... error in classreg.regr.fitobject/dofit (line 219) model = fitter(model); error in nonlinearmodel.fit (line 1484) model = dofit(model); error in getmatrix (line 101) nlm = nonlinearmodel.fit(regressormatrix',temp2',modelfun,beta0);
my regressormatrix
2-by-n (so transpose n-by-2), temp2'
n-by-1, , beta0
, model
given by:
model =@(b,x)b(1).*x(:,1).*x(:,2).^b(2); beta0=[.14 .6]; nlm = nonlinearmodel.fit(regressormatrix',temp2',model,beta0);
could please me in figuring out causing error?
edit: ok, no far try more specific. know error referring weighted jacobian matrix. not sure why jacobian not real-valued.
here first few rows of regressor matrix:
regressormatrix = 1.0e+07 * 0.000000000776613 3.762601240855837 0.000000001683014 3.762601240855837 0.000000001496807 3.762601240855837 0.000000000753495 3.762601240855837
and response matrix:
temp2 = -0.011811061934317 0.987582922964869 0.010621342764736 0.135001167018444 0.091950680609212
i can see wrong here (the orders of magnitude in col2 of regressor matrix off. fix , explanation if turns out the cause. working on printing out j. , jw
edit2: able print out jw before error occurs , discovered jw nx2 complex matrix. specific reason error occurring weighted jacobian matrix not real valued. not sure why...
after lot of digging, found answer problem quite obvious. didn't realize of values 1 of regressor variables going negative sometimes. lead (jumping few steps ahead) complex jacobian.
Comments
Post a Comment