Handy Reference Sheet 2 - HRP 259 Calculation Formula's For Sample Data
Handy Reference Sheet 2 - HRP 259 Calculation Formula's For Sample Data
Handy Reference Sheet 2 - HRP 259 Calculation Formula's For Sample Data
Sample mean: x = x
i 1
i
n n
Sum of squares of x: SS x ( xi x )
2
i 1
[to ease computation: SS x x
i 1
i
2
nx 2 ]
n
SS
Sample variance: s x2 = x = (x
i 1
i x)2
n 1
n 1
sx (x
i 1
i x)2
Standard error of the sample mean: =
n n 1
n
2. Bivariate
n n
Sum of squares of xy: SS xy ( xi x )( y i y ) [to ease computation: SS xy x y i i nx y ]
i 1 i 1
n
Sample Covariance: 2
s xy =
SS xy
= (x
i 1
i x )( y i y )
n 1
n 1
2
s xy SS xy (x
i 1
i x )( y i y )
Sample Correlation: rˆ =
s x2 s 2y SS x SS y n
n
i 1
( xi x ) 2 (y
i 1
i y) 2
Hypothesis Testing
The Steps:
1. Define your hypotheses (null, alternative)
2. Specify your null distribution
3. Do an experiment
4. Calculate the p-value of what you observed
5. Reject or fail to reject (~accept) the null hypothesis
The Errors
Your Statistical True state of null hypothesis
Decision
H0 True H0 False
Power=1-
viii
Handy Reference II
sx
x t n 1, / 2 [if variance known or large sample size t df , / 2 Z / 2 ]
n
sd
d t n 1, / 2 [where di = the within-pair difference]
n
For a difference in means, 2 independent samples (σ2’s unknown but roughly equal):
s 2p s 2p SS x SS y (n x 1) s x2 ( n y 1) s 2y
( x y ) t n 2, / 2 s 2p = or
nx ny n2 n2
For a proportion:
( pˆ )(1 pˆ )
pˆ Z / 2
n
( pˆ 1 )(1 pˆ 1 ) ( pˆ 2 )(1 pˆ 2 )
( pˆ 1 pˆ 2 ) Z / 2
n1 n2
1 rˆ 2
rˆ t n 2, / 2 *
n2
ˆ t n 2, / 2 *
s2
[ ˆ SS xy (y
i 1
i yˆ i ) 2
]
SS x ;s2
SS x n2
ix
Handy Reference II
1 1 1 1 1 1 1 1
95% confidence limits: OR * exp 1.96 a
b
c
d
, OR * exp
1.96
a
b
c
d
x
Handy Reference II
( pˆ 1 pˆ 2 ) 0 n1 pˆ 1 n 2 pˆ 2
Z ;p
( p )(1 p ) ( p )(1 p ) n1 n 2
n1 n2
Test for: Ho: β = 0
ˆ 0
t n2
s2
SS x
xi
Handy Reference II
d
Z power n Z / 2
d
Smaller group sample size required to test Ho: μx – μy = 0 (two sample ttest):
(where r=ratio of larger group to smaller group)
(r 1) ( Z power Z / 2 )
2 2
n smaller
r ( x y ) 2
x y nr
Z power Z / 2
r 1
Smaller group sample size required to test Ho: p1 – p2 = 0 (difference in two proportions):
(where r=ratio of larger group to smaller group)
2
(r 1) p (1 p )( Z power Z / 2 )
n smaller
r ( p1 p 2 ) 2
p1 p 2 nr
Z power Z / 2
p (1 p ) r 1
r
Z power n 2 Z / 2
1 r2
xii
Handy Reference II
xiii
Handy Reference II
ANOVA TABLE
Source
Sourceofof Sum of squares MeanMean
Sum Sum
of of
variation
variation d.f.
d.f. Sum of squares Squares
Squares F-statistic
F-statistic p-value
p-value
kk
Between
Model k-1
k-1 SSM SSB SSM SSB Go toGo to
SSB nn (( yyii yy))22
SSM
(k(klevels
groups) i k 1k 1 k 1 k 1
of X) ii 11 Fk1,NkFk1,nkk
SSE SSW chart chart
N k nk k
Within
Error nk-k
N-k k n 2 SSW
y i ) 2 s s N knk k
N
2 SSE
SSE
j 1
2
SSW ( y ij ( yyˆ i ) ij
i 1 j 1
TSS=
Total variation N-1 TSS=
Total nk-1 n
variation SS y
SS y ( y y)
k
( y y )
i 1
n
i
ij
2
2
i 1 j 1
Coefficient of Determination:
variation explained by the predictor SSM 1 SSE
r 2 R 2
total variation in the outcome TSS TSS
xiv
Handy Reference II
T-distribution
x
Given n independent observations x i , t
s/ n
E(χn) = n
Var(χn) = 2n
The F- Distribution
n
Fn,m=
n
m
m
xv
Handy Reference II
Cross-sectional/case-control studies
Multivariate
(categorical and Continuous Multiple linear regression
continuous)
Multivariate (categorical
Binary Logistic regression
and continuous)
Multivariate (categorical
Time-to-event Cox-proportional hazards model
and continuous)
16
Handy Reference II
§
Fisher’s exact test is used when the expected cells contain less than 5 subjects.
17
Handy Reference II
Cross-sectional/case-control studies
Multivariate HRP259
(categorical and Continuous
Multiple linear regression
continuous)
Multivariate (categorical
Binary Logistic regression HRP261
and continuous)
18
Handy Reference II
§
Fisher’s exact test is used when the expected cells contain less than 5 subjects.
19
Handy Reference II
Cross-sectional/case-control studies
Multivariate
(categorical/ Binary Logistic regression PROC LOGISTIC
continuous)
Cohort Studies/Clinical Trials
Binary Binary Risk ratio PROC FREQ
20
Handy Reference II
*Non-parametric equivalents: PROC NPAR1WAY; §Fisher’s exact test: PROC FREQ, option: exact
21