Skip to content

Instantly share code, notes, and snippets.

@MatteoRagni
Last active November 15, 2016 13:53
Show Gist options
  • Save MatteoRagni/c83056286fa2b72d67da962535efd1b4 to your computer and use it in GitHub Desktop.
Save MatteoRagni/c83056286fa2b72d67da962535efd1b4 to your computer and use it in GitHub Desktop.
Ex. for 15 Nov. Lecture
19.8
15.4
11.4
19.5
10.1
18.5
14.1
8.8
14.9
7.9
17.6
13.6
7.5
12.7
16.7
11.9
15.4
11.9
15.8
11.4
15.4
11.4
# ANOVA
# Clean up the workspace
rm(list=ls())
# Import the data
# We have life length for rats, subject to different class of Poison:
# I, II, III
# and Treatment
# A, B, C, D
# The final argument of our table is tha length of the life. We can
# directly import data from the internet:
df <- read.table("https://goo.gl/W9CXQV", header=T)
# Understand the problem with boxplots and interaction plot
boxplot(Life ~ Poison, d=df)
boxplot(Life ~ Treat, d=df)
# In this case we are not sure about residual analysis
# thus it is better to perform ana analysis of residuals
interaction.plot(df$Poison, df$Treat, df$Life)
# Let's make a first model for this process.
# We consider that the the Life process as a dependecies
# from the Treat, the Poison and the combination of Treat and Poison
# Converted in formula it means
df.formula <- Life ~ Treat + Poison + Treat:Poison
# And we can create a model
df.lm <- lm(df.formula, data=df)
# And we can make an analysis of residuals (qualitative) to understand
# if we are making a good assumption of the model
qqnorm(rstandard(df.lm))
qqline(rstandard(df.lm))
# residual pplot
plot(rstandard(df.lm))
# Let's try to simplify this model
df.formula.2 <- Life ~ Treat + Poison
# And we can create a model
df.lm.2 <- lm(df.formula.2, data=df)
# And we can make an analysis of residuals (qualitative) to understand
# if we are making a good assumption of the model
qqnorm(rstandard(df.lm.2))
qqline(rstandard(df.lm.2))
# residual pplot
plot(rstandard(df.lm.2))
# Let's try to improve the model
boxplot(1/Life ~ Poison, d=df)
boxplot(1/Life ~ Treat, d=df)
df.formula.3 <- 1/Life ~ Treat + Poison
# And we can create a model
df.lm.3 <- lm(df.formula.3, data=df)
# And we can make an analysis of residuals (qualitative) to understand
# if we are making a good assumption of the model
qqnorm(rstandard(df.lm.3))
qqline(rstandard(df.lm.3))
# residual pplot
plot(rstandard(df.lm.3))
# Let's try with anova analisys
anova(df.lm.3)
anova(df.lm)
60
53
46
44
47
45
53
43
50
57
48
44
47
53
44
51
55
47
55
46
61
51
57
51
58
51
41
47
48
43
47
53
47
48
52
49
43
47
55
59
50
46
41
58
43
55
55
60
48
48
45
44
44
47
56
48
57
53
44
42
48
59
45
61
43
50
49
47
51
47
64
48
54
47
47
49
49
63
47
58
57
61
48
46
48
47
46
46
54
47
58
48
45
51
47
46
42
51
44
51
44
46
48
55
47
45
57
50
44
52
51
56
48
50
54
47
47
62
45
47
49
47
48
45
57
47
46
44
63
47
47
47
47
46
48
46
43
52
56
54
49
48
45
44
58
45
49
45
47
51
53
48
52
45
43
44
44
42
43
57
49
44
46
46
51
45
49
45
42
53
45
47
50
46
50
47
46
47
47
45
46
50
48
45
58
44
64
46
40
47
55
53
45
53
44
52
50
51
41
51
49
56
52
46
40
48
49
48
47
47
59
54
48
60
47
47
48
48
50
44
58
43
52
46
59
52
45
49
49
64
52
46
59
49
49
47
49
45
59
50
60
45
45
45
48
51
49
46
47
58
62
48
63
56
43
46
48
47
53
44
48
47
46
42
58
47
40
53
44
47
49
47
46
57
51
45
55
45
57
47
47
45
50
53
48
53
47
50
60
64
54
48
50
57
45
48
60
50
54
47
46
44
61
43
47
46
44
57
47
60
48
45
56
47
53
65
54
47
44
45
49
49
65
56
47
47
46
60
45
42
47
46
49
42
53
51
47
55
47
60
50
48
45
44
49
44
51
46
52
52
58
52
48
50
51
61
58
45
61
46
46
53
46
50
49
44
52
49
48
44
42
44
48
46
52
47
47
56
50
47
56
50
62
48
46
57
62
62
50
53
45
55
45
55
44
59
49
45
50
42
59
50
47
44
48
53
50
56
57
60
48
51
63
52
44
47
47
46
57
50
51
47
46
46
46
47
44
47
63
52
45
50
45
44
59
57
50
44
40
45
48
45
47
45
51
47
47
48
44
51
48
43
56
44
46
48
48
55
45
61
50
48
47
46
45
42
55
54
47
47
56
53
45
47
48
47
65
43
45
48
44
54
47
52
42
45
46
52
48
58
48
50
47
46
44
56
50
51
59
49
46
51
61
44
45
50
44
60
47
56
46
50
44
45
43
50
45
44
44
44
58
51
52
47
45
41
48
44
45
46
52
47
47
48
45
51
48
45
48
62
54
41
49
56
49
46
50
47
45
48
48
59
50
49
45
45
47
58
46
49
46
48
56
47
47
47
49
47
46
46
45
56
60
43
44
49
43
49
47
47
52
47
47
49
43
64
47
47
44
58
53
47
45
61
45
44
47
46
45
47
52
46
61
47
57
59
48
48
63
46
57
57
47
55
45
49
60
46
52
47
45
46
50
48
45
46
48
52
54
45
49
43
59
45
47
41
47
54
46
46
50
46
48
44
47
42
55
58
46
61
47
47
45
48
47
53
51
55
48
52
48
45
52
57
60
45
43
45
45
44
45
55
43
51
52
53
47
51
50
52
58
47
48
46
44
47
54
49
51
50
46
52
49
47
46
47
46
46
56
46
56
48
45
49
49
52
44
48
55
48
61
47
46
45
45
46
44
48
51
47
48
42
50
45
57
50
46
51
51
45
47
50
48
45
45
45
46
46
46
46
47
61
48
51
51
47
51
46
57
47
42
47
50
50
48
60
61
45
44
45
44
48
47
58
52
42
50
60
50
46
47
46
50
48
51
60
56
54
52
51
52
46
44
51
47
47
47
54
49
43
53
51
54
50
45
53
46
45
50
50
44
58
40
53
50
57
46
59
47
49
47
42
63
44
47
43
42
47
49
61
50
54
60
46
49
45
49
51
47
56
52
46
47
50
47
46
52
46
47
46
47
58
48
60
46
46
52
52
44
47
54
46
55
52
54
59
49
47
53
64
45
60
57
47
50
52
55
45
47
43
45
44
45
55
57
40
62
52
47
44
49
51
49
45
54
60
43
50
42
59
42
48
46
53
47
42
54
49
46
57
47
45
49
54
47
45
45
45
44
46
46
47
58
49
55
50
49
48
52
63
47
47
51
48
45
58
44
56
52
60
47
46
44
44
48
47
49
48
61
56
46
63
44
44
45
52
46
46
49
56
46
51
45
47
42
57
56
46
57
51
49
46
42
44
48
50
43
43
47
51
53
46
65
47
62
57
46
53
56
57
48
50
51
62
58
49
60
41
42
46
48
62
53
51
50
49
46
53
46
57
49
49
59
43
65
45
50
46
47
50
49
60
45
52
46
65
44
48
53
59
50
48
44
55
46
47
45
53
47
43
47
48
47
62
53
48
61
45
55
51
45
59
50
48
46
47
47
52
60
51
53
45
49
61
52
47
53
61
43
63
52
46
51
50
53
52
52
45
44
49
42
49
45
44
45
46
62
47
44
54
51
44
47
51
59
49
46
46
48
47
51
55
43
47
62
43
45
45
55
54
48
47
61
65
46
45
45
53
57
53
46
47
54
62
44
56
44
56
47
47
60
56
46
45
44
56
47
53
43
55
50
58
44
53
48
46
45
47
48
44
45
54
61
62
48
48
48
60
56
49
56
45
44
46
46
58
54
49
55
43
51
46
46
45
45
45
49
44
49
50
45
46
43
65
48
60
52
43
51
50
49
48
50
53
54
49
44
59
43
50
50
43
48
44
48
45
45
57
54
44
65
54
54
46
44
43
52
46
44
51
61
44
52
43
57
46
52
49
45
48
51
56
63
58
43
51
63
49
57
50
45
49
46
48
41
47
46
44
46
47
44
47
53
50
41
56
54
45
48
48
48
44
47
43
54
52
59
58
47
43
43
46
47
43
47
57
62
53
47
48
53
55
58
43
47
46
51
45
47
51
54
42
41
49
65
55
53
47
50
53
44
51
43
45
53
54
46
62
45
47
50
50
51
46
57
45
45
46
54
49
47
58
54
49
40
50
48
47
49
47
49
47
57
48
45
47
49
44
53
62
45
60
56
43
49
51
56
47
50
61
45
44
47
53
64
55
47
54
46
48
43
46
49
50
51
47
47
56
46
60
55
47
56
54
52
54
46
47
49
49
56
57
55
53
54
56
52
50
45
49
58
60
59
42
42
48
53
48
46
53
47
46
50
44
50
44
50
52
43
45
46
47
56
51
51
51
48
51
52
47
61
47
44
63
55
46
47
56
46
56
49
53
45
48
60
50
46
43
48
59
55
52
44
51
57
63
64
47
49
41
48
45
49
46
47
50
46
52
47
47
50
45
45
48
46
47
53
47
50
46
46
49
45
49
46
56
47
47
50
44
57
55
47
50
62
52
54
44
41
44
47
52
44
57
47
49
53
44
54
47
45
43
53
53
47
45
45
52
55
59
58
48
57
46
59
53
64
58
58
47
43
53
53
48
62
52
44
45
50
59
49
61
60
44
43
54
48
45
51
53
53
47
46
50
43
48
65
48
50
57
47
48
48
48
48
47
44
60
43
47
54
46
46
55
48
48
46
51
51
47
51
46
49
54
45
64
47
60
44
47
51
48
49
47
56
48
47
60
47
48
46
57
48
46
49
49
51
49
47
55
50
50
62
49
47
50
49
60
48
56
46
48
53
53
44
50
50
55
49
40
50
55
48
65
45
43
58
44
41
52
55
41
45
45
60
61
43
44
54
44
52
49
48
54
51
53
44
48
51
51
48
59
53
60
46
41
62
47
43
60
47
45
46
59
48
44
52
43
57
46
56
46
60
45
49
43
47
46
50
51
52
41
48
51
45
45
46
48
64
54
50
56
55
49
47
47
50
45
54
63
59
46
48
42
50
48
47
48
58
44
49
45
49
44
46
43
52
47
41
48
46
47
46
45
47
47
49
62
53
61
49
47
46
48
46
59
54
54
46
64
59
48
53
48
45
60
45
43
50
45
56
46
55
50
43
45
44
47
47
48
44
51
48
43
54
59
46
48
47
47
54
47
49
44
45
58
48
47
45
54
51
47
47
48
50
42
50
50
48
54
48
56
47
55
53
53
51
51
51
47
40
46
57
56
54
54
47
50
46
51
52
47
45
49
46
43
40
47
48
49
50
42
42
45
48
52
47
48
47
50
47
46
46
53
43
51
50
47
50
58
46
49
43
47
57
47
48
46
49
47
54
65
52
45
59
47
46
45
55
50
50
52
45
62
50
54
46
43
64
49
57
60
46
46
43
45
50
51
49
53
45
58
54
50
49
59
42
48
47
55
47
49
45
44
60
56
51
46
45
58
46
55
54
43
50
53
49
46
44
52
55
46
48
54
46
55
49
46
45
47
47
58
54
46
49
63
50
65
57
57
54
48
50
57
49
48
49
51
59
61
57
55
45
44
49
55
40
55
48
43
55
52
44
50
58
47
45
56
50
45
51
56
50
51
45
61
49
47
48
62
53
48
44
56
44
52
43
46
57
48
50
47
54
47
46
44
55
55
47
53
50
48
52
49
49
62
58
47
46
48
47
47
60
46
45
56
50
54
47
47
41
53
44
43
61
56
43
43
54
55
54
43
49
45
45
58
48
50
48
52
42
50
49
47
61
51
59
44
47
49
44
50
52
45
46
62
58
51
52
48
43
54
46
49
49
43
44
51
47
46
57
57
47
62
49
51
46
51
47
42
46
46
50
43
60
51
48
46
45
63
46
54
46
47
48
46
44
47
41
48
43
50
48
45
52
46
44
63
44
48
45
56
58
41
48
48
47
59
59
44
58
51
46
47
56
45
63
46
58
54
42
63
59
52
46
61
45
47
59
47
51
54
47
55
53
64
46
59
55
50
47
44
53
45
47
48
46
46
47
44
45
55
49
46
60
51
45
61
46
51
41
49
50
49
46
46
47
51
57
45
59
47
49
49
46
53
44
44
41
50
55
47
44
61
62
45
47
60
59
46
47
48
58
63
48
44
46
48
46
44
48
54
53
52
48
50
44
55
59
46
47
51
49
45
46
61
65
47
45
56
51
60
46
57
51
50
56
46
54
47
47
53
45
45
43
43
46
54
43
45
47
46
52
46
59
47
52
52
52
54
45
40
59
49
53
61
43
56
45
44
63
44
57
44
51
47
43
47
46
41
45
57
54
47
47
48
47
60
64
55
53
44
51
43
49
53
45
48
46
45
47
56
48
49
49
59
55
47
46
54
50
54
48
45
45
45
45
51
50
48
44
45
42
52
45
46
47
42
62
56
44
60
47
62
44
45
46
55
46
47
61
44
45
44
60
46
50
48
56
45
49
49
47
47
47
55
55
45
47
46
51
47
48
48
54
45
55
59
48
47
52
46
62
49
46
52
44
45
58
46
51
53
42
47
56
49
46
49
44
44
63
53
44
46
43
49
47
55
41
52
46
49
47
62
52
47
50
46
45
45
46
44
42
62
49
54
42
47
46
43
45
47
50
49
51
51
42
45
45
47
44
44
51
50
51
47
52
57
47
54
51
51
48
59
60
49
60
47
58
50
50
48
49
45
48
56
59
55
51
44
56
47
54
59
43
46
44
49
50
44
47
62
51
57
60
49
55
62
50
45
51
60
63
52
46
47
47
48
53
57
48
45
48
54
43
47
47
55
49
46
48
46
47
45
47
40
51
48
56
48
45
49
50
43
53
45
54
51
51
51
48
56
46
42
48
47
44
47
45
52
47
49
42
46
49
48
46
45
49
58
57
55
51
51
52
48
44
55
47
50
61
43
55
46
46
46
49
61
60
52
45
45
47
56
42
51
53
45
49
50
46
62
50
44
57
60
42
46
42
52
50
63
44
61
58
54
44
59
50
47
47
46
48
44
46
47
50
46
43
55
62
56
45
47
43
51
59
43
50
55
64
51
46
61
46
44
47
47
46
48
48
48
49
52
49
47
47
51
61
56
61
46
46
49
47
47
55
54
50
44
45
44
59
55
48
42
62
48
52
57
62
61
44
46
47
44
47
48
48
45
58
50
61
46
59
46
61
51
46
56
44
46
47
48
62
52
47
43
53
51
57
45
49
44
43
65
50
49
51
43
63
57
57
43
48
57
54
63
53
43
54
54
46
46
44
60
42
51
45
44
55
45
51
55
47
46
58
47
52
42
45
46
48
43
48
51
44
48
44
47
55
50
48
44
50
46
43
51
49
47
58
48
55
48
48
47
59
49
45
48
47
48
49
46
40
63
50
49
47
53
45
54
62
46
48
52
43
64
44
63
45
47
45
58
47
62
48
44
58
43
45
44
55
50
46
59
53
44
45
50
59
53
58
47
48
61
54
52
42
55
47
55
56
61
44
46
44
48
46
51
47
45
58
46
49
43
45
47
47
51
46
53
45
48
47
49
46
50
42
46
50
55
48
50
45
45
57
61
44
47
50
47
45
48
46
51
49
45
51
47
43
52
54
48
49
49
47
44
53
48
42
47
42
42
49
43
50
46
43
52
46
63
58
47
53
42
58
57
55
45
45
43
49
45
58
47
46
44
54
40
47
46
46
46
51
51
56
49
44
57
61
51
56
56
52
61
58
47
45
44
58
46
47
51
46
42
48
46
55
60
55
49
46
56
51
48
49
50
44
48
52
49
56
50
53
42
49
49
48
48
59
44
44
45
44
44
44
51
48
54
47
50
48
55
57
47
48
41
53
45
47
46
47
53
50
47
57
47
48
45
47
53
49
49
49
48
48
48
51
48
45
48
46
45
48
44
44
52
47
56
46
46
47
49
48
45
53
59
58
48
52
56
45
50
47
51
46
52
50
64
59
45
43
48
64
43
45
47
43
51
45
42
# GOODNESS OF FIT
# This example represent bservations of vehicle per minute
# in a street. Evaluate if this pcess can be modeled with
# a Poisson distribution.
rm(list=ls())
# Data are available at https://goo.gl/v91n7L
df <- read.table("https://goo.gl/v91n7L")$V1
df.n <- length(df)
df.m <- mean(df)
df.s <- sd(df)
df.l <- 46
# Create the bins
# We put freq=F to get a density distribution instead of a pure
# frequency distribution
(df.h <- hist(df, freq=F))
# Create the expected distribution
df.b <- df.h$breaks # x-values in hist plot
#df.b[1] = -Inf
df.b[length(df.b)] = 0
# Evaluate the expected Poisson distribution
ei <- diff(ppois(df.b, df.l)) * df.n
plot(ei)
points(df.h$counts, col="red")
chi <- sum((df.h$counts - ei) ** 2 / ei)
# Check against pchisq
pchisq(chi, df=length(df.h$counts) - 1 - 1)
# CONFIDENCE INTERVAL
rm(list=ls())
# An article describes t results of tensile adhesion tests on
# n = 22 U-700 Alloy specimens. The failure load is described in file
# at: https://goo.gl/6XWdME
df <- read.table(file="https://goo.gl/6XWdME")$V1
(m <- mean(df))
(s <- sd(df))
(n <- length(df))
# Let's check our model for a distribution
boxplot(df, ylab="Load at Failure")
qqnorm(df)
qqline(df)
# We can assume that the population is normally distributed
# and we want to understand which is the confidence interval
# on the mean of our distribution
# The confidence interval is the confidence interval on the mean
# with variance unknown for the t-distribution
conf <- 0.95
t <- qt((1 - conf)/2, n - 1, low=F)
(c(
m - t * s / sqrt(n),
m + t * s / sqrt(n)
))
Poison Treat Life
I A 0.31
I B 0.82
I C 0.43
I D 0.45
I A 0.45
I B 1.1
I C 0.45
I D 0.71
I A 0.46
I B 0.88
I C 0.63
I D 0.66
I A 0.43
I B 0.72
I C 0.76
I D 0.62
II A 0.36
II B 0.92
II C 0.44
II D 0.56
II A 0.29
II B 0.61
II C 0.35
II D 1.02
II A 0.4
II B 0.49
II C 0.31
II D 0.71
II A 0.23
II B 1.24
II C 0.4
II D 0.38
III A 0.22
III B 0.3
III C 0.23
III D 0.3
III A 0.21
III B 0.37
III C 0.25
III D 0.36
III A 0.18
III B 0.38
III C 0.24
III D 0.31
III A 0.23
III B 0.29
III C 0.22
III D 0.33
# T-Test example - 15 Nov 2016
# Clear workspace
rm(list=ls())
# PART 1
# DATA GENERATION
# Define two means µ[a] and µ[b], suche that µ[a] > µ[b]
mu.a <- 0.1
mu.b <- -0.1
# Define two standard deviation σ[a] and σ[b], such that σ[a]!= σ[b]
sigma.a <- 0.1
sigma.b <- 0.15
# Create 4 groups of samples such that:
# * N(µa, σa) with 12 samples -> s1
# * N(µa, σb) with 15 samples -> s2
# * N(µb, σa) with 13 samples -> s3
# * N(µb, σb) with 10 samples -> s4
n.1 <- 12
s.1 <- rnorm(n.1, mu.a, sigma.a)
n.2 <- 15
s.2 <- rnorm(n.2, mu.a, sigma.b)
n.3 <- 13
s.3 <- rnorm(n.3, mu.b, sigma.a)
n.4 <- 10
s.4 <- rnorm(n.4, mu.b, sigma.b)
# PART 2
# T-TEST ONE SAMPLE, TWO SIDES
# t.test if s4 belongs to a distribution with mean µ[b]
# H0: µ1 = µ2
# H1: µ1 != µ2
# In this case there is no need to evaluate the pooled variance,
# but we can directly evaluate the t0
test.1.t0 <- (mean(s.4) - mu.b)/(sd(s.4) / sqrt(n.4))
# And we get a p-value from a two sided t-distribution
( pt(abs(test.1.t0), n.4 - 1, lower.tail=FALSE) * 2 )
# Lets test it versus built in function
( test.1.tt <- t.test(s.4, alternative="two.sided", mu=mu.b, paired=F) )
# PART 3
# INTERLUDE: Functions
# Write that evaluates t-test for sigma equal and sigma different
my.t.test <- function(s1, s2, sigma.equal=TRUE) {
n1 <- length(s1)
n2 <- length(s2)
t0 <- 0
if (sigma.equal) {
n <- n1 + n2 - 2
sp <- ((n1-1)*var(s1) + (n2-1)*var(s2)) / n
return((mean(s1)-mean(s2))/(sqrt(sp*(1/n1+1/n2))))
} else {
return((mean(s1) - mean(s2))/sqrt(var(s1)/n1 + var(s2)/n2))
}
}
# PART 4
# T-TEST TWO SAMPLES, TWO SIDES
# t.test between s1 and s2 with
# H0: µ1 = µ2
# H1: µ1 != µ2
test.2.t0 <- my.t.test(s.1, s.2)
( pt(abs(test.2.t0), (n.1 + n.2 - 2), lower.tail=FALSE) * 2 )
( test.2.tt <- t.test(s.1, y=s.2, alternative="two.sided", var.equal=T) )
# PART 5
# T-TEST TWO SAMPLES, ONE SIDE
# t.test between s1 and s3 with
# H0: µ1 = µ2
# H1: µ1 < µ2
test.3.t0 <- my.t.test(s.1, s.3)
( pt(test.3.t0, n.1 + n.3 - 2, low=T) )
( test.3.tt <- t.test(s.1, y=s.3, alt="less", var.equal=T))
# PART 6
# T-TEST TWO SAMPLES, ONE SIDE
# t.test between s2 and s4 with
# H0: µ1 = µ2
# H1: µ1 > µ2
test.4.t0 <- my.t.test(s.2, s.4)
( pt(test.4.t0, n.2 + n.4 - 2, low=F) )
( test.4.tt <- t.test(s.2, y=s.4, paired=F, alt="greater", var.equal=T))
# HOMEWORK
# Imagine that you now know a priori:
#
# * s.1 deviation differs from s.2 deviation
# * s.1 deviation is the same of s.3 deviation
# * s.2 deviation is the same of s.4 deviation
#
# Modify the script to make a "good" comparison, using
# var.equal=FALSE where it is necessary.
# Write a function to evaluate the degree of freedom
# that is necessary in that case.
# hint: Welch-Satterthwaite equation
# PART 7
# Evaluate the confidence interval for each of the previous
# two-samples comparison
pool.deviation <- function(s1, s2) {
n1 <- length(s1)
n2 <- length(s2)
n <- n1 + n2 - 2
sp <- (n1-1)*var(s1) + (n2-1)*var(s2)
return(sqrt(sp/n))
}
scaling.coefficient <- function(s1, s2, var.equal=T) {
n1 <- length(s1)
n2 <- length(s2)
if(var.equal) {
sp <- pool.deviation(s1, s2)
sn <- sqrt((1/n1) + (1/n2))
return(sp*sn)
} else {
return(sqrt((var(s1)/n1) + (var(s2)/n2)))
}
}
confidence.interval <- function(s1, s2, conf=0.95, var.equal=T) {
dmu <- mean(s1) - mean(s2)
n <- 0
if (var.equal) {
n <- length(s1) + length(s2) - 2
} else {
# To be completed with a paricular equation...
# this means... HOMEWORK!! yup!
n <- 0 # ?
}
cf <- scaling.coefficient(s1, s2, var.equal=var.equal)
tp <- qt((1 - conf)/2, n, low=F)
i_min <- dmu - tp * cf
i_max <- dmu + tp * cf
return(c(i_min, i_max))
}
( test.2.tt$conf.int )
( confidence.interval(s.1, s.2) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment