I´m using this version of R

R version 2.13.2 (2011-09-30)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)


2012/5/5 Trying To learn again <tryingtolearnag...@gmail.com>

> Hi all,
>
> I´m re-starting (as my name indicates) my little knowlegde of CRAN R.
>
> I made this function time before but I don´t know where is the error
> because nothing appears as an error but the histogram plot doesn´t appear.
> Should I install some special library to run sapply?
>
>
> pru<-function(){
>
> randz<-matrix(rnorm(200000),100,2000)
>
> H<-matrix(0,100,2000)
>
>
> for (j in 2:2000){
> for (i in 2:100){
> H[1,]<-randz[1,]
> H[i,j]<-H[i-1,j]+randz[i,j]
>
>
> }}
>
> hy<-nrow(H)-1
>
> estima<-H[2:nrow(H),]
>
> estima2<-H[1:hy,]
>
>
> a<-estima
> b<-estima2
>
>
> mycoef <- function(x, y) coefficients( lm(y ~ x-1) )
>
> rest <- sapply(2:2000, function(i){
>                y <- a[,i]
>                x <- b[,i]
>               mycoef(x,y)
>                }
>             )
>
>
>
> print(summary(rest))
>
> hist(rest,col="blue",breaks=seq(0.6,1.05,0.01),prob=TRUE)
> lines(density(rest,bw=0.03))
> rug(rest)
>
>
>
> }
>
> Many Thanks¡¡¡
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to