day 2 done
46
statistics/assignments/day2.tex
Normal file
@ -0,0 +1,46 @@
|
||||
\documentclass[addpoints,10pt]{exam}
|
||||
\usepackage{url}
|
||||
\usepackage{color}
|
||||
\usepackage{hyperref}
|
||||
|
||||
\pagestyle{headandfoot}
|
||||
\runningheadrule
|
||||
\firstpageheadrule
|
||||
|
||||
\firstpageheader{Scientific Computing}{afternoon assignment day 02}{10/21/2014}
|
||||
%\runningheader{Homework 01}{Page \thepage\ of \numpages}{23. October 2014}
|
||||
\firstpagefooter{}{}{}
|
||||
\runningfooter{}{}{}
|
||||
\pointsinmargin
|
||||
\bracketedpoints
|
||||
|
||||
%\printanswers
|
||||
\shadedsolutions
|
||||
|
||||
|
||||
\begin{document}
|
||||
%%%%%%%%%%%%%%%%%%%%% Submission instructions %%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\sffamily
|
||||
%%%%%%%%%%%%%% Questions %%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
\begin{questions}
|
||||
\question Download example002 from yesterday (brain weights).
|
||||
\begin{parts}
|
||||
\part Simulate a null distribution via permutation.
|
||||
\part Determine whether you can reject ``means are equal'' on a
|
||||
5\% significance level using the simulated null distribution.
|
||||
\part Check whether the means are different with a two sample
|
||||
t-test in matlab ({\tt ttest2}).
|
||||
\part Plot the data appropriately and generate a single slide that
|
||||
contains the plot and short discussion of the test that respects
|
||||
the nature statistical checklist (ignore all question whether the
|
||||
assumptions of the test are satisfied).
|
||||
\part Upload the slide and the code to Ilias. Deadline is 19h00.
|
||||
\end{parts}
|
||||
\end{questions}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\end{document}
|
@ -1,3 +1,3 @@
|
||||
Brain Weight In 1888, P. Topinard published data on the brain weights
|
||||
Brain Weight: In 1888, P. Topinard published data on the brain weights
|
||||
of hundreds of French men and women. Brain weights are given in
|
||||
gram.
|
||||
|
BIN
statistics/figs/2012-10-29_14-55-39_181.jpg
Normal file
After Width: | Height: | Size: 546 KiB |
BIN
statistics/figs/2012-10-29_14-56-59_866.jpg
Normal file
After Width: | Height: | Size: 575 KiB |
BIN
statistics/figs/2012-10-29_14-58-18_054.jpg
Normal file
After Width: | Height: | Size: 385 KiB |
BIN
statistics/figs/2012-10-29_14-59-05_984.jpg
Normal file
After Width: | Height: | Size: 865 KiB |
BIN
statistics/figs/2012-10-29_15-04-38_517.jpg
Normal file
After Width: | Height: | Size: 425 KiB |
BIN
statistics/figs/2012-10-29_15-09-25_388.jpg
Normal file
After Width: | Height: | Size: 582 KiB |
BIN
statistics/figs/2012-10-29_16-26-05_771.jpg
Executable file
After Width: | Height: | Size: 724 KiB |
BIN
statistics/figs/2012-10-29_16-29-35_312.jpg
Executable file
After Width: | Height: | Size: 386 KiB |
BIN
statistics/figs/2012-10-29_16-41-39_523.jpg
Executable file
After Width: | Height: | Size: 461 KiB |
BIN
statistics/figs/StandardErrorOrStandardDeviation.pdf
Normal file
BIN
statistics/figs/bootstraptest.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
statistics/figs/bootstraptest2.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
BIN
statistics/figs/example01.png
Executable file
After Width: | Height: | Size: 21 KiB |
BIN
statistics/figs/example02.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
statistics/figs/example03.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
statistics/figs/example04.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
statistics/figs/hunger.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
statistics/figs/repetition0.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
statistics/figs/repetition1.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
statistics/figs/repetition2.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
statistics/figs/repetition3.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
statistics/figs/repetition4.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
statistics/figs/repetition5.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
statistics/figs/samplingDistribution.png
Executable file
After Width: | Height: | Size: 68 KiB |
BIN
statistics/figs/samplingDistributionMedian00.pdf
Normal file
BIN
statistics/figs/samplingDistributionMedian01.pdf
Normal file
BIN
statistics/figs/statistic1.png
Executable file
After Width: | Height: | Size: 116 KiB |
BIN
statistics/figs/statistic2.png
Executable file
After Width: | Height: | Size: 125 KiB |
BIN
statistics/figs/statistic3.png
Executable file
After Width: | Height: | Size: 40 KiB |
BIN
statistics/figs/statistic4.png
Executable file
After Width: | Height: | Size: 56 KiB |
@ -22,14 +22,19 @@
|
||||
% \useoutertheme{miniframes}
|
||||
}
|
||||
|
||||
\AtBeginSection[]
|
||||
\AtBeginSubsection[]
|
||||
{
|
||||
\begin{frame}<beamer>
|
||||
\begin{center}
|
||||
\Huge \insertsectionhead
|
||||
\end{center}
|
||||
\tableofcontents[
|
||||
currentsubsection,
|
||||
hideothersubsections,
|
||||
sectionstyle=show/hide,
|
||||
subsectionstyle=show/shaded,
|
||||
]
|
||||
% \frametitle{\insertsectionhead}
|
||||
% \tableofcontents[currentsection,hideothersubsections]
|
||||
\end{frame}
|
||||
}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
|
||||
@ -84,25 +89,7 @@ Bernstein Center T\"ubingen}
|
||||
|
||||
\end{frame}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{plan}
|
||||
\setcounter{tocdepth}{1}
|
||||
\tableofcontents
|
||||
|
||||
\end{frame}
|
||||
\begin{frame}
|
||||
\frametitle{information}
|
||||
\begin{itemize}
|
||||
\item Samuels, M. L., Wittmer, J. A., \& Schaffner,
|
||||
A. A. (2010). Statistics for the Life Sciences (4th ed.,
|
||||
p. 668). Prentice Hall.
|
||||
\item Zar, J. H. (1999). Biostatistical Analysis. (D. Lynch,
|
||||
Ed.)Prentice Hall New Jersey (4th ed., Vol. 4th, p. 663). Prentice
|
||||
Hall. doi:10.1037/0012764
|
||||
\item \url{http://stats.stackexchange.com}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% errorbars (error bar paper)
|
||||
% confidence intervals (sources of error)
|
||||
@ -170,8 +157,7 @@ Bernstein Center T\"ubingen}
|
||||
\end{frame}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\section[descriptive statistics, errorbars, and plots]{Day 1 --
|
||||
descriptive statistics and plots}
|
||||
\section{Day 1 -- descriptive statistics and plots}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{types of data}
|
||||
@ -523,7 +509,7 @@ correlation coefficient does not have that property.
|
||||
\end{frame}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\subsection{nominal scale}
|
||||
\subsection{plotting data}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%-------------------------------------------------------------
|
||||
|
13
statistics/matlab/bootstrap_mean.m
Normal file
@ -0,0 +1,13 @@
|
||||
load thymusglandweights.dat
|
||||
x = thymusglandweights(1:50);
|
||||
|
||||
m = 500;
|
||||
n = length(x);
|
||||
|
||||
mu = zeros(m,1);
|
||||
for i = 1:m
|
||||
mu(i) = mean(x(randi(n,n,1)));
|
||||
end
|
||||
fprintf("bootstrap standard error: %.4f\n", std(mu));
|
||||
fprintf("standard error: %.4f\n", std(x)/sqrt(n));
|
||||
|
19
statistics/matlab/ci_mean.m
Normal file
@ -0,0 +1,19 @@
|
||||
load thymusglandweights.dat
|
||||
|
||||
n = 80;
|
||||
x = thymusglandweights(1:n);
|
||||
|
||||
m = 5000;
|
||||
me = zeros(m,1);
|
||||
for i = 1:m
|
||||
me(i) = median(x(randi(n,n,1)));
|
||||
end
|
||||
|
||||
t025 = tinv(0.025, n-1);
|
||||
t975 = tinv(0.975, n-1);
|
||||
|
||||
se = std(x)/sqrt(n);
|
||||
|
||||
fprintf('bootstrap quantiles: %.4f, %.4f \n', quantile(me,0.025), quantile(me,0.975));
|
||||
fprintf('analytical quantile: %.4f, %.4f \n', mean(x)+t025*se, mean(x)+t975*se);
|
||||
|
17
statistics/matlab/ci_media.m
Normal file
@ -0,0 +1,17 @@
|
||||
load thymusglandweights.dat
|
||||
x = thymusglandweights(1:50);
|
||||
|
||||
m = 500;
|
||||
n = length(x);
|
||||
x = sort(x);
|
||||
me = zeros(m,1);
|
||||
for i = 1:m
|
||||
me(i) = median(x(randi(n,n,1)));
|
||||
end
|
||||
|
||||
a1 = binoinv(0.025,n,.5)-1;
|
||||
a2 = binoinv(1-0.025,n,.5);
|
||||
|
||||
fprintf('bootstrap quantiles: %.4f, %.4f \n', quantile(me,0.025), quantile(me,1-0.025));
|
||||
fprintf('analytical quantile: %.4f, %.4f \n', x(a1),x(a2));
|
||||
|
38
statistics/matlab/tests.m
Normal file
@ -0,0 +1,38 @@
|
||||
close all
|
||||
clear all
|
||||
load thymusglandweights.dat
|
||||
|
||||
literature_mean = 34.3;
|
||||
|
||||
x = thymusglandweights;
|
||||
n = length(x);
|
||||
y = x - mean(x) + literature_mean;
|
||||
|
||||
m = 2000;
|
||||
me = zeros(m,1);
|
||||
for i = 1:m
|
||||
me(i) = median(y(randi(n,n,1)));
|
||||
end
|
||||
|
||||
hist(me, 50);
|
||||
hold on
|
||||
mu = mean(x);
|
||||
plot([mu,mu],[0,200],'--r','LineWidth',3);
|
||||
xlabel('thymus gland weights [g]');
|
||||
ylabel('frequency');
|
||||
title('bootstrapped null distribution');
|
||||
hold off
|
||||
|
||||
% 5% significance boundaries
|
||||
low = quantile(me,0.025);
|
||||
high = quantile(me,0.975);
|
||||
disp(['the 5% boundaries are: ', num2str(low), ' ', num2str(high)]);
|
||||
|
||||
hold on
|
||||
plot([low,low],[0,200],'--g','LineWidth',3);
|
||||
plot([high,high],[0,200],'--g','LineWidth',3);
|
||||
hold off
|
||||
|
||||
pval = mean(abs(me-literature_mean) > abs(mu - literature_mean))
|
||||
|
||||
legend('Null distribution','measured mean','5% significance boundaries')
|