Prev: loop for with plot
Next: Styling single bar in BarChart
From: Canopus56 on 30 May 2010 06:47 I am taking an intro to stats class and am trying to learn some Mathematica functions related to basic statistics. I would like to use Mathematica to calculate exact values and inverse values from the standard normal table and Student's t distribution table. For example, the following returns the cdf equvialent to standard normal distribution table for a known mu, sigma (STD) and target x-bar: (1 - CDF[NormalDistribution[187000, 2181.9716], 190000]) The following returns the two-sided t-distribution value for a known z-statistic: StudentTPValue[-0.1373, 6, TwoSided -> True] Q1) How do I get the inverse of these, which the equivalent of reading a cdf table and a t-distribution table backwards, i.e. - a) Given a cdf, how do I return the z-statistic from a standard normal distribution? b) Given a P-Value and sampling distribution size, how did I return the z-star critical test value? Thanks - Kurt
From: Canopus56 on 30 May 2010 23:45 Thanks, Bob. That does the trick. Are there no built-in functions for the three of four common tasks of pulling z and P-values out of normal and Student's t tables? - Kurt dist == NormalDistribution[0, 1]; CDF[dist, 1.960] 0.975002 InverseCDF[dist, %] 1.96 Needs["HypothesisTesting`"] StudentTPValue[1.960, 100000, TwoSided -> True] TwoSidedPValue -> 0.0499986 Abs[InverseCDF[StudentTDistribution[100000], (TwoSidedPValue/2) /. %]] 1.96 Abs[InverseCDF[StudentTDistribution[10], 0.05]] 1.81246 ----- Original Message ---- From: Bob Hanlon <hanlonr(a)cox.net> To: Canopus56 <canopus56(a)yahoo.com>; mathgroup(a)smc.vnet.net Sent: Sun, May 30, 2010 8:35:58 AM Subject: Re: Basic normal and t table questions Use InverseCDF dist == NormalDistribution[187000, 2181.9716]; 1 - CDF[dist, 190000] 0.0845807 InverseCDF[dist, 1 - %] 190000. Needs["HypothesisTesting`"] StudentTPValue[-0.1373, 6, TwoSided -> True] TwoSidedPValue->0.895285 InverseCDF[StudentTDistribution[6], (1 - TwoSidedPValue/2) /. %] 0.1373 Since it is two-sided, the sign is meaningless Bob Hanlon ---- Canopus56 <canopus56(a)yahoo.com> wrote: ========================== I am taking an intro to stats class and am trying to learn some Mathematica= functions related to basic statistics. I would like to use Mathematica to calculate exact values and inverse value= s from the standard normal table and Student's t distribution table. For example, the following returns the cdf equvialent to standard normal di= stribution table for a known mu, sigma (STD) and target x-bar: (1 - CDF[NormalDistribution[187000, 2181.9716], 190000]) The following returns the two-sided t-distribution value for a known z-stat= istic: StudentTPValue[-0.1373, 6, TwoSided -> True] Q1) How do I get the inverse of these, which the equivalent of reading a cd= f table and a t-distribution table backwards, i.e. - a) Given a cdf, how do I return the z-statistic from a standard normal dist= ribution? b) Given a P-Value and sampling distribution size, how did I return the z-s= tar critical test value? Thanks - Kurt
From: Barrie Stokes on 30 May 2010 23:47 Hi Kurt In[46]:= Off[ Solve::"ifun" ] sol = Solve[ (1 - CDF[NormalDistribution[0, 1], z]) == 0.025, z ][[1]] Out[47]= {z -> 1.95996} In[48]:= z95 = z /. sol Out[48]= 1.95996 Thus: In[49]:= pValue2Sided = 2*(1 - CDF[NormalDistribution[0, 1], z95]) Out[49]= 0.05 And: In[50]:= zScore = Quantile[ NormalDistribution[ 0, 1 ], pValue2Sided/2 ] {zScore, -zScore} Out[50]= -1.95996 Out[51]= {-1.95996, 1.95996} In[52]:= Off[ Solve::"ifun" ] sol = Solve[ (1 - CDF[NormalDistribution[0, 1], z]) == 0.05, z ][[1]] Out[53]= {z -> 1.64485} In[54]:= z90 = z /. sol Out[54]= 1.64485 Thus In[55]:= pValue2Sided = 2*(1 - CDF[NormalDistribution[0, 1], z90]) Out[55]= 0.1 In[56]:= zScore = Quantile[ NormalDistribution[ 0, 1 ], pValue2Sided/2 ] {zScore, -zScore} Out[56]= -1.64485 Out[57]= {-1.64485, 1.64485} Cheers Barrie >>> On 30/05/2010 at 8:48 pm, in message <201005301048.GAA29139(a)smc.vnet.net>, Canopus56 <canopus56(a)yahoo.com> wrote: > I am taking an intro to stats class and am trying to learn some Mathematica > functions related to basic statistics. > > I would like to use Mathematica to calculate exact values and inverse values > from the standard normal table and Student's t distribution table. > > For example, the following returns the cdf equvialent to standard normal > distribution table for a known mu, sigma (STD) and target x-bar: > > (1 - CDF[NormalDistribution[187000, 2181.9716], 190000]) > > The following returns the two-sided t-distribution value for a known > z-statistic: > > StudentTPValue[-0.1373, 6, TwoSided -> True] > > Q1) How do I get the inverse of these, which the equivalent of reading a cdf > table and a t-distribution table backwards, i.e. - > > a) Given a cdf, how do I return the z-statistic from a standard normal > distribution? > > b) Given a P-Value and sampling distribution size, how did I return the z-star > critical test value? > > Thanks - Kurt
From: Bob Hanlon on 30 May 2010 23:48 Use InverseCDF dist = NormalDistribution[187000, 2181.9716]; 1 - CDF[dist, 190000] 0.0845807 InverseCDF[dist, 1 - %] 190000. Needs["HypothesisTesting`"] StudentTPValue[-0.1373, 6, TwoSided -> True] TwoSidedPValue->0.895285 InverseCDF[StudentTDistribution[6], (1 - TwoSidedPValue/2) /. %] 0.1373 Since it is two-sided, the sign is meaningless Bob Hanlon ---- Canopus56 <canopus56(a)yahoo.com> wrote: ============= I am taking an intro to stats class and am trying to learn some Mathematica functions related to basic statistics. I would like to use Mathematica to calculate exact values and inverse values from the standard normal table and Student's t distribution table. For example, the following returns the cdf equvialent to standard normal distribution table for a known mu, sigma (STD) and target x-bar: (1 - CDF[NormalDistribution[187000, 2181.9716], 190000]) The following returns the two-sided t-distribution value for a known z-statistic: StudentTPValue[-0.1373, 6, TwoSided -> True] Q1) How do I get the inverse of these, which the equivalent of reading a cdf table and a t-distribution table backwards, i.e. - a) Given a cdf, how do I return the z-statistic from a standard normal distribution? b) Given a P-Value and sampling distribution size, how did I return the z-star critical test value? Thanks - Kurt
From: Bill Rowe on 1 Jun 2010 04:19 On 5/30/10 at 6:48 AM, canopus56(a)yahoo.com (Canopus56) wrote: >I would like to use Mathematica to calculate exact values and >inverse values from the standard normal table and Student's t >distribution table. >For example, the following returns the cdf equvialent to standard >normal distribution table for a known mu, sigma (STD) and target >x-bar: >(1 - CDF[NormalDistribution[187000, 2181.9716], 190000]) >The following returns the two-sided t-distribution value for a known >z-statistic: >StudentTPValue[-0.1373, 6, TwoSided -> True] >Q1) How do I get the inverse of these, which the equivalent of >reading a cdf table and a t-distribution table backwards, i.e. - >a) Given a cdf, how do I return the z-statistic from a standard >normal distribution? >b) Given a P-Value and sampling distribution size, how did I return >the z-star critical test value? The inverse function to CDF in Mathematica is Quantile. Using your first example, I can do as follows: In[39]:= p = (1 - CDF[NormalDistribution[187000, 2181.9716], 190000]) Out[39]= 0.0845807 In[40]:= zscore = Quantile[NormalDistribution[], 1 - p] Out[40]= 1.3749 The standard z-score. And to show Quantile is the inverse function to CDF In[41]:= Quantile[NormalDistribution[187000, 2181.9716], 1 - p] Out[41]= 190000. or using the computed zscore In[42]:= zscore 2181.9716 + 187000 Out[42]= 190000. Quantile also solves the second problem as well. But here you need to understand what is being done after loading HypothesisTesting and using StudentTPValue First, doing In[43]:= StudentTPValue[-0.1373, 6, TwoSided -> True] Out[43]= TwoSidedPValue->0.895285 and doing In[45]:= p = 2 CDF[StudentTDistribution[6], -0.1373] Out[45]= 0.895285 results in the same p-Value. So, In[46]:= Quantile[StudentTDistribution[6], p/2] Out[46]= -0.1373 gives the desired result
|
Pages: 1 Prev: loop for with plot Next: Styling single bar in BarChart |