[R] help with simulate AR(1) data
Hi, sorry for bothering your guys again. I want to simulate 100 AR(1) data with cor(x_t, x_t-1)=rho=0.3. The mean of the first 70 data (x_1 to x_70) is 0 and the mean of the last 30 data (x_71 to x_100) is 2. Can I do it in the following way? x <- arima.sim(list=(ar=0.3), 100) mean <- c(rep(0, 70), rep(2, 30)) xnew <- x+mean If the above code to simulate 100 AR(1) data is right, what should I do if I want to simulate 1000 independent group of this data? Each group contains 100 AR(1) data. So it is a matrix of 1000*100. Each row is a AR(1). I think there should be a quicker way to do that? (the easies way is simulate ar(1) 1000 times, but it waste time, I think) Thank you very much for your reply! Fang -- View this message in context: http://www.nabble.com/help-with-simulate-AR%281%29-data-tp18597351p18597351.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] Question about using “par”
Hi, Sorry for bothering your guys again. I am trying to use "par" to put 6 figures into 3 rows and 2 columns. My code is: op <- par(mfrow = c(1, 2)) xyplot(x1+x2+x3 ~ y, data=resulta, type="l", pch=LETTERS[1:3], lty=c(1:3), main="For k=3, theata1=1") xyplot(x1+x2+x3 ~ y, data=resultb, type="l", pch=LETTERS[1:3], lty=c(1:3), main="For k=3, theata1=5") xyplot(x1+x2+x3 ~ y, data=resultc, type="l", pch=LETTERS[1:3], lty=c(1:3), main="For k=5, theata1=1") xyplot(x1+x2+x3 ~ y, data=resultd, type="l", pch=LETTERS[1:3], lty=c(1:3), main="For k=5, theata1=5") xyplot(x1+x2+x3 ~ y, data=resulte, type="l", pch=LETTERS[1:3], lty=c(1:3), main="For k=10, theata1=1") xyplot(x1+x2+x3 ~ y, data=resultf, type="l", pch=LETTERS[1:3], lty=c(1:3), main="For k=10, theata1=5") par(op) But I can only get one figure in one page, not 6 figures in one page. Is there any other parameter I should specify? There is no error indicated. Thank you so much! Catherine -- View this message in context: http://www.nabble.com/Question-about-using-%E2%80%9Cpar%E2%80%9D-tf4894997.html#a14019058 Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] How to write a Greek letter in a graph?
Hi, Sorry for bothering you again. I have a small question about the graph and the following is my code: xyplot(power1+power2 ~ pi0, data=resultb, ylab="Average Power", type="l", pch=LETTERS[1:2], lty=c(1:2), main="(a)") The name of the X-axis will be “pi0” in the graph. What should I do if I want the name of the X-axis is the Greek letter of “pi0”? Thanks a lot! Catherine -- View this message in context: http://www.nabble.com/How-to-write-a-Greek-letter-in-a-graph--tp14957789p14957789.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] About "Plot.new"
Hi, sorry for bothering your guys. I will trying to make some nice graph using boxplot. when I check the help file of boxplot, there is a sample code as: boxplot(len ~ dose, data = ToothGrowth, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2, subset = supp == "OJ", col = "orange") legend(2, 9, c("Ascorbic acid", "Orange juice"), fill = c("yellow", "orange")) But when I run it, it shows the following error: Error in xypolygon(xx, yy, lty = "blank", col = boxfill[i]) : plot.new has not been called yet what does it mean? If I first run "plot.new()", then running the above code, only the x-axis and y-axis is on the graph, no boxplot inside. Can anyone tell me how to call plot.new or at least how to run the above code correctly? Thank you very much! -- View this message in context: http://www.nabble.com/About-%22Plot.new%22-tp19446258p19446258.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] Again, about boxplot
Thank you for your guys reply for my previous question. But I got one more question about the boxplot. With the code in the R-help: boxplot(len ~ dose, data = ToothGrowth, boxwex = 0.25, at = 1:3 - 0.2, subset = supp == "VC", col = "yellow", main = "Guinea Pigs' Tooth Growth", xlab = "Vitamin C dose mg", ylab = "tooth length", ylim = c(0, 35), yaxs = "i") boxplot(len ~ dose, data = ToothGrowth, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2, subset = supp == "OJ", col = "orange") legend(2, 9, c("Ascorbic acid", "Orange juice"), fill = c("yellow", "orange")) I got 6 boxplots, which is ordered as "0.5, 0.5, 1, 1, 2, 2" How can I reorder the 6 boxplots as "0.5, 1, 2, 0.5, 1, 2"? Thank you very much! -- View this message in context: http://www.nabble.com/Again%2C-about-boxplot-tp19457862p19457862.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] how to extend the whisker in boxplot?
Hi, Sorry for bothering your guys. I am still working on boxplot. How can I extend the whisker to the 5% and the 95% quantiles? What I should do if I only want to show the most extreme outlier, like 0.01% and 99.99% percentiles? I saw something on boxplot.stat, but I even donot know how to connect it to boxplot? Thank you very much! suppose the follow is the data to make the boxplot. a <- c(1:100, 800, 900, 1000, -800, -900, -1000) -- View this message in context: http://www.nabble.com/how-to-extend-the-whisker-in-boxplot--tp19540830p19540830.html Sent from the R help mailing list archive at Nabble.com. __ 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.