Re: [R] Improvement: function cut

2021-09-18 Thread David Winsemius
On 9/18/21 5:28 AM, Leonard Mada via R-help wrote: Hello Andrew, I add this info as a completion (so other users can get a better understanding): If we want to perform a survival analysis, than the interval should be closed to the right, but we should include also the first time point (as pe

Re: [R] Improvement: function cut

2021-09-18 Thread Leonard Mada via R-help
Hello Andrew, I add this info as a completion (so other users can get a better understanding): If we want to perform a survival analysis, than the interval should be closed to the right, but we should include also the first time point (as per Intention-to-Treat): [0, 4](4, 8](8, 12](12, 16]

Re: [R] Improvement: function cut

2021-09-17 Thread Bert Gunter
Perhaps you and Andrew should take this discussion off list... Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Fri, Sep 17, 2021 at 3:45 PM Leonard Mada via R-he

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
The warn should be in cut() => .bincode(). It should be generated whenever a real value (excludes NA or NAN or +/- Inf) is not included in any of the bins. If the user writes a script and doesn't want any warnings: he can select warn = FALSE. But otherwise it would be very helpful to catch

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
Why would you want to merge different factors? It makes no sense on real data. Even if some names are the same, the factors are not the same! The only real-data application that springs to mind is censoring (right or left, depending on the choice): but here we have both open and closed interv

Re: [R] Improvement: function cut

2021-09-17 Thread Jeff Newmiller
Re your objection that "the user has to suspect that some values were not included" applies equally to your proposed warn option. There are a lot of ways to introduce NAs... in real projects all analysts should be suspecting this problem. On September 17, 2021 3:01:35 PM PDT, Leonard Mada via R

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
Hello Andrew, But "cut" generates factors. In most cases with real data one expects to have also the ends of the interval: the argument "include.lowest" is both ugly and too long. [The test-code on the ftable thread contains this error! I have run through this error a couple of times.] The

Re: [R] Improvement: function cut

2021-09-17 Thread Andrew Simmons
I disagree, I don't really think it's too long or ugly, but if you think it is, you could abbreviate it as 'i'. x <- 0:20 breaks1 <- seq.int(0, 16, 4) breaks2 <- seq.int(0, 20, 4) data.frame( cut(x, breaks1, right = FALSE, i = TRUE), cut(x, breaks2, right = FALSE, i = TRUE), check.nam

Re: [R] Improvement: function cut

2021-09-17 Thread Andrew Simmons
While it is not explicitly mentioned anywhere in the documentation for .bincode, I suspect 'include.lowest = FALSE' is the default to keep the definitions of the bins consistent. For example: x <- 0:20 breaks1 <- seq.int(0, 16, 4) breaks2 <- seq.int(0, 20, 4) cbind( .bincode(x, breaks1, right

Re: [R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
Thank you Andrew. Is there any reason not to make: include.lowest = TRUE the default? Regarding the NA: The user still has to suspect that some values were not included and run that test. Leonard On 9/18/2021 12:53 AM, Andrew Simmons wrote: > Regarding your first point, argument 'include.

Re: [R] Improvement: function cut

2021-09-17 Thread Andrew Simmons
Regarding your first point, argument 'include.lowest' already handles this specific case, see ?.bincode Your second point, maybe it could be helpful, but since both 'cut.default' and '.bincode' return NA if a value isn't within a bin, you could make something like this on your own. Might be worth

[R] Improvement: function cut

2021-09-17 Thread Leonard Mada via R-help
Hello List members, the following improvements would be useful for function cut (and .bincode): 1.) Argument: Include extremes extremes = TRUE if(right == FALSE) {    # include also right for last interval; } else {    # include also left for first interval; } 2.) Argument: warn = TRUE Warn

Re: [R] "Improvement with the R code"

2017-08-28 Thread Berry, Charles
> On Aug 28, 2017, at 9:26 AM, Elie Canonici Merle > wrote: > > Chuck (Is it fine to call you Chuck?) In this forum, yes please. > I don't know much about pmin and factor but it might worth looking into if > you want to manipulate states by names (I assume this is why one might want > to use

Re: [R] "Improvement with the R code"

2017-08-28 Thread Elie Canonici Merle
Chuck (Is it fine to call you Chuck?) has far more R jutsu than I do obviously. I don't know much about pmin and factor but it might worth looking into if you want to manipulate states by names (I assume this is why one might want to use it?) generate_transition_matrix <- function(data, states)

Re: [R] "Improvement with the R code"

2017-08-28 Thread Elie Canonici Merle
Ok, I assumed you wanted to compute a matrix M for all states such that M[i][j]= transition from state i to state j / number of transition from state i but from what you just answered it looks like you want to compute a matrix M for a set of states S such that: M[S_i][S_j]= transition from stat

Re: [R] "Improvement with the R code"

2017-08-28 Thread Berry, Charles
All of this can be done without for loops. Use head(..., -1), tail(..., -1) to get the pre and post states. Use factor or pmin to recode them as necessary Use table(pre, post) to get the transition counts. Use prop.table(table_of_counts,1) to get the probabilities. HTH, Chuck > On Aug 28,

Re: [R] "Improvement with the R code"

2017-08-28 Thread Elie Canonici Merle
Hi, I think you overthought this one a little bit, I don't know if this is the kind of code you are expecting but I came up with something like that: generate_transition_matrix <- function(data, n_states) { #To be sure I imagine you should check n_states is right at this point transiti

[R] "Improvement with the R code"

2017-08-28 Thread niharika singhal
Hello, I am trying to implement a formula aij= transition from state S_i to S_j/no of transition at state S_i Code I have written is working with three state {1,2,3 }, but if the number of states become={1,2,3,4,..n} then the code will not work, so can some help me with this. For and s

Re: [R] Improvement in Process time

2016-02-02 Thread PIKAL Petr
project.org] On Behalf Of Amelia > Marsh via R-help > Sent: Tuesday, February 02, 2016 1:03 PM > To: R Help R > Subject: [R] Improvement in Process time > > Dear R forum, > > I am running a Particular process 1000 times for different rates. Each > time the result

[R] Improvement in Process time

2016-02-02 Thread Amelia Marsh via R-help
Dear R forum, I am running a Particular process 1000 times for different rates. Each time the result of the process is getting stored (appended) in a data.frame. However, the process is taking unsual time at times more than 2 hours. When I had tried to find out the reason for such a long proces

Re: [R] Improvement of Regression Model

2012-09-05 Thread Jeff Newmiller
a) This sounds like homework. This is not a homework support forum. b) If it is not homework, you should take one or more classes on statistics. Your questions are more about theory than R and this is not a statistics theory mailing list. c) You ask questions about the use of your data, but you

Re: [R] Improvement of Regression Model

2012-09-05 Thread Bert Gunter
These questions are off topic for this list. Try a statistical list like stats.stackexchange.com. Probably better yet, as your statistical skills sound like they are somewhat limited, consult a local statistician for help. -- Bert On Wed, Sep 5, 2012 at 7:54 AM, Vignesh Prajapati wrote: > > Hel

[R] Improvement of Regression Model

2012-09-05 Thread Vignesh Prajapati
Hello folks, I am on learning phase of R. I have developed Regression Model over six predictor variables. while development, i found my all data are not very linear. So, may because of this the prediction of my model is not exact. Here is the summary of model : Call: lm(formula = y ~ x_1 +

Re: [R] improvement

2010-05-17 Thread Sebastian Kruk
For example if nombreC <- nombreC <- c("Juan", "Carlos", "Ana", "María","Mario") I do not want as a result: name index 1 Juan 1 2 Juan 5 3 Carlos 2 4Ana 3 5 María 4 6 Mario 0 I want: name index 1 Juan 1 2 Juan 5 3 Carlos 2 4Ana 3

Re: [R] improvement

2010-05-16 Thread Sebastian Kruk
Hi, if i just want a vector filled with names which has length(index) > 0. For example if nombreC <- c("Juan", "Carlos", "Ana", "María") nombreL <- c("Juan Campo", "Carlos Gallardo", "Ana Iglesias", "María Bacaldi", "Juan Grondona", "Dario Grandineti", "Jaime Acosta", "Lourdes Serrano") I would

Re: [R] improvement of Ancova analysis

2008-05-04 Thread hadley wickham
On Sat, May 3, 2008 at 9:00 PM, Tobias Erik Reiners <[EMAIL PROTECTED]> wrote: > Dear Helpers, > > I just started working with R and I'm a bit overloaded with information. > > My data is from marsupials reindroduced in a area. I have weight(wt), hind > foot > lenghts(pes) as continues variables

Re: [R] improvement of Ancova analysis

2008-05-04 Thread Stephan Kolassa
Hi Tobias, If you want to do inferential statistics with groups differing systematically on the covariate, you will need to be extra careful in your interpretation. See, e.g., Miller, G. A. & Chapman, J. P. Misunderstanding Analysis of Covariance, Journal of Abnormal Psychology, 2001, 110, 40

Re: [R] improvement of Ancova analysis

2008-05-03 Thread Prof Brian Ripley
For points 4 and 5, you could use a robust linear fit. One way to do that is to use rlm() from package MASS, which is used in several examples in the book that package MASS supports. On Sun, 4 May 2008, Tobias Erik Reiners wrote: Dear Helpers, I just started working with R and I'm a bit ove

Re: [R] improvement of Ancova analysis

2008-05-03 Thread Andrew Robinson
Tobi, I think that it would be easier to provide advice if you were more explicit on what the model will be used for, and what is the structure of the data. Is there only one measurement for each marsupial? Is the goal to a) produce a model to predict marsupial weight given other variables, and

[R] improvement of Ancova analysis

2008-05-03 Thread Tobias Erik Reiners
Dear Helpers, I just started working with R and I'm a bit overloaded with information. My data is from marsupials reindroduced in a area. I have weight(wt), hind foot lenghts(pes) as continues variables and origin and gender as categorial. condition is just the residuals i took from the model