#(1) library(quantreg) Y=c(2,0,-5,5,1) # ind=seq(0,1, by=0.01) #graf vykreslime na mrizce od 0 do 1 quantile(Y,ind,type=1) par(mfrow=c(3,3)) plot(quantile(Y,ind,type=1)~ind,type='l') plot(quantile(Y,ind,type=2)~ind,type='l') plot(quantile(Y,ind,type=3)~ind,type='l') plot(quantile(Y,ind,type=4)~ind,type='l') plot(quantile(Y,ind,type=5)~ind,type='l') plot(quantile(Y,ind,type=6)~ind,type='l') plot(quantile(Y,ind,type=7)~ind,type='l') plot(quantile(Y,ind,type=8)~ind,type='l') plot(quantile(Y,ind,type=9)~ind,type='l') rq(Y~1,tau=0) rq(Y~1,tau=0.01) rq(Y~1,tau=0.25) rq(Y~1,tau=0.6) rq(Y~1,tau=0.8) rq(Y~1,tau=1) rq(Y~1,tau=ind) rq(Y~1,tau=-1) plot(rq(Y~1,tau=-1)) #(a) R=rank(Y) R #(b) P=rq(Y~1, tau=-1)$sol D=rq(Y~1, tau=-1)$dsol #y-ove souradnice zlomu ind=P[1,] #x-ove souradnice zlomu par(mfrow=c(2,3)) for (i in 1:5){ plot(D[i,]~ind,type="l", main=c("R=",R[i]),xlab=expression(alpha),ylab="a_i") } #(2) library(HSAUR) data=heptathlon attach(data) M=rq(score~hurdles+highjump+longjump+javelin,data=heptathlon, tau=-1) rq(score~hurdles+highjump+longjump+javelin,data=heptathlon, tau=0.49) rq(score~hurdles+highjump+longjump+javelin,data=heptathlon, tau=0.51) #(a) plot(M) #regresni kvantilovy proces P=M$sol #y-ove souradnice bodu zlomu ind=P[1,] #x-ove souradnice bodu zlomu par(mfrow=c(3,2)) #vlastni konstrukce tehoz for (i in 4:8){ plot(P[i,]~ind) } #(b) #nejprve definujeme model s 9 pozorovanimi M2=rq(score~hurdles+highjump+longjump+javelin,data=heptathlon[1:9,], tau=-1) P2=M2$sol ind2=P2[1,] #x-ove souradnice bodu zlomu D2=M2$dsol #y-ove souradnice bodu zlomu par(mfrow=c(3,3)) for (i in 1:9){ plot(D2[i,]~ind2,type="l",xlab=expression(alpha),ylab="a_i") } #(3) m=5 n=7 N=m+n #(a) X=combn(N,n) K=length(X[1,]) W=apply(X,2,sum) table(W)/K #pravdepodobnostni funkce plot(table(W)/K,xlab="x",ylab="p(x)") #graf pravdepodobnostni funkce #(b) mu=n*(N+1)/2 #EW sigma=sqrt(m*n*(N+1)/12) #sd(W) curve(dnorm(x,mu,sigma),add=T,col=2) #graf as. normalniho rozdeleni #(c) W2=W-n*(n+1)/2 table(W2)/K dwilcox(0:35,m,n)