t-distribution

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

t-distribution

Nair, Murlidharan T
If I have a calculated t can I get the probability associated with it
using an R function by giving it the df and t? I know I can do the whole
calculation using t.test() or get the t-distribution using qt().  If
t=1.11 and df =9 can I get the probability?

 

Thanks../Murli


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Leeds, Mark (IED)
if you mean the area to the left of the 1.11 point on the x axis of a t
dist with 9 degrees of freedom,
Then you need to use pt(1.11,9). See ?pt for more info.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Nair, Murlidharan
T
Sent: Wednesday, August 01, 2007 2:43 PM
To: [hidden email]
Subject: [R] t-distribution

If I have a calculated t can I get the probability associated with it
using an R function by giving it the df and t? I know I can do the whole
calculation using t.test() or get the t-distribution using qt().  If
t=1.11 and df =9 can I get the probability?

 

Thanks../Murli


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Daniel Nordlund
In reply to this post by Nair, Murlidharan T
?pt is what you want.

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Nair, Murlidharan T
> Sent: Wednesday, August 01, 2007 11:43 AM
> To: [hidden email]
> Subject: [R] t-distribution
>
> If I have a calculated t can I get the probability associated with it
> using an R function by giving it the df and t? I know I can do the whole
> calculation using t.test() or get the t-distribution using qt().  If
> t=1.11 and df =9 can I get the probability?
>
>
>
> Thanks../Murli
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Bill.Venables
In reply to this post by Nair, Murlidharan T
for the upper tail:

> 1-pt(1.11, 9)
[1] 0.1478873


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Nair, Murlidharan
T
Sent: Thursday, 2 August 2007 4:43 AM
To: [hidden email]
Subject: [R] t-distribution

If I have a calculated t can I get the probability associated with it
using an R function by giving it the df and t? I know I can do the whole
calculation using t.test() or get the t-distribution using qt().  If
t=1.11 and df =9 can I get the probability?

 

Thanks../Murli


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Ben Bolker
 <Bill.Venables <at> csiro.au> writes:

>
> for the upper tail:
>
> > 1-pt(1.11, 9)
> [1] 0.1478873
>
   wouldn't
     pt(1.11, 9, lower.tail=FALSE)
  be more accurate?

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Bill.Venables
Well, is "t = 1.11" all that accurate in the first place?  :-)

In fact, reading beween the lines of the original enquiry, what the
person probably wanted was something like

ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)

which is the two-sided t-test tail area.

The teller of the parable will usually leave some things unexplained...

Bill.


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:[hidden email]
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Ben Bolker
Sent: Thursday, 2 August 2007 4:57 AM
To: [hidden email]
Subject: Re: [R] t-distribution

 <Bill.Venables <at> csiro.au> writes:

>
> for the upper tail:
>
> > 1-pt(1.11, 9)
> [1] 0.1478873
>
   wouldn't
     pt(1.11, 9, lower.tail=FALSE)
  be more accurate?

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Nair, Murlidharan T
Indeed, this is what I wanted, I figured it from the function you and
Mark pointed me. Thank you both.

I am trying to plot it to illustrate the point and I tried this

plot(function(x) dt(x, df = 9), -5, 5, ylim = c(0, 0.5), main="t -
Density", yaxs="i")

Is there an easy way to shade the area under the curve?


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
[hidden email]
Sent: Wednesday, August 01, 2007 3:18 PM
To: [hidden email]; [hidden email]
Subject: Re: [R] t-distribution

Well, is "t = 1.11" all that accurate in the first place?  :-)

In fact, reading beween the lines of the original enquiry, what the
person probably wanted was something like

ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)

which is the two-sided t-test tail area.

The teller of the parable will usually leave some things unexplained...

Bill.


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:[hidden email]
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Ben Bolker
Sent: Thursday, 2 August 2007 4:57 AM
To: [hidden email]
Subject: Re: [R] t-distribution

 <Bill.Venables <at> csiro.au> writes:

>
> for the upper tail:
>
> > 1-pt(1.11, 9)
> [1] 0.1478873
>
   wouldn't
     pt(1.11, 9, lower.tail=FALSE)
  be more accurate?

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Ted.Harding
In reply to this post by Bill.Venables
On 01-Aug-07 19:18:05, [hidden email] wrote:

> Well, is "t = 1.11" all that accurate in the first place?  :-)
>
> In fact, reading beween the lines of the original enquiry, what the
> person probably wanted was something like
>
> ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)
>
> which is the two-sided t-test tail area.
>
> The teller of the parable will usually leave some things unexplained...
>
> Bill.

However: "Those who have ears to hear, let them hear!"
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[hidden email]>
Fax-to-email: +44 (0)870 094 0861
Date: 01-Aug-07                                       Time: 20:43:53
------------------------------ XFMail ------------------------------

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Henrique Dallazuanna
In reply to this post by Nair, Murlidharan T
see ?polygon function.

--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

On 01/08/07, Nair, Murlidharan T <[hidden email]> wrote:

>
> Indeed, this is what I wanted, I figured it from the function you and
> Mark pointed me. Thank you both.
>
> I am trying to plot it to illustrate the point and I tried this
>
> plot(function(x) dt(x, df = 9), -5, 5, ylim = c(0, 0.5), main="t -
> Density", yaxs="i")
>
> Is there an easy way to shade the area under the curve?
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> [hidden email]
> Sent: Wednesday, August 01, 2007 3:18 PM
> To: [hidden email]; [hidden email]
> Subject: Re: [R] t-distribution
>
> Well, is "t = 1.11" all that accurate in the first place?  :-)
>
> In fact, reading beween the lines of the original enquiry, what the
> person probably wanted was something like
>
> ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)
>
> which is the two-sided t-test tail area.
>
> The teller of the parable will usually leave some things unexplained...
>
> Bill.
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile:                         +61 4 8819 4402
> Home Phone:                     +61 7 3286 7700
> mailto:[hidden email]
> http://www.cmis.csiro.au/bill.venables/
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ben Bolker
> Sent: Thursday, 2 August 2007 4:57 AM
> To: [hidden email]
> Subject: Re: [R] t-distribution
>
> <Bill.Venables <at> csiro.au> writes:
>
> >
> > for the upper tail:
> >
> > > 1-pt(1.11, 9)
> > [1] 0.1478873
> >
>    wouldn't
>      pt(1.11, 9, lower.tail=FALSE)
>   be more accurate?
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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]]


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Stephen Tucker
In reply to this post by Nair, Murlidharan T
p <- seq(0.001,0.999,,1000)
x <- qt(p,df=9)
y <- dt(x,df=9)
plot(x,y,type="l")
polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),col="gray90")

Hope this helps.

ST


--- "Nair, Murlidharan T" <[hidden email]> wrote:

> Indeed, this is what I wanted, I figured it from the function you and
> Mark pointed me. Thank you both.
>
> I am trying to plot it to illustrate the point and I tried this
>
> plot(function(x) dt(x, df = 9), -5, 5, ylim = c(0, 0.5), main="t -
> Density", yaxs="i")
>
> Is there an easy way to shade the area under the curve?
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> [hidden email]
> Sent: Wednesday, August 01, 2007 3:18 PM
> To: [hidden email]; [hidden email]
> Subject: Re: [R] t-distribution
>
> Well, is "t = 1.11" all that accurate in the first place?  :-)
>
> In fact, reading beween the lines of the original enquiry, what the
> person probably wanted was something like
>
> ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)
>
> which is the two-sided t-test tail area.
>
> The teller of the parable will usually leave some things unexplained...
>
> Bill.
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile:                         +61 4 8819 4402
> Home Phone:                     +61 7 3286 7700
> mailto:[hidden email]
> http://www.cmis.csiro.au/bill.venables/ 
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ben Bolker
> Sent: Thursday, 2 August 2007 4:57 AM
> To: [hidden email]
> Subject: Re: [R] t-distribution
>
>  <Bill.Venables <at> csiro.au> writes:
>
> >
> > for the upper tail:
> >
> > > 1-pt(1.11, 9)
> > [1] 0.1478873
> >
>    wouldn't
>      pt(1.11, 9, lower.tail=FALSE)
>   be more accurate?
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Nair, Murlidharan T
How do I tell it to shade a particular region below the curve? Like the
one being computed below
ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)

Thanks ../Murli


-----Original Message-----
From: Stephen Tucker [mailto:[hidden email]]
Sent: Thursday, August 02, 2007 2:27 AM
To: Nair, Murlidharan T; [hidden email]
Subject: Re: [R] t-distribution

p <- seq(0.001,0.999,,1000)
x <- qt(p,df=9)
y <- dt(x,df=9)
plot(x,y,type="l")
polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),col="gray90")

Hope this helps.

ST


--- "Nair, Murlidharan T" <[hidden email]> wrote:

> Indeed, this is what I wanted, I figured it from the function you and
> Mark pointed me. Thank you both.
>
> I am trying to plot it to illustrate the point and I tried this
>
> plot(function(x) dt(x, df = 9), -5, 5, ylim = c(0, 0.5), main="t -
> Density", yaxs="i")
>
> Is there an easy way to shade the area under the curve?
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> [hidden email]
> Sent: Wednesday, August 01, 2007 3:18 PM
> To: [hidden email]; [hidden email]
> Subject: Re: [R] t-distribution
>
> Well, is "t = 1.11" all that accurate in the first place?  :-)
>
> In fact, reading beween the lines of the original enquiry, what the
> person probably wanted was something like
>
> ta <- pt(-1.11, 9) + pt(1.11, 9, lower.tail = FALSE)
>
> which is the two-sided t-test tail area.
>
> The teller of the parable will usually leave some things
unexplained...

>
> Bill.
>
>
> Bill Venables
> CSIRO Laboratories
> PO Box 120, Cleveland, 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):  +61 7 3826 7304
> Mobile:                         +61 4 8819 4402
> Home Phone:                     +61 7 3286 7700
> mailto:[hidden email]
> http://www.cmis.csiro.au/bill.venables/ 
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ben Bolker
> Sent: Thursday, 2 August 2007 4:57 AM
> To: [hidden email]
> Subject: Re: [R] t-distribution
>
>  <Bill.Venables <at> csiro.au> writes:
>
> >
> > for the upper tail:
> >
> > > 1-pt(1.11, 9)
> > [1] 0.1478873
> >
>    wouldn't
>      pt(1.11, 9, lower.tail=FALSE)
>   be more accurate?
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>



       
________________________________________________________________________
____________
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Richard M. Heiberger
In reply to this post by Nair, Murlidharan T
I believe you are looking for the functionality I have
in the norm.curve function in the HH package.

Download and install HH from CRAN and then look at

example(norm.curve)

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Nair, Murlidharan T

I tried doing it this way.

left<--2.3
right<-2.3
p <- seq(0.001,0.999,,1000)
x <- qt(p,df=9)
y <- dt(x,df=9)
plot(x,y,type="l")
x.tmp<-x
y.tmp<-y
a<-which(x<=left)
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))),col="gray90")
b<-which(x>=right)
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))),col="gray90")

Please let me know if I have made any mistakes.
Thanks ../Murli



-----Original Message-----
From: Richard M. Heiberger [mailto:[hidden email]]
Sent: Thu 8/2/2007 10:25 AM
To: Nair, Murlidharan T; Stephen Tucker; [hidden email]
Subject: Re: [R] t-distribution
 
I believe you are looking for the functionality I have
in the norm.curve function in the HH package.

Download and install HH from CRAN and then look at

example(norm.curve)

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Stephen Tucker
yes, or

p <- seq(0.001,0.999,,1000)
x <- qt(p,df=9)
y <- dt(x,df=9)
plot(x,y,type="l")

f <- function(x,y,...) {
  polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
}
with(data.frame(x,y)[x >= 2.3,],f(x,y,col="gray90"))
with(data.frame(x,y)[x <= -2.3,],f(x,y,col="gray90"))


--- "Nair, Murlidharan T" <[hidden email]> wrote:

>
> I tried doing it this way.
>
> left<--2.3
> right<-2.3
> p <- seq(0.001,0.999,,1000)
> x <- qt(p,df=9)
> y <- dt(x,df=9)
> plot(x,y,type="l")
> x.tmp<-x
> y.tmp<-y
> a<-which(x<=left)
>
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))),col="gray90")
> b<-which(x>=right)
>
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))),col="gray90")

>
> Please let me know if I have made any mistakes.
> Thanks ../Murli
>
>
>
> -----Original Message-----
> From: Richard M. Heiberger [mailto:[hidden email]]
> Sent: Thu 8/2/2007 10:25 AM
> To: Nair, Murlidharan T; Stephen Tucker; [hidden email]
> Subject: Re: [R] t-distribution
>  
> I believe you are looking for the functionality I have
> in the norm.curve function in the HH package.
>
> Download and install HH from CRAN and then look at
>
> example(norm.curve)
>
>



       
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Nair, Murlidharan T
I am trying to shade the critical regions for normal distribution with
different means and making overlaps of the plots to explain Type I and
Type II errors. I tried the following. If I calculate the z score and as
I did below, can I use it to pick regions from the original data? I
think I am making mistake by calculating the z scores for d$x, can
someone explain the mistake I am making?

left<- -1.96
right<- 1.96
mu1<-rnorm(100000,20,5)
d<-(density(mu1))
x.tmp<-d$x
y.tmp<-d$y
x<-x.tmp
y<-y.tmp
mu1z<-(x.tmp-mean(x.tmp))/sd(x.tmp) # is it correct?
a<-which(mu1z <=left)
b<-which(mu1z >=right)
plot(x.tmp,y.tmp, type="l")
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))
),col="gray90")
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))
),col="gray90")

-----Original Message-----
From: Stephen Tucker [mailto:[hidden email]]
Sent: Thursday, August 02, 2007 3:11 PM
To: Nair, Murlidharan T; [hidden email]
Subject: RE: [R] t-distribution

yes, or

p <- seq(0.001,0.999,,1000)
x <- qt(p,df=9)
y <- dt(x,df=9)
plot(x,y,type="l")

f <- function(x,y,...) {
  polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
}
with(data.frame(x,y)[x >= 2.3,],f(x,y,col="gray90"))
with(data.frame(x,y)[x <= -2.3,],f(x,y,col="gray90"))


--- "Nair, Murlidharan T" <[hidden email]> wrote:

>
> I tried doing it this way.
>
> left<--2.3
> right<-2.3
> p <- seq(0.001,0.999,,1000)
> x <- qt(p,df=9)
> y <- dt(x,df=9)
> plot(x,y,type="l")
> x.tmp<-x
> y.tmp<-y
> a<-which(x<=left)
>
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))
),col="gray90")
> b<-which(x>=right)
>
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))
),col="gray90")

>
> Please let me know if I have made any mistakes.
> Thanks ../Murli
>
>
>
> -----Original Message-----
> From: Richard M. Heiberger [mailto:[hidden email]]
> Sent: Thu 8/2/2007 10:25 AM
> To: Nair, Murlidharan T; Stephen Tucker; [hidden email]
> Subject: Re: [R] t-distribution
>  
> I believe you are looking for the functionality I have
> in the norm.curve function in the HH package.
>
> Download and install HH from CRAN and then look at
>
> example(norm.curve)
>
>



       
________________________________________________________________________
____________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Gregory Snow
Look at the power.examp and run.power.examp functions in the
TeachingDemos package.  Do these do what you want?  If not you can look
at the code in them to see how to fill part of the area under the curve.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
(801) 408-8111
 
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Nair,
> Murlidharan T
> Sent: Friday, August 03, 2007 8:46 AM
> To: Stephen Tucker; [hidden email]
> Subject: Re: [R] t-distribution
>
> I am trying to shade the critical regions for normal
> distribution with different means and making overlaps of the
> plots to explain Type I and Type II errors. I tried the
> following. If I calculate the z score and as I did below, can
> I use it to pick regions from the original data? I think I am
> making mistake by calculating the z scores for d$x, can
> someone explain the mistake I am making?
>
> left<- -1.96
> right<- 1.96
> mu1<-rnorm(100000,20,5)
> d<-(density(mu1))
> x.tmp<-d$x
> y.tmp<-d$y
> x<-x.tmp
> y<-y.tmp
> mu1z<-(x.tmp-mean(x.tmp))/sd(x.tmp) # is it correct?
> a<-which(mu1z <=left)
> b<-which(mu1z >=right)
> plot(x.tmp,y.tmp, type="l")
> polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
> y.tmp[a]))
> ),col="gray90")
> polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
> y.tmp[b]))
> ),col="gray90")
>
> -----Original Message-----
> From: Stephen Tucker [mailto:[hidden email]]
> Sent: Thursday, August 02, 2007 3:11 PM
> To: Nair, Murlidharan T; [hidden email]
> Subject: RE: [R] t-distribution
>
> yes, or
>
> p <- seq(0.001,0.999,,1000)
> x <- qt(p,df=9)
> y <- dt(x,df=9)
> plot(x,y,type="l")
>
> f <- function(x,y,...) {
>   polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
> }
> with(data.frame(x,y)[x >= 2.3,],f(x,y,col="gray90"))
> with(data.frame(x,y)[x <= -2.3,],f(x,y,col="gray90"))
>
>
> --- "Nair, Murlidharan T" <[hidden email]> wrote:
>
> >
> > I tried doing it this way.
> >
> > left<--2.3
> > right<-2.3
> > p <- seq(0.001,0.999,,1000)
> > x <- qt(p,df=9)
> > y <- dt(x,df=9)
> > plot(x,y,type="l")
> > x.tmp<-x
> > y.tmp<-y
> > a<-which(x<=left)
> >
> polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
> y.tmp[a]))
> ),col="gray90")
> > b<-which(x>=right)
> >
> polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
> y.tmp[b]))
> ),col="gray90")
> >
> > Please let me know if I have made any mistakes.
> > Thanks ../Murli
> >
> >
> >
> > -----Original Message-----
> > From: Richard M. Heiberger [mailto:[hidden email]]
> > Sent: Thu 8/2/2007 10:25 AM
> > To: Nair, Murlidharan T; Stephen Tucker; [hidden email]
> > Subject: Re: [R] t-distribution
> >  
> > I believe you are looking for the functionality I have in the
> > norm.curve function in the HH package.
> >
> > Download and install HH from CRAN and then look at
> >
> > example(norm.curve)
> >
> >
>
>
>
>        
> ______________________________________________________________
> __________
> ____________Ready for the edge of your seat?
> Check out tonight's top picks on Yahoo! TV.
> http://tv.yahoo.com/
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: t-distribution

Nair, Murlidharan T
Thanks, I figured it out after I realized my mistake here is the
corrected one. But I will certainly look at the teaching demos package.

left<- -1.96
right<- 1.96
mu1<-rnorm(100000,20,5)
d<-(density(mu1))
x.tmp<-d$x
y.tmp<-d$y
x<-x.tmp
y<-y.tmp
x.int1<-20 + (5*1.96)
x.int2<-20 - (5*1.96)
a<-which(x <=x.int2)
b<-which(x >=x.int1)
plot(x.tmp,y.tmp, type="l")
polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(y.tmp[a]))
),col="gray90")
polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(y.tmp[b]))
),col="gray90")

-----Original Message-----
From: Greg Snow [mailto:[hidden email]]
Sent: Friday, August 03, 2007 11:01 AM
To: Nair, Murlidharan T; Stephen Tucker; [hidden email]
Subject: RE: [R] t-distribution

Look at the power.examp and run.power.examp functions in the
TeachingDemos package.  Do these do what you want?  If not you can look
at the code in them to see how to fill part of the area under the curve.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
(801) 408-8111
 
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Nair,
> Murlidharan T
> Sent: Friday, August 03, 2007 8:46 AM
> To: Stephen Tucker; [hidden email]
> Subject: Re: [R] t-distribution
>
> I am trying to shade the critical regions for normal
> distribution with different means and making overlaps of the
> plots to explain Type I and Type II errors. I tried the
> following. If I calculate the z score and as I did below, can
> I use it to pick regions from the original data? I think I am
> making mistake by calculating the z scores for d$x, can
> someone explain the mistake I am making?
>
> left<- -1.96
> right<- 1.96
> mu1<-rnorm(100000,20,5)
> d<-(density(mu1))
> x.tmp<-d$x
> y.tmp<-d$y
> x<-x.tmp
> y<-y.tmp
> mu1z<-(x.tmp-mean(x.tmp))/sd(x.tmp) # is it correct?
> a<-which(mu1z <=left)
> b<-which(mu1z >=right)
> plot(x.tmp,y.tmp, type="l")
> polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
> y.tmp[a]))
> ),col="gray90")
> polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
> y.tmp[b]))
> ),col="gray90")
>
> -----Original Message-----
> From: Stephen Tucker [mailto:[hidden email]]
> Sent: Thursday, August 02, 2007 3:11 PM
> To: Nair, Murlidharan T; [hidden email]
> Subject: RE: [R] t-distribution
>
> yes, or
>
> p <- seq(0.001,0.999,,1000)
> x <- qt(p,df=9)
> y <- dt(x,df=9)
> plot(x,y,type="l")
>
> f <- function(x,y,...) {
>   polygon(x=c(x,rev(x)),y=c(y,rep(0,length(y))),...)
> }
> with(data.frame(x,y)[x >= 2.3,],f(x,y,col="gray90"))
> with(data.frame(x,y)[x <= -2.3,],f(x,y,col="gray90"))
>
>
> --- "Nair, Murlidharan T" <[hidden email]> wrote:
>
> >
> > I tried doing it this way.
> >
> > left<--2.3
> > right<-2.3
> > p <- seq(0.001,0.999,,1000)
> > x <- qt(p,df=9)
> > y <- dt(x,df=9)
> > plot(x,y,type="l")
> > x.tmp<-x
> > y.tmp<-y
> > a<-which(x<=left)
> >
> polygon(x=c(x.tmp[a],rev(x.tmp[a])),y=c(y.tmp[a],rep(0,length(
> y.tmp[a]))
> ),col="gray90")
> > b<-which(x>=right)
> >
> polygon(x=c(x.tmp[b],rev(x.tmp[b])),y=c(y.tmp[b],rep(0,length(
> y.tmp[b]))
> ),col="gray90")
> >
> > Please let me know if I have made any mistakes.
> > Thanks ../Murli
> >
> >
> >
> > -----Original Message-----
> > From: Richard M. Heiberger [mailto:[hidden email]]
> > Sent: Thu 8/2/2007 10:25 AM
> > To: Nair, Murlidharan T; Stephen Tucker; [hidden email]
> > Subject: Re: [R] t-distribution
> >  
> > I believe you are looking for the functionality I have in the
> > norm.curve function in the HH package.
> >
> > Download and install HH from CRAN and then look at
> >
> > example(norm.curve)
> >
> >
>
>
>
>        
> ______________________________________________________________
> __________
> ____________Ready for the edge of your seat?
> Check out tonight's top picks on Yahoo! TV.
> http://tv.yahoo.com/
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.