[R] Displaying Results in Two Columns
Could I have some suggestions as to how (various ways) I can display my confidence interval results? rm(list = ls()) set.seed(1) func - function(d,t,beta,lambda,alpha,p.gamma,delta,B){ d - c(5,1,5,14,3,19,1,1,4,22) t - c(94.32,15.72,62.88,125.76,5.24,31.44,1.048,1.048,2.096,10.48) post - matrix(0, nrow = 11, ncol = B) theta - c(lambda,beta) beta.hat - 2.471546 for(j in 1:B){ for(i in 1:(B-1)){ c.lambda - rgamma(10,d+alpha,t+beta.hat) c.beta - rgamma(1,10*alpha+p.gamma,delta+sum(lambda)) c.theta - c(c.lambda,c.beta) pi.func - prod((c.lambda/lambda)^(d+alpha-1)*exp(-t*(c.lambda-lambda)))*(c.beta/beta)^(10*alpha+p.gamma-1)*exp(-c.beta*(delta+sum(c.lambda))+beta*(delta+sum(lambda))) g.x - prod((beta.hat+t)^(alpha+d)*lambda^(alpha+d-1)*exp(-lambda*(beta.hat+t))/gamma(alpha+d))*(sum(lambda)+delta)^(p.gamma+10*alpha)*beta^(p.gamma+10*alpha-1)*exp(-beta*(sum(lambda)+delta))/gamma(p.gamma+10*alpha) g.y - prod((beta.hat+t)^(alpha+d)*c.lambda^(alpha+d-1)*exp(-lambda*(beta.hat+t))/gamma(alpha+d))*(sum(c.lambda)+delta)^(p.gamma+10*alpha)*c.beta^(p.gamma+10*alpha-1)*exp(-c.beta*(sum(c.lambda)+delta))/gamma(p.gamma+10*alpha) a - pi.func*(g.x/g.y) if(a1){ theta-c.theta } else theta - theta+(c.theta-theta)*rbinom(1,1,alpha) } post[,j] - theta #print(post[,j]) } mean - apply(post,1,mean) ci - apply(post,1,quants) return(list(The Means = mean, The Corresponding Confidence Intervals = ci)) } quants - function(x){ lo - quantile(x,.025) hi - quantile(x,.975) return(c(lo,hi)) } (out - func(d,t,beta=1.5,lambda=rep(0.5,10),alpha=1.8,p.gamma=0.01,delta=1,B=100)) __ 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.
Re: [R] Displaying Results in Two Columns
You could find several good examples on the first several results here: http://www.google.com/search?sourceid=chromeie=UTF-8q=plot.ci+R Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Thu, Aug 19, 2010 at 2:47 AM, R Newbie help0938...@gmail.com wrote: Could I have some suggestions as to how (various ways) I can display my confidence interval results? rm(list = ls()) set.seed(1) func - function(d,t,beta,lambda,alpha,p.gamma,delta,B){ d - c(5,1,5,14,3,19,1,1,4,22) t - c(94.32,15.72,62.88,125.76,5.24,31.44,1.048,1.048,2.096,10.48) post - matrix(0, nrow = 11, ncol = B) theta - c(lambda,beta) beta.hat - 2.471546 for(j in 1:B){ for(i in 1:(B-1)){ c.lambda - rgamma(10,d+alpha,t+beta.hat) c.beta - rgamma(1,10*alpha+p.gamma,delta+sum(lambda)) c.theta - c(c.lambda,c.beta) pi.func - prod((c.lambda/lambda)^(d+alpha-1)*exp(-t*(c.lambda-lambda)))*(c.beta/beta)^(10*alpha+p.gamma-1)*exp(-c.beta*(delta+sum(c.lambda))+beta*(delta+sum(lambda))) g.x - prod((beta.hat+t)^(alpha+d)*lambda^(alpha+d-1)*exp(-lambda*(beta.hat+t))/gamma(alpha+d))*(sum(lambda)+delta)^(p.gamma+10*alpha)*beta^(p.gamma+10*alpha-1)*exp(-beta*(sum(lambda)+delta))/gamma(p.gamma+10*alpha) g.y - prod((beta.hat+t)^(alpha+d)*c.lambda^(alpha+d-1)*exp(-lambda*(beta.hat+t))/gamma(alpha+d))*(sum(c.lambda)+delta)^(p.gamma+10*alpha)*c.beta^(p.gamma+10*alpha-1)*exp(-c.beta*(sum(c.lambda)+delta))/gamma(p.gamma+10*alpha) a - pi.func*(g.x/g.y) if(a1){ theta-c.theta } else theta - theta+(c.theta-theta)*rbinom(1,1,alpha) } post[,j] - theta #print(post[,j]) } mean - apply(post,1,mean) ci - apply(post,1,quants) return(list(The Means = mean, The Corresponding Confidence Intervals = ci)) } quants - function(x){ lo - quantile(x,.025) hi - quantile(x,.975) return(c(lo,hi)) } (out - func(d,t,beta=1.5,lambda=rep(0.5,10),alpha=1.8,p.gamma=0.01,delta=1,B=100)) __ 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. [[alternative HTML version deleted]] __ 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] displaying results
Hi everyone, can anyone tell me how i can change how i display mean(age), i want it to say The mean age of patients within the sample is mean(age) -- View this message in context: http://www.nabble.com/displaying-results-tp23558890p23558890.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.
Re: [R] displaying results
Read the posting guide please. Self-contained, minimal, reproducible code. On Fri, May 15, 2009 at 8:33 AM, deanj2k dl...@le.ac.uk wrote: Hi everyone, can anyone tell me how i can change how i display mean(age), i want it to say The mean age of patients within the sample is mean(age) -- View this message in context: http://www.nabble.com/displaying-results-tp23558890p23558890.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. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ 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.
Re: [R] displaying results
Absolutely no idea what you mean, Try reconstructing your question in concise English with reproducible code. Simon. - Original Message - From: deanj2k dl...@le.ac.uk To: r-help@r-project.org Sent: Friday, May 15, 2009 1:33 PM Subject: [R] displaying results Hi everyone, can anyone tell me how i can change how i display mean(age), i want it to say The mean age of patients within the sample is mean(age) -- View this message in context: http://www.nabble.com/displaying-results-tp23558890p23558890.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-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.
Re: [R] displaying results
On 5/15/2009 8:33 AM, deanj2k wrote: Hi everyone, can anyone tell me how i can change how i display mean(age), i want it to say The mean age of patients within the sample is mean(age) I think you want something like this: cat(sprintf(The mean age of patients within the sample is %.1f.\n, mean(age))) Play with the %.1f format for more decimal places, etc. Duncan Murdoch __ 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.
Re: [R] displaying results
Duncan Murdoch wrote: On 5/15/2009 8:33 AM, deanj2k wrote: Hi everyone, can anyone tell me how i can change how i display mean(age), i want it to say The mean age of patients within the sample is mean(age) I think you want something like this: cat(sprintf(The mean age of patients within the sample is %.1f.\n, mean(age))) or maybe cat(sprintf(The mean age of patients within the sample is %.1f.\n, round(mean(age), 1))) Play with the %.1f format for more decimal places, etc. ... and be aware of excel bugs. vQ __ 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.