Moumita Das
2009-Jan-06 11:26 UTC
[R] Warning message:In pt(q, df, lower.tail, log.p) : NaNs produced
Hi friends, Any idea why do i get this warning?And also why all computed p-values are NaN. Have shown below what i did in Windows r-console.:--> dfc1 c2 1 1 50 2 NA NA 3 4 NA 4 7 6 5 NA 7 6 10 10> r<-cor(x=df,y=NULL,use="complete.obs",method=c("pearson")) > rc1 c2 c1 1.0000000 -0.9148074 c2 -0.9148074 1.0000000> cor.p.values<- function(r, n)+ { + df <- n - 2 + ESTIMATE <- c(cor = r) + PARAMETER <- c(df = df) + STATISTIC <- c(sqrt(df) * r / sqrt(1 - r^2)) + p <- pt(STATISTIC, df) + return(2 * pmin(p, 1 - p)) + }> cor.p.values(r,2)[1] NaN NaN NaN NaN *Warning message: In pt(q, df, lower.tail, log.p) : NaNs produced * Any help will be appreciated.. :) -- Thanks Moumita [[alternative HTML version deleted]]
Yihui Xie
2009-Jan-06 11:58 UTC
[R] Warning message:In pt(q, df, lower.tail, log.p) : NaNs produced
Obviously your df=0 in pt(STATISTIC, df). Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Tue, Jan 6, 2009 at 7:26 PM, Moumita Das <das.moumita.online at gmail.com> wrote:> Hi friends, > Any idea why do i get this warning?And also why all computed p-values are > NaN. > Have shown below what i did in Windows r-console.:-- >> df > c1 c2 > 1 1 50 > 2 NA NA > 3 4 NA > 4 7 6 > 5 NA 7 > 6 10 10 >> r<-cor(x=df,y=NULL,use="complete.obs",method=c("pearson")) >> r > c1 c2 > c1 1.0000000 -0.9148074 > c2 -0.9148074 1.0000000 >> cor.p.values<- function(r, n) > + { > + df <- n - 2 > + ESTIMATE <- c(cor = r) > + PARAMETER <- c(df = df) > + STATISTIC <- c(sqrt(df) * r / sqrt(1 - r^2)) > + p <- pt(STATISTIC, df) > + return(2 * pmin(p, 1 - p)) > + } >> cor.p.values(r,2) > [1] NaN NaN NaN NaN > *Warning message: > In pt(q, df, lower.tail, log.p) : NaNs produced > * > Any help will be appreciated.. :) > -- > Thanks > Moumita > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
Reasonably Related Threads
- Calculating signicance value
- Fwd: Cannot allocate a new database connection error
- Error in pf(q, df1, df2, lower.tail, log.p) : Non-numeric argument to mathematical function
- Query regarding na.omit function
- Added system Info:--Segmentation Fault occured while connecting to the database