DOC PREVIEW
PSU STAT 401 - Linear Regression

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Explaining CIsCIs and Tests for ProportionsHomework Lab ActivityCIs, Hypothesis Tests for the Mean, and PIsHomework Lab ActivityCIs, Hypothesis testing, and PIs in RegressionHomework Lab ActivitySupplement to Reading Data in ROutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RLab5: CIs, PIs, and Hypothesis Testing for:Proportions, Means and Linear RegressionM. George AkritasM. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RExplaining CIsCIs and Tests for ProportionsHomework Lab ActivityCIs, Hypothesis Tests for the Mean, and PIsHomework Lab ActivityCIs, Hypothesis testing, and PIs in RegressionHomework Lab ActivitySupplement to Reading Data in RM. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RIEach CI is a Bernoulli trial: It either contains the trueparameter value or not. After the CI is constructed, we talkabout how ”confident” we are that it contains the true value.The following commands generate the figure in the next slide:m = 50; n=20; p = .5 # toss 20 coins 50 timesphat = rbinom(m,n,p)/n # divide by n for proportionsSE = sqrt(phat*(1-phat)/n) # compute SEalpha = 0.10; zstar = qnorm(1-alpha/2) # compute zα/2matplot(rbind(phat - zstar*SE, phat + zstar*SE),rbind(1:m,1:m),type=”l”,lty=1)abline(v=p) # draw vertical line at p=0.5M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in R0.2 0.4 0.6 0.80 10 20 30 40 50End points of CIsCI countFigure: 50 CIs for p.M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RHomework Lab ActivityR command for Z-intervals for a proportionIWith T being the number of ”successes” in n trials, set”phat=T/n” and use the commandsphat ± qnorm(0.975)*sqrt(phat*(1-phat)/n)to obtain the 95% CI for p, i.e. the pair of valuesbp ± z0.025qbp(1−bp)n.ITo obtain 90% or other CIs, adjust the 0.975 in the abovecommand accordingly.M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RHomework Lab ActivityAlternative CIs and Hypothesis TestingIWith x being the binomial count, the command”prop.test(x,n)” is equivalent to the following:”prop.test(x,n,p=0.5,alternative=”two.sided”,conf.level=0.95,correct=TRUE)”It gives the p-value for testing H0: p = 0.5 against thetwo-sided alternative, a 95% CI for p, andbp.ITry ”prop.test(16,20)”. Also try ”prop.test(16,20,p=0.6)”which does the same except it tests H0: p = 0.6.IFor one-sided alternatives, use alternative = ”less” andalternative = ”greater”. But it will return one-sided CIs.IThe default ”correct=TRUE” is for continuity correction.M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RHomework Lab ActivityIs there evidence that the proportion p of men who are taller than6ft is greater than 0.3? Using the fathers’ heights in the data sethttp://sites.stat.psu.edu/~mga/401/Data/FatherSonHeights.txt, test at α = 0.05, and report the p value.Also construct a 95% CI. [Include the R commands and R outputwith your answer (Copy it from the R console and paste it).]Additional R help:ITo get the binomial count x (i.e. the number of fathers’heights that are > 72), put the data in the data frame ”ht”using, e.g. ”ht=read.clipboard()” after copying the data (seesupplement in the end of this file) and do:x1=ht$F H; x=sum((x1>72))M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RHomework Lab ActivityR command for the T-test and T-interval for the meanIWith x containing the data set, the command ”t.test(x)” isequivalent to the following:”t.test(x,mu=0,alternative=”two.sided”,conf.level=0.95)”It gives the t-statistic (TH0), the df, the p-value for testingH0: µ = 0 against the two-sided alternative, the 95% CI forµ, and X .ITo do the same except test H0: µ = µ0, e.g. H0: µ = 8.5,replace ”mu=0” by ”mu=8.5”, or use”xc = x-8.5; t.test(xc)”IFor one-sided alternatives, use alternative = ”less” andalternative = ”greater”. But again it will return one-sided CIs.M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RHomework Lab ActivityCIs and PIs through ”lm”I”confint(lm(x ∼ 1), level=0.9)” is an alternative way ofgetting the 90% CI for µ.I”predict(lm(x ∼ 1), interval=”predict”,level=0.9)” will give a90% PI for a new observation, but will do so n times.Alternatively, use:x2=rep(1,length(x))newx=data.frame(x2=1)predict(lm(x ∼ -1+ x2),newx, interval=”predict”,level=0.9)M. George Akritas Lab5: CIs, PIs, and Hypothesis Testing for: Proportions, Means and Linear RegressionOutlineExplaining CIsCIs and Tests for ProportionsCIs, Hypothesis Tests for the Mean, and PIsCIs, Hypothesis testing, and PIs in RegressionSupplement to Reading Data in RHomework Lab Activity1. Is there evidence


View Full Document
Download Linear Regression
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 Linear Regression 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 Linear Regression 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?