Skip to content

Commit 8d73b99

Browse files
author
Andy
committed
Add swe input accidentally left off of swe branch merge
1 parent 7d62cf9 commit 8d73b99

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
classdef SandwichEstimatorInput < handle
2+
% used to pass object by reference to SandwichEstimatorInputGUI and
3+
% receive output settings from that GUI
4+
%
5+
% call 'struct' function on an instance of this class to get an
6+
% equivalent struct
7+
properties
8+
groupId %n x 1 vector
9+
permute_method = nla.edge.permutationMethods.FCWildBootstrap();
10+
stdErrCalcObj %implements nla.helpers.stdError.AbstractSwEStdErrStrategy()
11+
behavior % nx1 vector (combine into covariates/variables)
12+
covariates % nxp matrix
13+
contrasts % c x (p+1) matrix
14+
contrastNames % c x 1 cell of strings of names
15+
FORCE_ORDINARY_LEAST_SQUARES = false
16+
17+
inputGuiSettingsStruct = []%struct to hold state of input GUI for re-loading input settings
18+
end
19+
20+
21+
methods
22+
function outStruct = pushFieldsIntoStruct(obj, inStruct)
23+
outStruct = inStruct;
24+
25+
classProps = properties(obj);
26+
27+
for iProp = 1:length(classProps)
28+
thisPropName = classProps{iProp};
29+
30+
outStruct.(thisPropName) = obj.(thisPropName);
31+
end
32+
33+
end
34+
35+
function loadFieldsFromStruct(obj, inStruct)
36+
classProps = properties(obj);
37+
38+
for iProp = 1:length(classProps)
39+
thisPropName = classProps{iProp};
40+
41+
if isfield(inStruct, thisPropName)
42+
obj.(thisPropName) = inStruct.(thisPropName);
43+
end
44+
end
45+
end
46+
47+
function isValid = isValid(obj)
48+
isValid = true;
49+
50+
groupRows = size(obj.groupId,1);
51+
[covarRows, covarCols] = size(obj.covariates);
52+
[contrastRows, contrastCols] = size(obj.contrasts);
53+
54+
if any([covarCols, contrastCols] ~= covarCols)
55+
isValid = false;
56+
end
57+
if obj.stdErrCalcObj.REQUIRES_GROUP && groupRows==0
58+
isValid = false;
59+
end
60+
61+
if contrastCols<=0
62+
isValid = false;
63+
end
64+
65+
end
66+
67+
function set.FORCE_ORDINARY_LEAST_SQUARES(obj, forceOLS)
68+
if forceOLS
69+
obj.stdErrCalcObj = nla.helpers.stdError.Homoskedastic();
70+
end
71+
obj.FORCE_ORDINARY_LEAST_SQUARES = forceOLS;
72+
end
73+
end
74+
75+
end

0 commit comments

Comments
 (0)