Re: [R] syvcoxph and cox.zph for testing the PH assumption

2021-07-12 Thread Youyi Fong
Thank you, Terry. We look forward to hearing from you again. Youyi On Mon, Jul 12, 2021 at 3:13 PM Therneau, Terry M., Ph.D. wrote: > > > On 7/11/21 5:00 AM, r-help-requ...@r-project.org wrote: > > Hello, is it kosher to call cox.zph on a syvcoxph model fit? I see that > > someone proposed a

Re: [R] syvcoxph and cox.zph for testing the PH assumption

2021-07-12 Thread Therneau, Terry M., Ph.D. via R-help
On 7/11/21 5:00 AM, r-help-requ...@r-project.org wrote: Hello, is it kosher to call cox.zph on a syvcoxph model fit? I see that someone proposed a modified version of cox.zph that uses resid(fit, 'schoenfeld', **weighted=TRUE**).

Re: [R] density with weights missing values

2021-07-12 Thread Duncan Murdoch
On 12/07/2021 1:22 p.m., matthias-gondan wrote: You're right, of course. Extrapolating your argument a bit, the whole practice of na.rm is questionable, since there's always a reason for missingness (that is not in x and rarely elsewhere in the data)Best wishes Matthias For what it's worth,

Re: [R] density with weights missing values

2021-07-12 Thread Jeff Newmiller
I think the missing weights are more crucial than equally-weighted missing data would be. what if there is a heavy weight on the missing values? it could completely change the interpretation of the result. On July 12, 2021 10:22:19 AM PDT, matthias-gondan wrote: >You're right, of course.

Re: [R] density with weights missing values

2021-07-12 Thread matthias-gondan
You're right, of course. Extrapolating your argument a bit, the whole practice of na.rm is questionable, since there's always a reason for missingness (that is not in x and rarely elsewhere in the data)Best wishes Matthias  Ursprüngliche Nachricht Von: Jeff Newmiller Datum:

Re: [R] density with weights missing values

2021-07-12 Thread Jeff Newmiller
Sure, you might think that. But most likely the reason this code has not been corrected is that when you give weights for missing data the most correct result is for your entire density to be invalid. Fix your inputs so they make sense to you and there is no problem. But absent your

Re: [R] density with weights missing values

2021-07-12 Thread Bert Gunter
My point (confusingly made!) is that documented behavior is all you should expect. The docs say that weights must be non-negative numeric. If they aren't... "Consistency" of behavior among different functions is highly subjective -- it depends exactly on what one considers to be "consistent",

Re: [R] density with weights missing values

2021-07-12 Thread matthias-gondan
The thing is that for na.rm=TRUE, I would expect the weights corresponding to the missing x to be removed, as well. Like in weighted.mean. So this one shouldn't raise an error,density(c(1, 2, 3, 4, 5, NA), na.rm=TRUE, weights=c(1, 1, 1, 1, 1, 1))Or am I missing something? 

Re: [R] density with weights missing values

2021-07-12 Thread Bert Gunter
The behavior is as documented AFAICS. na.rm logical; if TRUE, missing values are removed from x. If FALSE any missing values cause an error. The default is FALSE. weights numeric vector of non-negative observation weights. NA is not a non-negative numeric. Bert Gunter "The trouble with

Re: [R] density with weights missing values

2021-07-12 Thread Matthias Gondan
Weighted mean behaves differently: • weight is excluded for missing x • no warning for sum(weights) != 1 > weighted.mean(c(1, 2, 3, 4), weights=c(1, 1, 1, 1)) [1] 2.5 > weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1)) [1] NA > weighted.mean(c(1, 2, 3, NA), weights=c(1, 1, 1, 1), na.rm=TRUE)

[R] density with weights missing values

2021-07-12 Thread Matthias Gondan
Dear R users, This works as expected: • plot(density(c(1,2, 3, 4, 5, NA), na.rm=TRUE)) This raises an error • plot(density(c(1,2, 3, 4, 5, NA), na.rm=TRUE, weights=c(1, 1, 1, 1, 1, 1))) • plot(density(c(1,2, 3, 4, 5, NA), na.rm=TRUE, weights=c(1, 1, 1, 1, 1, NA))) This seems to work (it