Re: [R] NA in AR model residuals
Thanks all! On 09/09/2007, Nick Chorley <[EMAIL PROTECTED]> wrote: > > Hi, > > This may be a stupid question, but why when creating an AR model, why does > R set the first n components of the ar object's resid vector to NA (where n > is the order of the model)? > > Regards, > > NC > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
[R] NA in AR model residuals
Hi, This may be a stupid question, but why when creating an AR model, why does R set the first n components of the ar object's resid vector to NA (where n is the order of the model)? Regards, NC [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
Re: [R] Possible to "import" histograms in R?
On 15/08/07, Ted Harding <[EMAIL PROTECTED]> wrote: > > So you if you want the density plot, you would need to calculate > this for yourself. E.g. > > H1$density <- counts/sum(counts) > plot.histogram(H1,freq=FALSE) Oddly, plot.histogram doesn't work in my version of R (which is 2.5.1), even though R can give me the help page for it. plot() works fine though. Thanks again! NC And so on ... there are many relevant details in the help pages > ?hist and ?plot.histogram > > Best wishes, > Ted. > > > E-Mail: (Ted Harding) <[EMAIL PROTECTED]> > Fax-to-email: +44 (0)870 094 0861 > Date: 15-Aug-07 Time: 11:53:14 > -- XFMail -- > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
Re: [R] Possible to "import" histograms in R?
Thanks everyone! NC On 15/08/07, Ted Harding <[EMAIL PROTECTED]> wrote: > > On 15-Aug-07 18:17:27, Greg Snow wrote: > > > > > > > > Ted Harding wrote: > > [snip] > > > >> So you if you want the density plot, you would need to calculate > >> this for yourself. E.g. > >> > >> H1$density <- counts/sum(counts) > >> plot.histogram(H1,freq=FALSE) > > > > shouldn't that be: > > H1$density <- counts/sum(counts)/diff(brkpts) > > > > ? > > Of course! Thank you. > Ted. > > > E-Mail: (Ted Harding) <[EMAIL PROTECTED]> > Fax-to-email: +44 (0)870 094 0861 > Date: 15-Aug-07 Time: 20:23:13 > -- XFMail -- > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
Re: [R] Possible to "import" histograms in R?
On 15/08/07, Ted Harding <[EMAIL PROTECTED]> wrote: > > On 15-Aug-07 08:30:08, Nick Chorley wrote: > > Hi, > > > > I have a large amount of data that I would like to create a > > histogram of and plot and do things with in R. It is pretty > > much impossible to read the data into R, so I have written a > > program to bin the data and now have a list of counts in each > > bin. Is it possible to somehow import this into R and use > > hist(), so I can, for instance, plot the probability density? > > I have looked at the help page for hist(), but couldn't find > > anything related to this there. > > > > Regards, > > > > Nicky Chorley > > Presumably you now have (or can readily generate) files on your > system whose contents are (or are equivalent to) something like: > > brkpts.dat > 0.0 > 0.5 > 1.0 > > 9.5 > 10.0 > > counts.dat > 10 > 7 > 38 > > 7 > 0 > > where there is one more line in brkpts.dat than in counts.dat > > Now simply read both files into R, creating variables 'brkpts', > 'counts' > > Now create a histogram template (any silly old data will do): > > H1 <- hist(c(1,2)) > > Next, attach your variables to it: > > H1$breaks <- brkpts > H1$counts <- counts > > and you have your histogram in R. Also, you can use the data > in the variables 'brkpts', 'counts' to feed into any other > procedure which can acept data in this form. This is precisely what I wanted to do, except I didn't realise that you could assign to the variables in the histogram object like this. Normally when constructing the histogram, I'd use hist(x, prob=T) to plot the probability density against x, but obviously if you're just assigning values to the variables in the object, you can't do that. I tried putting "prob=T" in the call to hist when making the dummy object, but that didn't help. Example (simulating the above in R): > > brkpts<-0.5*(0:20) > counts<-rpois(20,7.5) > H1<-hist(c(1,2)) > H1$breaks <- brkpts > H1$counts <- counts > plot(H1) > > Or, if you want a more "realistic-looking" one, follow on with: > > midpts<-(brkpts[1:20]+brkpts[2:21])/2 > counts<-rpois(20,100*dnorm(midpts,mean=5,sd=3)) > H1$breaks <- brkpts > H1$counts <- counts > plot(H1) > > > In other words, you've already done R's work for it with your > program which bins the data. All you need to do in R is to get > these results into the right place in R. Yes! Thanks very much! NC Hoping this helps, > Ted. > > > E-Mail: (Ted Harding) <[EMAIL PROTECTED]> > Fax-to-email: +44 (0)870 094 0861 > Date: 15-Aug-07 Time: 10:38:05 > -- XFMail -- > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.
Re: [R] Possible to "import" histograms in R?
On 15/08/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: Nick Chorley-3 wrote: > > I have a large amount of data that I would like to create a histogram of > and > plot and do things with in R. It is pretty much impossible to read the > data > into R, so I have written a program to bin the data and now have a list of > counts in each bin. Is it possible to somehow import this into R and use > hist(), so I can, for instance, plot the probability density? I have > looked > at the help page for hist(), but couldn't find anything related to this > there. > Hi! And why do you think, its impossible to import the data in R? It can handle rather large data volumes, especially in Linux. Just study help("Memory-limits"). My data file is 4.8 GB! You can plot something looking like a histogram using barplot() or plot(... type="h"). The problem with those is that I can't plot the probability density. You can create the "histogram" class object manually. For example, [ import bin counts... probably, it is a table of 2 columns, defining bin borders and counts. let's store it in ncounts. ] Yes, that's what I have. > hst<-hist(rnorm(nrow(ncounts)),plot=FALSE) > str(hst) # actually I called hist(rnorm(100)) List of 7 $ breaks : num [1:10] -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 $ counts : int [1:9] 3 6 12 9 24 19 14 9 4 $ intensities: num [1:9] 0.06 0.12 0.24 0.18 0.48 ... $ density: num [1:9] 0.06 0.12 0.24 0.18 0.48 ... $ mids : num [1:9] -2.25 -1.75 -1.25 -0.75 -0.25 0.25 0.75 1.25 1.75 $ xname : chr "rnorm(100)" $ equidist : logi TRUE - attr(*, "class")= chr "histogram" > hst$breaks <- [ bsdfgsdghsdghdfgh ] > hst$counts <- [ asfd109,mnasdfkjhdsfl ] > hst$intensities <- My data isn't normally distributed, so I tried rexp() rather than rnorm(), but it's not looking like it should Studying the hist.default() sources will help you to understand, how every list element is created. -- View this message in context: http://www.nabble.com/Possible-to-%22import%22-histograms-in-R--tf4271809.html#a12158586 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch 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. --SevinMail-- __ R-help@stat.math.ethz.ch 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.
[R] Possible to "import" histograms in R?
Hi, I have a large amount of data that I would like to create a histogram of and plot and do things with in R. It is pretty much impossible to read the data into R, so I have written a program to bin the data and now have a list of counts in each bin. Is it possible to somehow import this into R and use hist(), so I can, for instance, plot the probability density? I have looked at the help page for hist(), but couldn't find anything related to this there. Regards, Nicky Chorley [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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.