Unformatted text preview:

Misc RDescriptive StatisticsNumericalRelative standingVisualAssessing NormalityProbabilityDiscrete Random VariablesBinomial distributionPoisson distributionContinuous random variablesUniform distributionNormal distributiont-distribution2-distributionF-distributionSampling distributionsEstimationConfidence IntervalsCI Critical Values (two sided)Required sample sizeHypothesis Tests1-sample proportion1-sample mean ( known)1-sample mean ( unknown)2-sample proportion test2-sample mean test2-sample matched pairs testTest of homogeneity, test of independenceLinear RegressionLinear correlationModels in RRegressionPrediction IntervalsANOVAOne way ANOVALoading and using external data and tablesLoading excel dataLoading an .RData fileUsing tables of dataStatistics Quick ReferenceCard & R Commandsby Anthony Tanbakuchi. Version 1.8.2http://www.tanbakuchi.comANTHONY@TANBAKUCHI·COMGet R at: http://www.r-project.orgR commands: bold typewriter text1 Misc RTo make a vector / store data: x=c(x1, x2, ...)Help: general RSiteSearch("Search Phrase")Help: function ?functionNameGet column of data from table:tableName$columnNameList all variables: ls()Delete all variables: rm(list=ls())√x = sqrt(x) (1)xn= x∧n (2)n = length(x) (3)T = table(x) (4)2 Descriptive Statistics2.1 NUMERICALLet x=c(x1, x2, x3, ...)total =n∑i=1xi= sum(x) (5)min = min(x) (6)max = max(x) (7)six number summary : summary(x) (8)µ =∑xiN= mean(x) (9)¯x =∑xin= mean(x) (10)˜x = P50= median(x) (11)σ =s∑(xi−µ)2N(12)s =s∑(xi− ¯x)2n −1= sd(x) (13)CV =σµ=s¯x(14)2.2 RELATIVE STANDINGz =x −µσ=x − ¯xs(15)Percentiles:Pk= xi, (sorted x)k =i −0.5n·100% (16)To find xigiven Pk, i is:1. L = (k/100%)n2. if L is an integer: i = L + 0.5;otherwise i=L and round up.2.3 VISUALAll plots have optional arguments:• main="" sets title• xlab="", ylab="" sets x/y-axis label• type="p" for point plot• type="l" for line plot• type="b" for both points and linesEx: plot(x, y, type="b", main="My Plot")Plot Types:hist(x) histogramstem(x) stem & leafboxplot(x) box plotplot(T) bar plot, T=table(x)plot(x,y) scatter plot, x, y are ordered vectorsplot(t,y) time series plot, t, y are ordered vectorscurve(expr, xmin,xmax) plot expr involving x2.4 ASSESSING NORMALITYQ-Q plot: qqnorm(x); qqline(x)3 ProbabilityNumber of successes x with n possible outcomes.(Don’t double count!)P(A) =xAn(17)P(¯A) = 1 −P(A) (18)P(A or B) = P(A) + P(B) −P(A and B) (19)P(A or B) = P(A) + P(B) if A,B mut. excl. (20)P(A and B) = P(A) ·P(B|A) (21)P(A and B) = P(A) ·P(B) if A,B independent (22)n! = n(n −1)···1 = factorial(n) (23)nPk=n!(n −k)!Perm. no elem. alike (24)=n!n1!n2!···nk!Perm. n1alike, . . . (25)nCk=n!(n −k)!k!= choose(n,k) (26)4 Discrete Random VariablesP(xi) : probability distribution (27)E = µ =∑xi·P(xi) (28)σ =q∑(xi−µ)2·P(xi) (29)4.1 BINOMIAL DISTRIBUTIONµ = n · p (30)σ =√n · p ·q (31)P(x) =nCxpxq(n−x)= dbinom(x, n, p) (32)4.2 POISSON DISTRIBUTIONP(x) =µx·e−µx!= dpois(x, µ) (33)5 Continuous random variablesCDF F(x) gives area to the left of x, F−1(p) expects pis area to the left.f (x) : probability density (34)E = µ =Z∞−∞x · f (x ) dx (35)σ =rZ∞−∞(x −µ)2· f (x) dx (36)F(x) : cumulative prob. density (CDF) (37)F−1(x) : inv. cumulative prob. density (38)F(x) =Zx−∞f (x0)dx0(39)p = P(x < x0) = F(x0) (40)x0= F−1(p) (41)p = P(x > a) = 1 −F(a) (42)p = P(a < x < b) = F(b) −F(a) (43)5.1 UNIFORM DISTRIBUTIONp = P(u < u0) = F(u0)= punif(u’, min=0, max=1) (44)u0= F−1(p) = qunif(p, min=0, max=1) (45)5.2 NORMAL DISTRIBUTIONf (x) =1√2πσ2·e−12(x−µ)2σ2(46)p = P(z < z0) = F(z0) = pnorm(z’) (47)z0= F−1(p) = qnorm(p) (48)p = P(x < x0) = F(x0)= pnorm(x’, mean=µ, sd=σ) (49)x0= F−1(p)= qnorm(p, mean=µ, sd=σ) (50)5.3 t -DISTRIBUTIONp = P(t < t0) = F(t0) = pt(t’, df) (51)t0= F−1(p) = qt(p, df) (52)5.4 χ2-DISTRIBUTIONp = P(χ2< χ20) = F(χ20)= pchisq(X2’, df) (53)χ20= F−1(p) = qchisq(p, df) (54)5.5 F-DISTRIBUTIONp = P(F < F0) = F(F0)= pf(F’, df1, df2) (55)F0= F−1(p) = qf(p, df1, df2) (56)6 Sampling distributionsµ¯x= µ σ¯x=σ√n(57)µˆp= p σˆp=rpqn(58)7 Estimation7.1 CONFIDENCE INTERVALSproportion: ˆp ±E, E = zα/2·σˆp(59)mean (σ known): ¯x ±E, E = zα/2·σ¯x(60)mean (σ unknown, use s): ¯x ±E, E = tα/2·σ¯x, (61)d f = n −1variance:(n −1)s2χ2R< σ2<(n −1)s2χ2L, (62)d f = n −12 proportions: ∆ ˆp ±zα/2·rˆp1ˆq1n1+ˆp2ˆq2n2(63)2 means (indep): ∆ ¯x ±tα/2·ss21n1+s22n2, (64)d f ≈ min (n1−1, n2−1)matched pairs:¯d ±tα/2·sd√n, di= xi−yi, (65)d f = n −17.2 CI CRITICAL VALUES (TWO SIDED)zα/2= F−1z(1 −α/2) = qnorm(1-alpha/2) (66)tα/2= F−1t(1 −α/2) = qt(1-alpha/2, df) (67)χ2L= F−1χ2(α/2) = qchisq(alpha/2, df) (68)χ2R= F−1χ2(1 −α/2) = qchisq(1-alpha/2, df)(69)7.3 REQUIRED SAMPLE SIZEproportion: n = ˆp ˆqzα/2E2, (70)( ˆp = ˆq = 0.5 if unknown)mean: n =zα/2·ˆσE2(71)8 Hypothesis TestsTest statistic and R function (when available) are listed for each.Optional arguments for hypothesis tests:alternative="two.sided" can be:"two.sided", "less", "greater"conf.level=0.95 constructs a 95% confidence interval. Standard CIonly when alternative="two.sided".Optional arguments for power calculations & Type II error:alternative="two.sided" can be:"two.sided" or "one.sided"sig.level=0.05 sets the significance level α.8.1 1-SAMPLE PROPORTIONH0: p = p0prop.test(x, n, p=p0, alternative="two.sided")z =ˆp − p0pp0q0/n(72)8.2 1-SAMPLE MEAN (σ KNOWN)H0: µ = µ0z =¯x −µ0σ/√n(73)8.3 1-SAMPLE MEAN (σ UNKNOWN)H0: µ = µ0t.test(x, mu=µ0, alternative="two.sided")Where x is a vector of sample data.t =¯x −µ0s/√n, d f = n −1 (74)Required Sample size:power.t.test(delta=h, sd =σ, sig.level=α, power=1 −β, type ="one.sample", alternative="two.sided")8.4 2-SAMPLE PROPORTION TESTH0: p1= p2or equivalently H0: ∆p = 0prop.test(x, n, alternative="two.sided")where: x=c(x1, x2) and n=c(n1, n2)z =∆ ˆp −∆p0q¯p ¯qn1+¯p ¯qn2, ∆ ˆp = ˆp1− ˆp2(75)¯p =x1+ x2n1+ n2, ¯q = 1 − ¯p (76)Required Sample size:power.prop.test(p1=p1, p2=p2, power=1 −β,sig.level=α, alternative="two.sided")8.5 2-SAMPLE MEAN TESTH0: µ1= µ2or equivalently H0: ∆µ = 0t.test(x1, x2, alternative="two.sided")where: x1 and x2 are vectors of sample 1 and sample 2 data.t =∆ ¯x −∆µ0rs21n1+s22n2d f ≈ min (n1−1, n2−1), ∆ ¯x = ¯x1− ¯x2(77)Required Sample


View Full Document

UA MATH 167 - Equation Sheet

Download Equation Sheet
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Equation Sheet and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Equation Sheet 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?