Example: quiz answers

simpleR Using R for Introductory Statistics

simpleR {UsingR forIntroductoryStatisticsJohnVerzani2000 04000060000800001200001600002e+054e+056e +058e+05ypageiPrefaceThesenotesareanintr oductionto to accompany anintroductorystatisticsbooksuch as Kitchens\ExploringStatistics". Thegoalsarenotto show allthefeaturesofR, or to replacea standardtextbook,butratherto be usedwitha textbooktoillustratethefeaturesofRthatca nbe learnedin a one-semester, take pedagogicalreasonstheequalssign,=, is usedas anassignment operatorandnotthetraditionalarrow combination<-. Thiswas addedtoRin onlyanolderversionis availablethereaderwillhave to make dataandfunctionsin thistextthatneedto be installedpriorto easy, ,youneedtodownloadthe\zip" le, andtheninstallfromthe\packages" ,oneusesthecommandR Someof in thehelp availableas anRpackagefrom: necessary, the lecansent in ,theindividualdatasetscanbe foundonlinein thesenotesandwerelastgeneratedonAugust22 , ,youshouldcheck forthemostrecent versionavailablefromtheCSIM}

simpleR { Using R for Introductory Statistics John Verzani 20000 40000 60000 80000 120000 160000 2e+05 4e+05 6e+05 8e+05 y

Tags:

  Using, Statistics, Introductory, Using r for introductory statistics

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of simpleR Using R for Introductory Statistics

1 simpleR {UsingR forIntroductoryStatisticsJohnVerzani2000 04000060000800001200001600002e+054e+056e +058e+05ypageiPrefaceThesenotesareanintr oductionto to accompany anintroductorystatisticsbooksuch as Kitchens\ExploringStatistics". Thegoalsarenotto show allthefeaturesofR, or to replacea standardtextbook,butratherto be usedwitha textbooktoillustratethefeaturesofRthatca nbe learnedin a one-semester, take pedagogicalreasonstheequalssign,=, is usedas anassignment operatorandnotthetraditionalarrow combination<-. Thiswas addedtoRin onlyanolderversionis availablethereaderwillhave to make dataandfunctionsin thistextthatneedto be installedpriorto easy, ,youneedtodownloadthe\zip" le, andtheninstallfromthe\packages" ,oneusesthecommandR Someof in thehelp availableas anRpackagefrom: necessary, the lecansent in ,theindividualdatasetscanbe foundonlinein thesenotesandwerelastgeneratedonAugust22 , ,youshouldcheck forthemostrecent versionavailablefromtheCSIM athdepartment ( ).}

2 Copyrightc ..1A noteonnotation..1 Data1 StartingR..1 Enteringdatawithc..2 Datais avector..3 Problems..7 UnivariateData8 Categoricaldata..8 Numericaldata.. 10 Problems.. 18 BivariateData19 Handlingbivariatecategoricaldata.. 20 .. 21 .. 24 Problems.. 31 MultivariateData32 Storingmultivariatedatain dataframes.. 32 Accessingdatain dataframes.. 33 Manipulatingdataframes:stackandunstack.. 34 UsingR's modelformulanotation.. 35 Ways to viewmultivariatedata.. 35 Thelatticepackage.. 40 Problems.. 40simpleR{ UsingRforIntroductoryStatisticspageiiRan domData41 Randomnumber generatorsinR{ the\r" .. 41 Problems.. 46 Simulations47 Thecentrallimittheorem.}}

3 49 Problems.. 51 ExploratoryDataAnalysis54 Ourtoolbox .. 54 Examples.. 54 Problems.. 58 Con denceInterval Estimation59 Populationproportiontheory.. 59 Proportiontest.. 61 Thez-test.. 62 Thet-test.. 62 Con denceinterval forthemedian.. 64 Problems.. 65 HypothesisTesting66 Testinga populationparameter.. 66 Testinga mean.. 67 Testsforthemedian.. 67 Problems.. 68 Two-sampletests68 Two-sampletestsof proportion.. 68 Two-samplet-tests.. 69 Resistant two-sampletests.. 71 Problems.. 71 ChiSquareTests72 Thechi-squareddistribution.. 72 Chi-squaredgoodnessof t tests.. 72 Chi-squaredtestsof independence.. 74 Chi-squaredtestsforhomogeneity.

4 75 Problems.. 76 RegressionAnalysis77 Simplelinearregressionmodel.. 77 Testingtheassumptionsof themodel.. 78 Statisticalinference.. 79 Problems.. 83 MultipleLinearRegression84 Themodel.. 84 Problems.. 89 Analysisof Variance89one-way analysisof variance.. 89 Problems.. 92 Appendix:InstallingR94 Appendix:ExternalPackages94 Appendix:A sampleR session94A samplesessioninvolvingregression.. 94t-tests.. 97A simulationexample.. 99simpleR{ UsingRforIntroductoryStatisticspageiiiAp pendix:WhathappenswhenR starts?100 Appendix:UsingFunctions100 Thebasictemplate.. 100 For loops.. 102 Conditionalexpressions.. 103 Appendix:EnteringDataintoR103 Usingc.}

5 104usingscan.. 104 Usingscanwitha le.. 104 Editingyourdata.. 104 Readingin tablesof data.. 105 Fixed-width elds.. 105 Spreadsheetdata.. 105 XML,urls.. 106\Foreign"formats.. 106 Appendix:TeachingTricks106 Appendix:Sourcesof help,documentation107simpleR{ UsingRforIntroductoryStatisticsDatapage1 Section1: IntroductionWhatisRThesenotesdescribe how to to allow this nesoftwareto be usedin "lower-level"courseswhereoftenMINITAB,SP SS,Excel, is expectedthatthereaderhashadat leasta is thehope, thatstudents shownhow to useRat thisearlylevel willbetterunderstandthestatisticalissues andwillultimatelybene tfromthemoresophisticatedprogramdespitei tssteeper\learningcurve".}

6 Thebene tsofRforanintroductorystudent are Ris open-sourceandrunsonUNIX,WindowsandMacin tosh. Rhasanexcellent built-inhelpsystem. Rhasexcellent graphingcapabilities. Students caneasilymigrateto thecommerciallysupportedS-Plusprogramif commercialsoftwareis desired. R's languagehasa powerful,easyto learnsyntaxwithmany built-instatisticalfunctions. Thelanguageis easyto extendwithuser-writtenfunctions. Ris a programmersit willfeelmorefamiliarthanothersandfornewc omputerusers,thenextleapto programmingwillnotbe so othersoftwaresolutions? It hasa limitedgraphicalinterface(S-Plushasa good one).Thismeans,it canbe harderto learnat theoutset. Thereis nocommercialsupport.

7 (Althoughonecanarguetheinternationalmail inglistis evenbetter) Thecommandlanguageis a programminglanguageso students mustlearnto anopen-source(GPL)statisticalenvironment modeledafterS andS-Plus( ).TheS languagewas developed in thelate1980sat AT& startedby RobertGentlemanandRossIhaka of theStatisticsDepartment of theUniversity of Aucklandin hasquicklygaineda is currentlymaintainedby theRcore-development team,a hard-working, themainsiteforinformationonR. At thissitearedirectionsforobtainingthesoft ware,accompanyingpackagesandothersources of noteonnotationA fewtypographicalconventionsareusedin erent fonts forurls,R commands,datasetnamesanddi erent typesettingforlongersequencesof R : DataStatisticsis thestudyof to startR, the rstthingwe needto be ableto dois learnhowto enterdataintoRandhow to { UsingRforIntroductoryStatisticsDatapage2 Ris mosteasilyusedin aninteractive a questionandRgives startupR's commandlineyoucandothefollowing:in Windows ndtheRiconanddoubleclick, onUnix,fromthecommandlinetypeR.}

8 Otheroperatingsystemsmay have di started,youshouldbe greetedwitha commandsimilartoR : Copyright2001,The R (2001-12-19)R is freesoftwareand comeswithABSOLUTELYNO are welcometo redistributeit `license()'or `licence()'for is a `contributors()'for `demo()'for somedemos,`help()'for on-linehelp,or` ()'for a HTML browserinterfaceto `q()'to quitR.[Previouslysavedworkspacerestored] >The>is calledtheprompt. In whatfollowsbelow it is nottyped,butis usedto indicatewhereyouareto type ifyoufollow a commandis too longto t ona line,a+is smalldatasetsis , ,supposewe have thefollowingcount of thenumber of typos per pageof thesenotes:2 3 0 3 1 0 0 1To enterthisinto anRsessionwe doso with> typos= c(2,3,0,3,1,0,0,1)> typos[1] 2 3 0 3 1 0 0 1 Noticea fewthings We assignedthevaluesto a variablecalledtypos Theassignment operatoris a=.

9 Thisis validas was (andstillcanbe) a< used,although,youshouldlearnoneandstick withit. Thevalueof thetyposdoesn'tautomaticallyprint does whenwe type justthenamethoughas thelastinputlineindicates Thevalueof typos is prefacedwitha funny looking[1]. Thisindicatesthatthevalueis avector. many implementationsofRyoucansave yourselfa lotof typingif youlearnthatthearrow keyscanbe usedto retrieve particular,each commandis storedin a historyandtheuparrow willtraversebackwardsalongthishistoryand thedownarrow arrow keyswillworkas mousecanmake it quiteeasyto dosimpleeditingof functionRcomeswithmany builtin functionsthatonecanapplyto datasuch astypos.

10 Oneof themis themeanfunctionfor ndingthemeanor averageof useit is easysimpleR{ UsingRforIntroductoryStatisticsDatapage3 > mean(typos)[1] ,we couldcallthemedian, orvarto ndthemedianor thesame{ thefunctionnamefollowed by parenthesesto containtheargument(s):> median(typos)[1] 1> var(typos)[1] avectorThedatais storedinRas avector. Thismeanssimplythatit keepstrack of theorderthatthedatais particularthereis a rstelement, a secondelement upto a lastelement. Thisis a good thingforseveralreasons: Oursimpledatavectortyposhasa naturalorder{ page1, page2 wouldn'twant to mixtheseup. We wouldlike to be ableto make changesto thedataitemby iteminsteadof havingto enterin theentiredatasetagain.}}}


Related search queries