Skip to content

Commit

Permalink
Fix multimodel bug to reshape parameter constraints inside 'posterior…
Browse files Browse the repository at this point in the history
… likelihood function'
  • Loading branch information
Munsky committed Oct 23, 2024
1 parent ac3efa3 commit 9f42b79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions WorkSpace/EricModel/a0_Fit_GR_and_DUSP1_models.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
close all
addpath(genpath('../../src'));

loadPrevious = false;
loadPrevious = true;
savedWorkspace = 'workspaceOct22_2024';
addpath('tmpPropensityFunctions');

Expand Down Expand Up @@ -113,7 +113,7 @@
ModelGRfit{i}.tSpan = ModelGRfit{i}.dataSet.times;
end

logPriorGR = @(x)-sum((log10(x)-log10PriorMean(5:12)).^2./(2*log10PriorStd(5:12).^2));
logPriorGR = @(x)-sum((log10(x)-log10PriorMean(5:12)').^2./(2*log10PriorStd(5:12)'.^2));
for jj = 1:fitIters
combinedGRModel = SSITMultiModel(ModelGRfit,ModelGRparameterMap,logPriorGR);
combinedGRModel = combinedGRModel.initializeStateSpaces(boundGuesses);
Expand All @@ -128,16 +128,16 @@
diag(1./(log10PriorStd(ModelGR.fittingOptions.modelVarsToFit)*log(10)).^2); % Add prior in log space.

%% STEP 1.C. -- Run MH on GR Models.
% MHFitOptions.thin=1;
% MHFitOptions.numberOfSamples=100;
% MHFitOptions.burnIn=0;
% MHFitOptions.progress=true;
% MHFitOptions.numChains = 1;
% MHFitOptions.useFIMforMetHast = true;
% MHFitOptions.saveFile = 'TMPEricMHGR.mat';
% [~,~,MHResultsGR] = combinedGRModel.maximizeLikelihood(...
% GRpars, MHFitOptions, 'MetropolisHastings');
% delete(MHFitOptions.saveFile)
MHFitOptions.thin=1;
MHFitOptions.numberOfSamples=100;
MHFitOptions.burnIn=0;
MHFitOptions.progress=true;
MHFitOptions.numChains = 1;
MHFitOptions.useFIMforMetHast = true;
MHFitOptions.saveFile = 'TMPEricMHGR.mat';
[~,~,MHResultsGR] = combinedGRModel.maximizeLikelihood(...
GRpars, MHFitOptions, 'MetropolisHastings');
delete(MHFitOptions.saveFile)

%% STEP 1.D. -- Make Plots of GR Fit Results
makeGRPlots(combinedGRModel,GRpars)
Expand Down
2 changes: 1 addition & 1 deletion src/CommandLine/SSITMultiModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

% Apply prior constraints.
if ~isempty(SMM.parameterConstraints)
totalLogLikelihood = totalLogLikelihood + SMM.parameterConstraints(parameterGuess);
totalLogLikelihood = totalLogLikelihood + SMM.parameterConstraints(parameterGuess(:));
end
end

Expand Down

0 comments on commit 9f42b79

Please sign in to comment.