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
講解:Mixed Model、R律罢、data膀值、RPython|SQL
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來辟癌,“玉大人寒屯,你說我怎么就攤上這事。” “怎么了寡夹?”我有些...
- 文/不壞的土叔 我叫張陵处面,是天一觀的道長。 經(jīng)常有香客問我菩掏,道長魂角,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任智绸,我火速辦了婚禮野揪,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘瞧栗。我一直安慰自己斯稳,他們只是感情好,可當(dāng)我...
- 文/花漫 我一把揭開白布迹恐。 她就那樣靜靜地躺著挣惰,像睡著了一般。 火紅的嫁衣襯著肌膚如雪殴边。 梳的紋絲不亂的頭發(fā)上憎茂,一...
- 文/蒼蘭香墨 我猛地睜開眼晓猛,長吁一口氣:“原來是場噩夢啊……” “哼饿幅!你這毒婦竟也來了凡辱?” 一聲冷哼從身側(cè)響起戒职,我...
- 正文 年R本政府宣布,位于F島的核電站针炉,受9級特大地震影響挠他,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜篡帕,卻給世界環(huán)境...
- 文/蒙蒙 一殖侵、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧镰烧,春花似錦拢军、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至败砂,卻和暖如春赌渣,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背昌犹。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- This is a pre-print version. Official version: http://rsi...