Skip to content

Commit f0aede0

Browse files
committed
Minor
1 parent 5be831d commit f0aede0

File tree

1 file changed

+0
-66
lines changed

1 file changed

+0
-66
lines changed

statistical-inference.org

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -278,69 +278,3 @@
278278
#+end_src
279279

280280

281-
** Introduction to the t distribution :ignore:
282-
283-
#+RESULTS: sampling4
284-
[[file:bsample4.png]]
285-
286-
#+NAME: sampling4
287-
#+BEGIN_SRC R :results output graphics :exports results :file bsample4.png :width 2500 :height 2000 :res 300
288-
library(data.table)
289-
library(ggplot2)
290-
options(scipen=9999)
291-
readRDS("plfsdata/plfsacjdata.rds")->worker
292-
worker$standardwage->worker$wage
293-
c(1:nrow(worker))->worker$SamplingFrameOrder
294-
worker[sex!=3,]->worker
295-
296-
worker->t9
297-
(t9$wage-mean(t9$wage))/sqrt(var(t9$wage))->t9$wage
298-
ggplot(t9,aes(wage))+geom_density(colour="black",size=1)->p
299-
p+scale_y_continuous(limits=c(0,0.75))->p
300-
p+scale_x_continuous(limits=c(-15,15)
301-
,breaks=c(-15,0,round(mean(worker$wage)),15))->p
302-
p+theme_bw()->p
303-
p
304-
305-
data.frame(sno=c(),meancol=c(),sterr=c())->t4
306-
samplesize=50
307-
for (i in c(1:20000)) {
308-
sample(1:nrow(worker),samplesize, replace=FALSE)->a1
309-
worker[a1,]->s1
310-
rbind(t4,data.frame(
311-
sno=i,
312-
meancol=mean(s1$wage),
313-
sterr=sqrt(var(s1$wage))/sqrt(samplesize)))->t4
314-
}
315-
316-
(t4$meancol-mean(t4$meancol))/t4$sterr->t4$teststat
317-
(t4$meancol-mean(t4$meancol))/sqrt(var(t4$meancol))->t4$teststat2
318-
data.frame(modelt=rt(20000,29))->m
319-
320-
var(t4$teststat)
321-
var(m$modelt)
322-
var(t4$teststat2)
323-
324-
ggplot()->p
325-
p+geom_density(data=t4,aes(teststat),colour="blue",size=1)-> p
326-
p+geom_density(data=m,aes(modelt),colour="darkolivegreen",size=1)->p
327-
p+geom_density(data=t4,aes(teststat2),colour="red",size=1)-> p
328-
p+annotate("text",x=3,y=0.4,
329-
label=paste("Var of statistic with unknown variance:",
330-
round(var(t4$teststat),2)),
331-
colour="blue")->p
332-
p+annotate("text",x=3,y=0.39,
333-
label=paste("Var of statistic with known variance:",
334-
round(var(t4$teststat2),2)),
335-
colour="red")->p
336-
p+annotate("text",x=3,y=0.38,
337-
label=paste("Var of t-distribution:",round(var(m$modelt),2)),
338-
colour="darkolivegreen")->p
339-
p
340-
341-
342-
#+end_src
343-
344-
345-
346-

0 commit comments

Comments
 (0)