.


:




:

































 

 

 

 





, ( stats, ):

ctest - (, "", , , - ...)

eda - ,

lqs -

modreg :

mva -

nls

splines -

stepfun -

ts -

: library() :

> library(eda)

3.1. 2 ( ).

c2 . , . , , 5-7 ( ). , .

:

ni - , ni - ( ).

:

- , - , .

, ( ), =2 . , R chisq.test().

chisq.test (x, y = NULL, p = rep(1/length (x), length (x)))

x .
y ; , x - .
p , x.

x ‑ , x ‑ , y , x ‑ . , - , p, , p . x - ( ), , . x y , ( ), .

() qchisq(p,df) c2- [2,.329].

, .

N<-100 #

x.norm<-rnorm(N,mean=2,sd=2.5) #

 

10% ( 10 )

> x.norm.q <- quantile(x.norm,probs=seq(0,1,0.1))

> round(x.norm.q,2)

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100%

-4.12 -1.51 -0.14 0.59 1.52 2.15 2.70 3.89 4.51 5.22 8.15

> summary(x.norm)

Min. 1st Qu. Median Mean 3rd Qu. Max.

-1.4490 0.6675 2.0330 2.0670 3.1050 6.5830

:

> k<-6 #

> x.q <- c(-10, -1.0, 0.5, 2.0, 3.5, 5.0,12.0)

> x.norm.hist<-hist(x.norm,breaks=x.q,plot=FALSE)

> x.norm.hist$counts

12 15 22 18 18 15

( )

> x.q[1]<-(-Inf);x.q[k+1]<-(+Inf)#

> x.norm.p.theor<-pnorm(x.q,mean=mean(x.norm),sd=sd(x.norm))

> x.norm.p.theor<-(x.norm.p.theor[2:(k+1)]-x.norm.p.theor[1:k])

> round(x.norm.p.theor,2)

0.12 0.15 0.21 0.22 0.16 0.14

> chisq.test(x.norm.hist$counts,p=x.norm.p.theor)

Chi-squared test for given probabilities

data: x.norm.hist$counts

X-squared = 0.9691, df = 5, p-value = 0.965

H0 , (p -value) 0.965 (96.5%), , 96.5%, . , .

. ( ̻ ƻ), ( 0, 1).

> x<-c(̔,Ɣ,Ɣ,̔,Ɣ,Ɣ,̔,Ɣ,̔,Ɣ,Ɣ,̔,̔)

> y<-c(0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0)

> tbl<-table(x,y)

> tbl

y

x 0 1

4 3

4 2

() x y:

> p.x<-c(sum(tbl[1,])/sum(tbl),sum(tbl[2,])/sum(tbl))

> p.y<-c(sum(tbl[,1])/sum(tbl),sum(tbl[,2])/sum(tbl))

, ( ),

> p.x<-apply(tbl,1,sum)/sum(tbl) # 1 -

> p.y<-apply(tbl,2,sum)/sum(tbl) # 2 -

( H0), :

>p.theor<-c(p.x[1]*p.y[1],p.x[2]*p.y[1], p.x[1]*p.y[2],p.x[2]*p.y[2])

, ( ),

> p.theor<- p.x %*% t(p.y)

> chisq.test(as.vector(t),p=p.theor)

Chi-squared test for given probabilities

 

data: as.vector(t)

X-squared = 0.1238, df = 3, p-value = 0.9888

p -value , . , tbl , 5 ( ), - , - .





:


: 2017-02-28; !; : 424 |


:

:

! . .
==> ...

1647 - | 1438 -


© 2015-2024 lektsii.org - -

: 0.013 .