Professional Documents
Culture Documents
Statistical Inference
Will review two common types of statistical inference
Hypothesis testing
Confidence intervals
Two-sample t Test
Interest in comparing mean responses to Trt 1 and Trt 2
H0 : 1 = 2 (Null Hypothesis)
<
H1 : 1 > 2 (Alternative Hypothesis)
6=
Compute t statistic
s
S12 S22
to = (y 1 y 2 )/ +
n1 n2
Is observed to unusual if H0 : 1 = 2 ?
Assumptions
1. Independent responses
2. Normally distributed observations
Assuming H0 : 1 = 2 , the sampling distribution of to
is approximately t distributed with k degrees of freedom.
Why is it approximate?
k typically estimated using a Satterthwaite approximation
Unusual quantified as the probability that a randomly
drawn t is more extreme then to (tail region)
Reject the null hypothesis when when this statistic (the
P -value) is small. Small typically based on choice of
significance level
Comparing Two Means 5
STAT 514
Example
(Samuels 7.36) In a study of lettuce growth, ten seedlings
were randomly allocated to be grown in either a standard
nutrient solution or in a solution containing extra
nitrogen. After 22 days, the plants were harvested and
weighed. The table below summarizes the results. Can we
conclude that extra nitrogen enhances growth?
Solution I
The test statistic is
4.17 3.62
to = q = 1.43
0.542 0.672
5
+ 5
Solution II
The pooled variance is
S2p = (4(.54)2 + 4(.67)2 )/8 = 0.37
i = 1, 2
yij = + i + ij
j = 1, 2, . . . n
i
where
+ i = mean for treatment i
ij are iid random errors . . . ij N (0, 2 )
Can express Null in terms of treatment effects 1 and 2
H 0 : 1 = 2 = 0
H1 : at least one i different than 0
proc ttest;
class solution;
var weight;
run;
Output
The TTEST Procedure
Variable: weight
Output
The Multtest Procedure
Model Information
Test for continuous variables Mean t-test
Degrees of Freedom Method Pooled
Tails for continuous tests Two-tailed
Strata weights None
P-value adjustment Permutation
Center continuous variables No
Number of resamples 1000
Seed 612
p-Values
Variable Contrast Raw Permutation
weight Extra vs Standard 0.1898 0.2390
P(Type I)
Null hypothesis
-4 -2 0 2 4
P(Type II)
Alternative hypothesis
-4 -2 0 2 4
Calculating Power
Assume is known (i.e., use Normal) and n1 = n2 = n
H0 : y 1 y 2 N (0, 2 2 /n)
H1 : y 1 y 2 N (, 2 2 /n)
Reject if (using the H0 sampling dist)
p p
y 1 y 2 > z/2 2 2 /n or y 1 y 2 < z/2 2 2 /n
p p
P(z > z/2 / 2 2 /n) + P(z < z/2 / 2 2 /n)
Example I
Suppose = .05, 2 =12.5, n = 25, and = 3.5
= .9382 + .0000
= .6001 + .0000
Power: P(reject | H1 )
y1 y2
p
p t2(n1) / 2 2 /n
2Sp2 /n
p
Noncentral parameter / 2 2 /n
proc power;
twosamplemeans alpha=.05 nulldiff=0 sides=2
meandiff=.25 npergroup=. stddev=.25
power=.90;
run;
proc power;
twosamplemeans alpha=.05 nulldiff=0 sides=2
meandiff=.25 stddev=.25 power=.
npergroup=2 to 25 by 1;
plot interpol=join yopts=(ref=0.80);
run;
Output
The POWER Procedure
Two-Sample t Test for Mean Difference
Actual N Per
Power Group
0.960 8
Output
The POWER Procedure
Two-Sample t Test for Mean Difference
Actual N Per
Power Group
0.912 23
Confidence Intervals
In addition to an estimate, want statement of precision
100(1-)% confidence intervals
q
tn1 +n2 2,/2 Sp 1/n1 + 1/n2
q
tdf,/2 S12 /n1 + S22 /n2
Using SAS
tpower.sas
proc power;
twosamplemeans ci=diff alpha=.05 halfwidth=.25 stddev=.25
npergroup=. probwidth=0.80;
run;
proc power;
twosamplemeans ci=diff alpha=.05 halfwidth=.25 stddev=.25
npergroup=. probwidth=0.50;
run;
Output
The POWER Procedure
Confidence Interval for Mean Difference
Fixed Scenario Elements
Distribution Normal
Method Exact
Alpha 0.05
CI Half-Width 0.25
Standard Deviation 0.25
Nominal Prob(Width) 0.8
Number of Sides 2
Prob Type Conditional
Actual
Prob N Per
(Width) Group
0.801 11
Output
The POWER Procedure
Confidence Interval for Mean Difference
Fixed Scenario Elements
Distribution Normal
Method Exact
Alpha 0.05
CI Half-Width 0.25
Standard Deviation 0.25
Nominal Prob(Width) 0.5
Number of Sides 2
Prob Type Conditional
Actual
Prob N Per
(Width) Group
0.533 9
Paired Comparison
Can often improve precision by pairing similar EUs
Removes variation between EUs
Twins for drug/health studies - subject variability
Same tissue specimen given both trts - specimen variability
Similar plots in a field - plot variability
Because of the pairing, we perform inference on the pair
differences di . This reduces the 2n observations into n
indep differences
1
di = y1i y2i Sd2 = (di d)2
P
n1
to = d/(Sd / n)
to tn1
Group EUs into blocks such that the EUs in a block are as
similar as possible. EUs across blocks can be very different.
Statistical Model
Pairing included as block effect (j ) in linear model
i = 1, 2
yij = + i + j + ij
j = 1, 2, . . . n
Example
Paired T-test/Randomization Paired Test
Solutions
t-test: d = {2, 1, 3, 2} d = 1.5 and sd = 0.866. The test
statistic is 1.732. With 3 df, the P-value is close to 0.18.
Using R
- Using simulation to approximate the P-value -
#### t-test ####
diff <- c(2,-1,3,2)
tdiff <- (mean(diff)/sqrt(var(diff)/4))
pvalue <- 2*pt(-abs(tdiff),3)
hist(tdist,nclass=530)
pvalue1 <- length(tdist[abs(tdist) >= abs(tdiff)])/10000
print(c(pvalue,pvalue1))
Histogram of tdist
1500
Frequency
1000
500
0
4 2 0 2 4
tdist
Using SAS
data camp;
input frog ctrl prog;
diff = prog - ctrl;
cards;
1 6 4
2 4 5
3 5 2
4 4 2
;
proc ttest;
paired ctrl*prog;
run;
Output
The TTEST Procedure