[R] Regression
I need to run a regression analysis with a large number of samples. Each sample (identified in the first file column) has its own x and y values. I will use the same model in all samples. How can I run the model for each sample? In SAS code I would use the BY SAMPLE statement. Alvaro [[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] tree-ring response function in R?
Hi, I am looking forward if some of you could help me with this. I have been looking R-functions to conduct tree-ring analysis in R. I know that exists a COFECHA version in R developed by C. Bigler. But I don't know if is there another collection of functions to do dendroclimatological analysis (such as response functions). Has someone developed such rutines in R ?, thanks in advance, Alvaro __ 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
Re: [R] Generation of missiing values in a time serie...
On 13 Dec 2005, at 20:06, Gabor Grothendieck wrote: In thinking about this some more, the trick I discussed is probably not the best way to do it since its possible that in the future zoo will completely disallow illegal zoo objects. I think a better way might be to construct it like this: aggregate(zoo(z.data), round(z.time, 1), tail, 1) where z.data is the matrix and z.time are the times. The variable z, which is an illegal zoo object, would not be created but in terms of z, since that is what I have reproducibly from your post, we have: z.data - coredata(z) z.time - time(z) Thanks for your help. However, I have finally implemented a solution by myself, using a loop that iterates over the original serie. I haven't been able to find a way of using these functions and generating a regular time serie in the way I wanted. Thanks anyway. Alvaro -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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
Re: [R] Generation of missiing values in a time serie...
Hi, First, thank you. It 'almost' works: I can convert a matrix to a 'zoo' object, but it can not convert it to a 'ts'. The sitruation is this: I load a set of samples with h_types - list (0, 0, character(0), character(0), 0, 0, 0, 0, 0) h_names - list (time, flow, type, dir, seq, ts, x, rtt, size) pcks_file - pipe (grep ' P ' server.dat), r) pcks- scan (pcks_file, what = h_types, comment.char = '#', fill = TRUE) Read 1429 records mat - data.frame (pcks) colnames (mat) - h_names mat time flow type dir seq ts x rtt size 1 1.0008930P +0 1.000893 1472 0.00 1472 2 1.5144540P +1 1.514454 2944 0.513142 1472 3 2.0150930P +2 2.015093 2944 0.513142 1472 4 2.5150250P +3 2.515025 4806 0.504488 1472 5 2.8219760P +4 2.821976 5730 0.496728 1472 6 3.0789310P +5 3.078931 5832 0.489744 1472 7 3.3318970P +6 3.331897 5832 0.489744 1472 [...] 1425 176.9255040P + 1424 176.925504 12141 0.764699 1472 1426 177.0394890P + 1425 177.039489 12141 0.764699 1472 1427 177.1534690P + 1426 177.153469 12141 0.764699 1472 1428 177.2674640P + 1427 177.267464 12141 0.764699 1472 1429 177.3814340P + 1428 177.381434 12141 0.764699 1472 Then I convert it to a 'zoo', removing the 'time' column from the input last_col- ncol (mat) range_cols - 2:last_col matrix_values - mat [,range_cols] z - zoo (matrix_values, mat $ time) So far, everything is fine. But then I need to apply a function to samples taken every t seconds, ie, the mean every 10 seconds. And, AFAIK, rapply needs a constant 'width', something that can only be obtained with regular time series... But if I try to get a 'ts' object from my 'zoo' I get as.ts (z) Error in if (del == 0 to == 0) return(to) : missing value where TRUE/FALSE needed Ummm, do you know if there is any error in my 'zoo' object? Has it the right format? Or, could I avoid the conversion and use the 'rapply' function but on time intervals (instead of points intervals)? Thank you very much. Alvaro On 12 Dec 2005, at 16:31, Gabor Grothendieck wrote: First we generate some sample data x and its times tt. Then using the zoo package we create an irregularly spaced time series. Now if you want a regularly spaced time series convert it to ts class. After loading zoo as shown below, the R command vignette(zoo) gives more info. x - 1:4 tt - c(1, 3, 4, 6) library(zoo) x.zoo - zoo(x, tt) # irregularly spaced time series x.ts - as.ts(x.zoo) # regular time series with NAs On 12/12/05, Alvaro Saurin [EMAIL PROTECTED] wrote: Hi, I am a R begginer and I have a small problem with time series. I was wondering if someone could help me I am collecting data from packets going through a network, and using R for obtaining some simple statistics of connections. However, my data is not collected at a constant frequency, so I would like to create a evenly spaced TS from my traces, using the minimum time difference between two samples as the period for my new TS, and filling the gaps with NA (or 0s). I think ther must be some simple solution for this... Anyone could help me? Thanks in advance. -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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 -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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
Re: [R] Generation of missiing values in a time serie...
On 13 Dec 2005, at 13:08, Gabor Grothendieck wrote: Your variable mat is not a matrix; its a data frame. Check it with: class(mat) Here is an example: x - cbind(A = 1:4, B = 5:8) tt - c(1, 3:4, 6) library(zoo) x.zoo - zoo(x, tt) x.ts - as.ts(x.zoo) Fixed, but anyway it fails: h_types - list (0, 0, NULL, NULL, 0, 0, 0, 0, 0) h_names - list (time, flow, seq, ts, x, rtt, size) pcks_file - pipe (grep ' P ' server.dat, r) pcks- scan (pcks_file, what = h_types, comment.char = '#', fill = TRUE) mat_df - data.frame (pcks[1:2], pcks[5:9]) mat - as.matrix (mat_df) colnames (mat) - h_names class (mat) [1] matrix z - zoo (mat, mat [,time]) z z time flow seq ts xrtt size 1.0009 1.000893 0.00 0.00 1.000893 1472.00 0.00 1472.00 1.5145 1.514454 0.00 1.00 1.514454 2944.00 0.513142 1472.00 2.0151 2.015093 0.00 2.00 2.015093 2944.00 0.513142 1472.00 2.5152.515025 0.00 3.00 2.515025 4806.00 0.504488 1472.00 2.8222.821976 0.00 4.00 2.821976 5730.00 0.496728 1472.00 [...] as.ts (z) Error in if (del == 0 to == 0) return(to) : missing value where TRUE/FALSE needed Any idea? Thanks for your help. Alvaro -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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
Re: [R] Generation of missiing values in a time serie...
I think I have found the error. It appears when there are two entries with the same time. Using as input file: - CUT # Output format for PCKs: # TIME FLOW P [+-] SEQ TS X RTT SIZE # 123.125683 0 P + 967 123.125683 13394 0.798205 1472 123.241137 0 P + 968 123.241137 12680 0.796258 1472 123.241137 0 P + 969 123.241137 12680 0.796258 1472 123.472631 0 P + 970 123.472631 12680 0.796258 1472 123.588613 0 P + 971 123.588613 12680 0.796258 1472 123.704594 0 P + 972 123.704594 12680 0.796258 1472 - CUT I run fhe following code: - CUT h_types - list (0, 0, NULL, NULL, 0, 0, 0, 0, 0) h_names - list (time, flow, seq, ts, x, rtt, size) pcks_file- pipe (grep ' P ' data, r) pcks - scan (pcks_file, what = h_types, comment.char = '#', fill = TRUE) mat_df - data.frame (pcks[1:2], pcks[5:9]) mat - as.matrix (mat_df) colnames (mat) - h_names z - zoo (mat, mat [,time]) - CUT The dput of 'z' shows: - CUT structure(c(123.125683, 123.241137, 123.241137, 123.472631, 123.588613, 123.704594, 0, 0, 0, 0, 0, 0, 967, 968, 969, 970, 971, 972, 123.125683, 123.241137, 123.241137, 123.472631, 123.588613, 123.704594, 13394, 12680, 12680, 12680, 12680, 12680, 0.798205, 0.796258, 0.796258, 0.796258, 0.796258, 0.796258, 1472, 1472, 1472, 1472, 1472, 1472 ), .Dim = c(6, 7), .Dimnames = list(c(1, 2, 3, 4, 5, 6), c(time, flow, seq, ts, x, rtt, size)), index = structure(c(123.125683, 123.241137, 123.241137, 123.472631, 123.588613, 123.704594), .Names = c(1, 2, 3, 4, 5, 6)), class = zoo) - CUT If I try a 'as.ts(z)', it fails. If I remove the duplicate entry, I can convert it to a TS with no problem. Is this made intentionally? Because then I have to filter the input matrix... But, anyway, the output matrix, after filtering, doesn't seem regular: - CUT as.ts (z) Time Series: Start = 1 End = 5 Frequency = 1 time flow seq ts x rtt size 1 123.12570 967 123.1257 13394 0.798205 1472 2 123.24110 969 123.2411 12680 0.796258 1472 3 123.47260 970 123.4726 12680 0.796258 1472 4 123.58860 971 123.5886 12680 0.796258 1472 5 123.70460 972 123.7046 12680 0.796258 1472 Warning message: ‘x’ does not have an underlying regularity in: as.ts.zoo(z) - CUT Weird... On 13 Dec 2005, at 16:33, Gabor Grothendieck wrote: Please provide a reproducible example. Note that dput(x) will output an R object in a way that can be copied and pasted into another session. On 12/13/05, Alvaro Saurin [EMAIL PROTECTED] wrote: On 13 Dec 2005, at 13:08, Gabor Grothendieck wrote: Your variable mat is not a matrix; its a data frame. Check it with: class(mat) Here is an example: x - cbind(A = 1:4, B = 5:8) tt - c(1, 3:4, 6) library(zoo) x.zoo - zoo(x, tt) x.ts - as.ts(x.zoo) Fixed, but anyway it fails: h_types - list (0, 0, NULL, NULL, 0, 0, 0, 0, 0) h_names - list (time, flow, seq, ts, x, rtt, size) pcks_file - pipe (grep ' P ' server.dat, r) pcks- scan (pcks_file, what = h_types, comment.char = '#', fill = TRUE) mat_df - data.frame (pcks[1:2], pcks[5:9]) mat - as.matrix (mat_df) colnames (mat) - h_names class (mat) [1] matrix z - zoo (mat, mat [,time]) z z time flow seq ts xrtt size 1.0009 1.000893 0.00 0.00 1.000893 1472.00 0.00 1472.00 1.5145 1.514454 0.00 1.00 1.514454 2944.00 0.513142 1472.00 2.0151 2.015093 0.00 2.00 2.015093 2944.00 0.513142 1472.00 2.5152.515025 0.00 3.00 2.515025 4806.00 0.504488 1472.00 2.8222.821976 0.00 4.00 2.821976 5730.00 0.496728 1472.00 [...] as.ts (z) Error in if (del == 0 to == 0) return(to) : missing value where TRUE/FALSE needed Any idea? Thanks for your help. Alvaro -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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
[R] Generation of missiing values in a time serie...
Hi, I am a R begginer and I have a small problem with time series. I was wondering if someone could help me I am collecting data from packets going through a network, and using R for obtaining some simple statistics of connections. However, my data is not collected at a constant frequency, so I would like to create a evenly spaced TS from my traces, using the minimum time difference between two samples as the period for my new TS, and filling the gaps with NA (or 0s). I think ther must be some simple solution for this... Anyone could help me? Thanks in advance. -- Alvaro Saurin [EMAIL PROTECTED] [EMAIL PROTECTED] __ 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
[R] Re: diamond graphs
Drs. Harrell and O'Keefe, Thank you for your suggestions. Regarding your comments about the content of the paper, I respectfully disagree that categorizing continuous variables is a fundamental violation of statistical graphics, nor are you to assume that all categorizations are arbitrary. In any case, the discussion section of our paper contains text acknowledging that contour plots are a preferred option when the continuity of variables is desired to be preserved. The hexagons we proposed seem, at first glance, to be unnecessarily complex but they fulfill properties that none of the other considered alternatives do (Table 1 and Figure 1 in paper and Figure 6 using Trellis). It is unfortunate that the comments from Dr. O'Keefe were based on a press release and not on the manuscript itself. I apologize for the press release implying no graphical progress in the 20th century. Many of his points are addressed in the manuscript. Regarding the extension of the methods to outcomes taking negative values (e.g., changes in markers), the use of two colors is an alternative but the plotting of 0.5*[1+(outcome/max(|outcome|)] and using the option E of Figure 1 in the paper will result in negative and positive values having opposite topology (much as the contrast of negative/positive bars in the unidimensional case). I will be happy to expedite a reprint to Dr. O'Keefe. If you so desire, please email the address to which it should be sent. Although it is at odds with your beliefs, University staff working on licensing and technology transfer believe that a patent may be a vehicle to achieve a wide use. The audience of the proposed methods would be the end users who are not sophisticated programmers and, therefore, the hope is that it would be available in widely used software which is not the case of the high end software (e.g., R). The proposed graph of 2D equiponderant display of two predictors is just a display procedure, not an inferential tool. The sophisticated analyst has little or no need for the proposed method. It does overcome the pitfalls of 3D bar graphs and, therefore, has the potential of improving the way we communicate our findings. Needless to say, were the predictions of Dr. Harrell to be on target, we will change course as the staff working on the licensing have planned from the start. We will be happy to share the code we wrote to produce the figures in The American Statistician paper with individuals wanting to use the software for academic purposes. Please send request for it to [EMAIL PROTECTED] In summary, our idea is a simple one (one that I refer as needing only 8th grade geometry) and it is its simplicity which has been fun to peruse. Alvaro Muñoz __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help