-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcovthosl.m
More file actions
76 lines (67 loc) · 2.07 KB
/
covthosl.m
File metadata and controls
76 lines (67 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function covth=covthosl(th,params,covm,ifinv)
% covth=COVTHOSL(th,params,covg,ifinv)
%
% Estimates the covariance matrix of the parameter estimate according to Eq. 36
% of Guillaumin et al 2022 as the matrix product of the Fisher information
% matrix with the covariance matrix of the score
%
% INPUT:
%
% th Matern spectral parameters, [s2 nu rh]
% params Parameter structure of the grid; at least p.NyNx and p.dydx must be
% provided explicitly
% covm A method specification for the covariance calculation
% 1 sampling
% 2 dfmtx
% 3 diagonals
% ifinv Indicate which parameters were inverted for and require covariance
% calculation
%
% OUTPUT:
%
% covth Covariance of the parameter estimates
%
% SEE ALSO:
%
% COVGAMMIOSL
%
% EXAMPLES:
%
% th=[1.41 0.75 6];
% p=[];p.NyNx=[65 92];p.dydx=[1 1];p.blurs=Inf;ifinv=[1 1 1];
% covg=covgammiosl(th,p,1,ifinv);
% covth=covthosl(th,p,covm,ifinv);
%
% covth=covthosl(th,p,1,ifinv);
%
% Last modified by fjsimons-at-alum.mit.edu, 05/15/2025
% Last modified by olwalbert-at-princeton.edu, 05/15/2025
if covm==0
covth=zeros(sum(ifinv),sum(ifinv));
return
end
% Let's stick to easier problems for now
defval('ifinv',[1 0 1])
% If we did not bring in a precomputed variance of the score
% calculate it now via the specified method
if prod(size(covm))==1
covm=covgammiosl(th,params,covm,ifinv);
end
% Calculate the Fisher information matrix for the grid
k=knums(params);
F=fishiosl(k,th,params);
% If the data were tapered and the periodogram was blurred, I think we need to
% modify how F is normalized in FISHIOSL (i.e., taking the mean of mth products)
if isfield(params,'taper') & numel(params.taper)>1 & isinf(params.blurs)
nt=sum(params.taper,'all');
nt=nt/prod(params.NyNx);
% Should be less than or equal to 1; if not, check out the taper
if nt>1; keyboard; end
F=F*nt;
end
% Degrees of freedom calculated according to FISHIOSL
df=length(k(:))/2;
% Only calculate the covariance for parameters that we inverted for
F=matslice(F,ifinv);
covF=inv(F);
covth=covF*covm*covF;