講解:Mixed Model、R律罢、data膀值、RPython|SQL

Advanced Statistics with R: Mixed Model – ExamStarting: 25.02.2020 h 7.00 pm – Ending: 06.02.2020 h 7.00 pmThe exam consists in three datasets to analyze. Try to follow the subsequent indications to analyze the datasets, and then send back a .docx (or similar) file including:?(all) the lines of the script you run in R; ?the output for each line; ?the information requested for each dataset, indicated as Q1, Q2… within each datasetN.B.: remember to load the libraries lme4 and car (and other libraries if necessary), and remember to convert in factors the effects that are written as number but they should be treated as categoricalN.B.: if you prefer, you can directly modify this file for answering1.PinesThe dataset “pines.txt” consists of the tree volume (Volume: ft3/acre) of pine trees included within each one of the 4 plots (Block) considered in the loblolly pine midrotation fertilization experiment of Gumpertz and Brownie (1993; Can J For Res 23: 625-639). The data, reported in the following Table 1, included the tree volume after two years of experiment (years 4 and 6 not considered). Each block received two treatments, Nitrogen (N, 4 levels) and Phosphorous (P, 3 levels), as reported in Table 1. After imported the dataset in R, let’s write a mixed model (M1) considering the Volume as response variable and the main effects (= no interactions) of N, P and Block; (Q1): which effects are fixed and which is random?After run the summary of the model, let’s plot the residuals for checking the normality of distribution using a qqnorm or a qqPlot statistics.Let run an ANOVA on fixed effects; (Q2): what effect(s) is/are significant?Let’s write a second model, M2, also considering the interaction between N and P; run the summary, the ANOVA on fixed effects, and make a model comparison using the AIC statistics; (Q3): which is the model that fits better the data?Let’s write a third model, M3, by including all the previous effects of M2 as fixed, run the summary, the ANOVA, and compare the ANOVA results with the ones of M2; (Q4): do you find similar significances for fixed effects in models M2 and M3 (for the effects that were accounted in both); what model would you like to choose for analyzing your data (you can also look at model fitting)?2.GuppiesThe dataset “guppies.txt” includes the experimental measures about the sexual behavior of 224 male guppies (Poecilia reticulata). The behaviors were measured for 10 min for each male within experimental tanks, in which each male was put in front of a receptive female. Behaviors included the “Display”, a visual exhibition of the male in front of the female, and a sneaky attempt to mate called “GT”, both included in the dataset and measured in sec. The dataset also included the dams and the sires of each male guppy, that were mated foMixed Model作業(yè)代做、R程序設(shè)計作業(yè)調(diào)試误辑、代寫data課程作業(yè)沧踏、R編程語言作業(yè)調(diào)試 代寫Python編程|代做llowing the scheme in the picture: each sire was mated with two dams, and each dam had a number of offspring (the males, called “ID” in the dataset). This data structure allows to find out the heritability of the sexual behavior (the quote of the behavior that is transmitted to progeny).After imported the dataset in R, let’s write a mixed model (M1) for the “Display” behavior including the sire and the dam as random effects. Take care about the data structure: (Q1) which is the upper level effect? And which is the nested effect? (N.B. in this dataset both the upper level and the nested effect should be indicated as random effect). Then look at the summary and (Q2) calculate the heritability of Display as ratio of the sire (intercept) variance on the sum of all the variances for random effects (sire, dam and residual). N.B.: since there is a lot of residual variance, residuals of the model are partly without the range of the normal distribution and are correlated with observation. Moving from M1, let’s write a model M2 without including the dam effect, and compare the two models using AIC statistics and the likelihood ratio test: (Q3) which is the best fitted model? Does the introduction of the dam effect significantly improve the model fitting?Let’s run the same analyses but for “GT” behavior and compare the two models including the dam effect or not (M3 vs. M4); (Q4): does the introduction of the dam effect significantly improve the model fitting?3.Growth of tpr foalsThe dataset “growth_tpr.txt” includes the periodical measures of the body weight (weight) of 43 foals (ID, matr or name columns), 13 females and 30 males (sex effect) of the CAITPR breed. After arrived at experimental station at an average age of 14.1 days, the foals were fed two diets (diet: HP: high protein, 21 foals; LP: low protein, 22 foals) and measured 7 times, every 4-5 weeks (date_num). The experiment is aimed to look if a reduction of protein in diet (LP) is able to provide the same growth of the normal diet (HP), in both sexes. The following table summarizes the data structure:Let’s write a mixed model (M1) including the body weight of the foals as response variable (y) and the fixed effects of diet, sex, date_num and the random effect of ID.Run the summary and the ANOVA on fixed effects; (Q1): what effects are significant? Does the protein reduction affect the growth of the foals?Let’s write a further mixed model (M2) by including the date_num also as random slope for each individual (ID), run the summary and the ANOVA on fixed effects; (Q2): do you find some differences?Let’s compare M1 and M2 using model fitting statistics (AIC, likelihood ratio test); (Q3): what is the model that better fits the data?…please, let me know if anything is unclear or if you have some concerns;Thanks, have a good job!轉(zhuǎn)自:http://www.6daixie.com/contents/18/4976.html

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市巾钉,隨后出現(xiàn)的幾起案子翘狱,更是在濱河造成了極大的恐慌,老刑警劉巖砰苍,帶你破解...
    沈念sama閱讀 221,548評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件潦匈,死亡現(xiàn)場離奇詭異,居然都是意外死亡赚导,警方通過查閱死者的電腦和手機(jī)茬缩,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,497評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來辟癌,“玉大人寒屯,你說我怎么就攤上這事。” “怎么了寡夹?”我有些...
    開封第一講書人閱讀 167,990評論 0 360
  • 文/不壞的土叔 我叫張陵处面,是天一觀的道長。 經(jīng)常有香客問我菩掏,道長魂角,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,618評論 1 296
  • 正文 為了忘掉前任智绸,我火速辦了婚禮野揪,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘瞧栗。我一直安慰自己斯稳,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 68,618評論 6 397
  • 文/花漫 我一把揭開白布迹恐。 她就那樣靜靜地躺著挣惰,像睡著了一般。 火紅的嫁衣襯著肌膚如雪殴边。 梳的紋絲不亂的頭發(fā)上憎茂,一...
    開封第一講書人閱讀 52,246評論 1 308
  • 那天,我揣著相機(jī)與錄音锤岸,去河邊找鬼竖幔。 笑死,一個胖子當(dāng)著我的面吹牛是偷,可吹牛的內(nèi)容都是我干的拳氢。 我是一名探鬼主播,決...
    沈念sama閱讀 40,819評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼晓猛,長吁一口氣:“原來是場噩夢啊……” “哼饿幅!你這毒婦竟也來了凡辱?” 一聲冷哼從身側(cè)響起戒职,我...
    開封第一講書人閱讀 39,725評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎透乾,沒想到半個月后洪燥,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,268評論 1 320
  • 正文 獨居荒郊野嶺守林人離奇死亡乳乌,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,356評論 3 340
  • 正文 我和宋清朗相戀三年捧韵,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(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
  • 我被黑心中介騙來泰國打工坚芜, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人斜姥。 一個月前我還...
    沈念sama閱讀 48,897評論 3 376
  • 正文 我出身青樓鸿竖,卻偏偏與公主長得像,于是被迫代替她去往敵國和親铸敏。 傳聞我的和親對象是個殘疾皇子缚忧,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,500評論 2 359

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

  • This is a pre-print version. Official version: http://rsi...
    hydro閱讀 614評論 0 0
  • 我就無言以對……???(?????_?????)????????
    白櫻嵐閱讀 267評論 1 1
  • 突然感到失落,從沒有有過的失落杈笔! 感覺心好像被掏空了闪水,空的什么都沒有 你的最后一句了冷漠,打碎我所有的夢想和希翼蒙具。...
    微光里的影閱讀 270評論 0 0
  • 今天是裸辭后的整整一個月球榆,回到家鄉(xiāng),我以為自己早已接受了失敗禁筏,不想再折騰持钉,我錯的離譜。 連續(xù)換了兩份工作篱昔,行業(yè)的落...
    王夕惜往矣閱讀 276評論 1 3
  • 祝親愛的簡友們新年快樂每强!萬事如意!獻(xiàn)春聯(lián)一副: 雪停了天晴了冬天去了, ...
    陳輝_5119閱讀 754評論 11 35