講解:Econ 325奋献、Limit Theorem健霹、R、RJava|Prolog

Econ 325 (004)Winter Session, Term 1, 2019M. VaneyLab 2 - Demonstration of the Central Limit TheoremDue: Monday November 25. Submit your work online.PurposeIn this lab R is used to demonstrate the Central Limit Theorem, a theorem that provides atheoretical basis for estimation and inference even for underlying populations that are notnormally distributed. The lab reinforces the use of .do ?les as an e¢ cient way to execute aseries of commands and the use of loops to automate repetitive tasks. The lab also introducesa few additional R commands.Central Limit TheoremGiven a random sample of size n from underlying distribution f(x) with 1(?nite mean) and 0 approximately normal with X. This can also be expressed as limn!1 X.One implication of this for estimation is that even if the underlying distribution is not normallydistributed, by appealing to the Central Limit Theorem we may treat the sample mean,X?n; as an approximately normally distributed random variable. The following ?gure showsthe underlying distribution of a random variable X as a solid line. Clearly X is not normallydistributed. The random variable X has realizations only over the interval [0; 3] rather than(1;1);X is not symmetric, X is not uni-modal. However, taking random samples ofsize n and computing the sample mean for each di§erent random sample we see that thedistribution of the sample mean (red dashed line) has many of the features characteristic ofa normally distributed random variable (uni-modal, symmetric, bell-shaped).How closely the sample mean conforms to a normal distribution will depend on features ofthe underlying distribution and the sample size. The larger the sample size the more closelythe distribution of the sample mean will resemble a normally distributed random variable.Data and MethodologyA number of ?populationsíare provided. In order to demonstrate the CLT it will be necessaryto describe the distribution of the sample mean for each of the populations.DataThe ?le lab2-variables.csv contains N = 700 observations for each of 5 random variables(called x1; : : : ; x5). Each of these can be thought of as a di§erent Population with a givenunderlying distribution f(x1); g(x2); : : : ; k(x5).MethodsUse R to carry out the following tasks:1. (a) Generate summary statistics and create histograms for each of the 5 variables.(b) Draw 1000 random samples of size n = 4; 25 and 144 for each of the randomvariables (without replacement). Compute the sample mean for each randomsample and construct a histogram of the sample means..R commandsThis lab will make use of some commands that are found two additional packages availablein R: dplyr and ggplot2. Both of these packages must be loaded in R. You can check tosee which packages are loaded by selecting the packages tab in the lower right corner of thescreen. If a package has not been installed in the console the following command can beentered:install.packages(ggplot2)the ggplot2 package will be installed (it may take a minute or two)In order to make use of the additional commands available in a package your script ?lemust refer to the packages through a library commnad. It is best to start the script withspeci?cation of the required packages:library(ggplot2)library(dplyr)The dplyr package has a number of commands that are useful for re-organizing data. Thecommand that we will use in this lab is sample_n(data, sample size)The ggplot2 package is used for making various graphs and ?gures. A very useful resourcefor creating histograms in ggplot2 can be found at the link provided in the Lab folder onCanvas.The sample_n() command will draw a single random sample (of rows of a dataset) of aspeci?c size, n. To generate 1000 random samples, sample_n() command along with a2command to take the mean can be embedded in the command replicate() which will repeatthese commands a speci?ed number of times.Results and DiscussionPresent and provide some discussion of the following:Submit your .do ?le for this lab. Do not submit raw data.1. (a) Consider the summary statistics and graphics for the underlying populations. Dothe underlying distributions appear to be Normally distributed? Comment onthe apparent distributions of each of the variables (symmetric, skewed, numberof modes,di§erence between mean and median, etc.).(b) Discuss how changing the size of the sample alters the distribution of the samplemean for each of the di§erent variables. Do the results conform with the predictionof the Central Limit Theorem?3轉(zhuǎn)自:http://www.daixie0.com/contents/18/4349.html

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末瓶蚂,一起剝皮案震驚了整個濱河市糖埋,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌窃这,老刑警劉巖阶捆,帶你破解...
    沈念sama閱讀 221,548評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異钦听,居然都是意外死亡洒试,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,497評論 3 399
  • 文/潘曉璐 我一進店門朴上,熙熙樓的掌柜王于貴愁眉苦臉地迎上來垒棋,“玉大人,你說我怎么就攤上這事痪宰〉鸺埽” “怎么了?”我有些...
    開封第一講書人閱讀 167,990評論 0 360
  • 文/不壞的土叔 我叫張陵衣撬,是天一觀的道長乖订。 經(jīng)常有香客問我,道長具练,這世上最難降的妖魔是什么乍构? 我笑而不...
    開封第一講書人閱讀 59,618評論 1 296
  • 正文 為了忘掉前任,我火速辦了婚禮扛点,結果婚禮上哥遮,老公的妹妹穿的比我還像新娘。我一直安慰自己眠饮,他們只是感情好,可當我...
    茶點故事閱讀 68,618評論 6 397
  • 文/花漫 我一把揭開白布铜邮。 她就那樣靜靜地躺著仪召,像睡著了一般松蒜。 火紅的嫁衣襯著肌膚如雪扔茅。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,246評論 1 308
  • 那天牍鞠,我揣著相機與錄音咖摹,去河邊找鬼。 笑死难述,一個胖子當著我的面吹牛萤晴,可吹牛的內(nèi)容都是我干的吐句。 我是一名探鬼主播,決...
    沈念sama閱讀 40,819評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼店读,長吁一口氣:“原來是場噩夢啊……” “哼嗦枢!你這毒婦竟也來了?” 一聲冷哼從身側響起屯断,我...
    開封第一講書人閱讀 39,725評論 0 276
  • 序言:老撾萬榮一對情侶失蹤文虏,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后殖演,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體氧秘,經(jīng)...
    沈念sama閱讀 46,268評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,356評論 3 340
  • 正文 我和宋清朗相戀三年趴久,在試婚紗的時候發(fā)現(xiàn)自己被綠了丸相。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,488評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡彼棍,死狀恐怖灭忠,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情座硕,我是刑警寧澤弛作,帶...
    沈念sama閱讀 36,181評論 5 350
  • 正文 年R本政府宣布,位于F島的核電站华匾,受9級特大地震影響映琳,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜瘦真,卻給世界環(huán)境...
    茶點故事閱讀 41,862評論 3 333
  • 文/蒙蒙 一刊头、第九天 我趴在偏房一處隱蔽的房頂上張望黍瞧。 院中可真熱鬧诸尽,春花似錦、人聲如沸印颤。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,331評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽年局。三九已至际看,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間矢否,已是汗流浹背仲闽。 一陣腳步聲響...
    開封第一講書人閱讀 33,445評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留僵朗,地道東北人赖欣。 一個月前我還...
    沈念sama閱讀 48,897評論 3 376
  • 正文 我出身青樓屑彻,卻偏偏與公主長得像,于是被迫代替她去往敵國和親顶吮。 傳聞我的和親對象是個殘疾皇子社牲,可洞房花燭夜當晚...
    茶點故事閱讀 45,500評論 2 359

推薦閱讀更多精彩內(nèi)容