set.seed(1234) n=30 X=rnorm(n) # data # (a) vyberovy prumer i=1 # IF pro prvni pozorovani IF=function(x){ IF=n*(mean(c(X[-i],x))-mean(X)) return(IF) } ind=seq(-10,10, by=0.01) #graf vykreslime na mrizce od -10 do 10 plot(Vectorize(IF)(ind)~ind, type="l",xlab="x",ylab="EIF(x)") #jina definice IF2=function(x){ IF2=(n+1)*(mean(c(X,x))-mean(X)) return(IF2) } plot(Vectorize(IF2)(ind)~ind, type="l",xlab="x",ylab="EIF(x)") # (b) median IF=function(x){ IF=n*(median(c(X[-i],x))-median(X)) return(IF) } plot(Vectorize(IF)(ind)~ind, type="l",xlab="x",ylab="EIF(x)") # (c) useknuty prumer IF=function(x){ IF=n*(mean(c(X[-i],x),trim=0.1)-mean(X,trim=0.1)) return(IF) } plot(Vectorize(IF)(ind)~ind, type="l",xlab="x",ylab="EIF(x)") # (d) winsorizovany prumer library(psych) IF=function(x){ IF=n*(winsor.mean(c(X[-1],x),0.1)-winsor.mean(X,0.1)) return(IF) } plot(Vectorize(IF)(ind)~ind, type="l",xlab="x",ylab="EIF(x)")