forked from Zwucki/OneArmPhaseTwoStudy_GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr_sub1design.h
130 lines (118 loc) · 6.32 KB
/
r_sub1design.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// An object of this class implements all methods needed for planning, monitoring,
// and analyzing subset designs.
// (Internally the appropriated methods from the "OneArmePhaseTwoStudy" r-package are used.)
//
// This file is part of OneArmPhaseTwoStudy.
//
// OneArmPhaseTwoStudy is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// OneArmPhaseTwoStudy is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details (http://www.gnu.org/licenses/).
#ifndef R_SUB1DESIGN_H
#define R_SUB1DESIGN_H
#ifndef PACKAGE_NAME
#define PACKAGE_NAME "OneArmPhaseTwoStudy"
#endif
#define SOLNAME_SUB1 "sub1Sol"
#define SUB1_OBJECT "sub1"
#include <RInside.h>
#include <QString>
#include <QTextStream>
#include <QtGui>
#include "sub1_result.h"
#include <QDebug>
class R_Sub1Design
{
public:
R_Sub1Design();
R_Sub1Design(long double alpha, long double beta, long double pc0, long double pt0, long double pc1, long double pt1);
~R_Sub1Design();
// Tries to load the "OneArmPhaseTwo"-package. If successful the method returns "true" otherwise "false".
bool loadPackage();
// Identifies simon's tow stage designs which fit to the current values of the member variables "alpha", "beta", "pc0",
// "pt0", "pc1", "pt1" and "maxn".
// skipS: If true skips the iteration over "s" at certian points to improve calculation speed (finds less designs).
// skipR: If true skips the iteration over "r" at certian points to improve calculation speed (finds less designs).
// skipN1: If true skips the iteration over "n1" at certian points to improve calculation speed
// (finds less designs and it is impossible to determine the optimalization criteria of the found designs).
// lowerBorder: Sets a minimal value for "n" (number of patients to be recruited).
// upperBorder: Sets a maximal value for "n" (number of patients to be recruited).
void calculateStudySolutions(bool skipS, bool skipR, bool skipN1, int lowerBorder, int upperBorder);
// Returns the number of identified designs (after "calculateStudySolutions" was invoked).
int getNumberOfResults();
// Estimates the effect of (non-)stochastic curtailment for the "subset" design with the ID "resID".
// cut: Sets the "cut point" used to calculate the effect of (non-)stochastic curtailment. A study is stopped if the conditional power falls below the value of "cut".
// reps: Number of replications used to estimate the effect of (non-)stochastic curtailment.
// all: If true the effect of (non-)stochastic curtailment will be calculated for different cut points in 0.05 steps starting with the value of the parameter "cut".
void calculateSC(int resID, double cut, int reps, bool all);
// Calculates the "uniformly minimal variance unbiased estimator" (UMVUE)
// for the true response rate for the subset endpoint based on the approach of Grishick, Mosteller and Savage.
// t: Observed responses in the subset endpoint.
// r1: Critical value for the first stage.
// n1: Sample size for the first stage.
// n: Overall sample size.
double get_UMVUE_ep1(int t, int r1, int n1, int n);
// Calculates the "uniformly minimal variance unbiased estimator" (UMVUE) for the true response rate for the superset endpoint.
// t: Observed responses in the subset endpoint.
// u: Observed responses in the superset endpoint.
// r1: Critical value for the first stage.
// n1: Sample size for the first stage.
// n: Overall sample size.
double get_UMVUE_ep2(int t, int u, int r1, int n1, int n);
// Returns the conditional power when "t" responses in the supset and "u" responses in the superset endpoint
// where observed out of "enrolled" Patients for the given Simon's tow stage design.
// t: Observed responses in the subset endpoint.
// u: Observed responses in the superset endpoint.
// enrolled: Number of enrolled patients.
// r1: Critical value for the first stage.
// n1: Sample size for the first stage.
// r: Critical value for the subset endpoint.
// s: Critical value for the superset endpoint.
// n: Overall sample size.
// pc1: The response probability under the alternative hypothesis for the subset endpoint.
// pt1: The response probability under the alternative hypothesis for the superset endpoint.
double get_conditionalPower(int t, int u, int enrolled, int r1, int n1, int r, int s, int n, double pc1, double pt1);
// Calculates the exact p value for a given subset design.
// t: Observed responses in the subset endpoint.
// u: Observed responses in the superset endpoint.
// enrolled: Number of enrolled patients.
// r1: Critical value for the first stage.
// n1: Sample size for the first stage.
// n: Overall sample size.
// pc0: The response probability for the subset endpoint under the null hypothesis.
// pt0: The response probability for the superset endpoint under the null hypothesis.
double get_pValue(int t, int u , int r1, int n1, int n, double pc0, double pt0);
// Approximate the maximal value of "n" for the previously set values of
// "alpha", "beta", "pc0", "pt0", "pc1" and "pt1" in a way that the optimal design should be found through "calculateStudySolutions".
int aproximateMaxN();
// Definition of getters and setters for the member variables.
void setAlpha(double alpha);
double getAlpha();
void setBeta(double beta);
double getBeta();
void setPc0(double pc0);
double getPc0();
void setPt0(double pt0);
double getPt0();
void setPc1(double pc1);
double getPc1();
void setPt1(double pt1);
double getPt1();
// Returns the ID of the minimax design under the identified designs.
int getMinimaxPos();
// Returns the ID of the optimal design under the identified designs.
int getOptimalPos();
Sub1_result* getResult(int id);
private:
RInside &R;
bool packageLoaded;
bool solutionsCalculated;
std::vector<Sub1_result*> *allResults;
double alpha, beta, pc0, pt0, pc1, pt1;
};
#endif // R_SUB1DESIGN_H