STA 442 Methods of Applied Statistics

Homework 2, Mixed effects models
STA 442 Methods of Applied Statistics
Due 16 Oct 2019
Math (10 marks)
data("MathAchieve", package = "MEMSS")
head(MathAchieve)
School Minority Sex SES MathAch MEANSES
1 1224 No Female -1.528 5.876 -0.428
2 1224 No Female -0.588 19.708 -0.428
3 1224 No Male -0.528 20.349 -0.428
4 1224 No Male -0.668 8.781 -0.428
5 1224 No Male -0.158 17.898 -0.428
6 1224 No Male 0.022 4.583 -0.428
From Maindonald and Braun, ch 10 q 5. In the data set MathAchieve (MEMSS package),
the factors Minority (levels yes and no), and the variable SES (socio-economic status) are
clearly fixed effects. Carry out an analysis that treats School as a random effect. Does
it appear that there are substantial differences between schools, or are differences within
schools nearly as big as differences between students from different schools? Write a short
report ( a single page of text plus a few graphs).
Q3: Drugs (20 marks)
http://www.icpsr.umich.edu/icpsrweb/ICPSR/studies/35074
The Treatment Episode Data Set – Discharges (TEDS-D) is a national census data system of
annual discharges from substance abuse treatment facilities. TEDS-D provides annual data

代做STA 442课程作业、代写effects models作业
on the number and characteristics of persons discharged from public and private substance
abuse treatment programs that receive public funding.
download.file("http://pbrown.ca/teaching/appliedstats/data/drugs.rds",
"drugs.rds")
xSub = readRDS("drugs.rds")
1
table(xSub$SUB1)
(4) MARIJUANA/HASHISH (2) ALCOHOL
188406 97013
(5) HEROIN (7) OTHER OPIATES AND SYNTHETICS
58511 45609
(10) METHAMPHETAMINE (3) COCAINE/CRACK
21606 11333
table(xSub$STFIPS)[1:5]
(1) ALABAMA (2) ALASKA (4) ARIZONA (5) ARKANSAS (6) CALIFORNIA
616 1360 4479 1508 48065
table(xSub$TOWN)[1:2]
ABILENE, TX AKRON, OH
42 1078
Each row of the dataset corresponds to an individual admitted to a drug or alcohol addiction
treatment facility. The variables above are:
• completed is TRUE if the individual in question completed their treatment and FALSE
otherwise.
• SUB1 is the substance which was the individual’s primary addiction.
• GENDER, AGE, raceEthnicity are the individuals age, gender and ethnicity, known to
be important confounders.
• STFIPS, TOWN, the US state and town in which the treatment was given.
Write a short report addressing the hypothesis that chance of a young person completing their
drug treatment depends on the substance the individual is addicted to, with ‘hard’ drugs
(Heroin, Opiates, Methamphetamine, Cocaine) being more difficult to treat than alcohol or
marijuana. A secondary hypothesis is that some American states have particularly effective
treatment programs whereas other states have programs which are highly problematic with
very low completion rates.
The report should be on the order of four paragraphs: introduction, methods, results, conclusions.
Not more than two pages of text, closer to one page is better.
Some code below may or may not be helpful.
forInla = na.omit(xSub)
forInla$y = as.numeric(forInla$completed)
library("INLA")
ires = inla(y ~ SUB1 + GENDER + raceEthnicity + homeless +
2
f(STFIPS, hyper=list(prec=list(
prior=‘pc.prec‘, param=c(0.1, 0.05)))) +
f(TOWN),
data=forInla, family=‘binomial‘,
control.inla = list(strategy=‘gaussian‘, int.strategy=‘eb‘))
sdState = Pmisc::priorPostSd(ires)
do.call(matplot, sdState$STFIPS$matplot)
do.call(legend, sdState$legend)
0.4 0.5 0.6 0.7 0.8
0 2 4 6
sd
dens
prior
posterior
Figure 1: State-level standard deviation
toPrint = as.data.frame(rbind(exp(ires$summary.fixed[,
c(4, 3, 5)]), sdState$summary[, c(4, 3, 5)]))
sss = "^(raceEthnicity|SUB1|GENDER|homeless|SD)(.[[:digit:]]+.[[:space:]]+| for )?"
toPrint = cbind(variable = gsub(paste0(sss, ".*"),
"\\1", rownames(toPrint)), category = substr(gsub(sss,
"", rownames(toPrint)), 1, 25), toPrint)
Pmisc::mdTable(toPrint, digits = 3, mdToTex = TRUE,
guessGroup = TRUE, caption = "Posterior means and quantiles for model parameters.")
ires$summary.random$STFIPS$ID = gsub("[[:punct:]]|[[:digit:]]",
"", ires$summary.random$STFIPS$ID)
ires$summary.random$STFIPS$ID = gsub("DISTRICT OF COLUMBIA",
"WASHINGTON DC", ires$summary.random$STFIPS$ID)
toprint = cbind(ires$summary.random$STFIPS[1:26, c(1,
2, 4, 6)], ires$summary.random$STFIPS[-(1:26),
c(1, 2, 4, 6)])
colnames(toprint) = gsub("uant", "", colnames(toprint))
knitr::kable(toprint, digits = 1, format = "latex")
3
Table 1: Posterior means and quantiles for model parameters.
0.5quant 0.025quant 0.975quant
(Intercept)
(Intercept) 0.682 0.562 0.826
SUB1
ALCOHOL 1.642 1.608 1.677
HEROIN 0.898 0.875 0.921
OTHER OPIATES AND SYNTHET 0.924 0.898 0.952
METHAMPHETAMINE 0.982 0.944 1.022
COCAINE/CRACK 0.876 0.834 0.920
GENDER
FEMALE 0.895 0.880 0.910
raceEthnicity
Hispanic 0.829 0.810 0.849
BLACK OR AFRICAN AMERICAN 0.685 0.669 0.702
AMERICAN INDIAN (OTHER TH 0.730 0.680 0.782
OTHER SINGLE RACE 0.864 0.810 0.920
TWO OR MORE RACES 0.851 0.790 0.917
ASIAN 1.133 1.038 1.236
NATIVE HAWAIIAN OR OTHER 0.847 0.750 0.955
ASIAN OR PACIFIC ISLANDER 1.451 1.225 1.720
ALASKA NATIVE (ALEUT, ESK 0.844 0.623 1.143
homeless
TRUE 1.015 0.983 1.048
SD
STFIPS 0.581 0.482 0.698
TOWN 0.537 0.482 0.597
4
ID mean 0.025q 0.975q ID mean 0.025q 0.975q
ALABAMA 0.2 -0.3 0.7 MONTANA -0.2 -1.0 0.6
ALASKA 0.0 -0.8 0.8 NEBRASKA 0.8 0.4 1.2
ARIZONA 0.0 -1.1 1.1 NEVADA -0.1 -0.8 0.5

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codehelp

原文地址:https://www.cnblogs.com/weljavat/p/11700035.html

时间: 2024-08-30 14:45:53

STA 442 Methods of Applied Statistics的相关文章

ST5222: Advanced Topics in Applied Statistics

ST5222: Advanced Topics in Applied StatisticsMidterm 1Dealine for submission midnight 9th of October, 2019.1. (10 points)(a) Suppose (x1, x2, x3) follow a multivariate normal distribution withmean (µ1, µ2, µ3) and covariance matrixshow that the condi

ACCT648 Applied Statistics for Data Analysis

Term 1, 2019/2020ACCT648 Applied Statistics for Data AnalysisAssignment 3Deadline of Submission: Upload your answer file in word-format on 6 November2019 before 5pm in e-Learn, and submit the hard copy during class on that day1. The owner of a moving

MAT022 Foundations of Statistics

MAT022 Foundations of Statistics and Data Science Summative Assessment 2019/20MAT022 Foundations of Statistics and Data ScienceSummative Assessment 2019/20Summative assessment for the module is by means of a single report on your statistical analysis

数学类杂志SCI2013-2014影响因子

ISSN Abbreviated Journal Title Full Title Category Subcategory Country total Cites IF        2013-2014 IF 2012-2013 IF 2011-2012 IF 2010-2011 IF 2009-2010 IF 2008-2009 IF 2007-2008 5-Year Impact Factor Immediacy Index Articles Cited Half-Life Eigenfa

[Z] 计算机类会议期刊根据引用数排名

一位cornell的教授做的计算机类期刊会议依据Microsoft Research引用数的排名 link:http://www.cs.cornell.edu/andru/csconf.html The following are the journals and conferences in computer science that have published at least 100 papers (2003–2013), with at least 5 citations per pa

Scale Space(zz Wiki)

Scale space From Wikipedia, the free encyclopedia Scale space Scale-space axioms Scale-space implementation Feature detection Edge detection Blob detection Corner detection Ridge detection Interest point detection Scale selection Affine shape adaptat

【Repost】A Practical Intro to Data Science

Are you a interested in taking a course with us? Learn about our programs or contact us at [email protected]. There are plenty of articles and discussions on the web about what data science is, what qualitiesdefine a data scientist, how to nurture th

【分享】近4000份数学学习资源免费分享给大家

一直以来喜欢收集数学类的教程资源,于是费了好大劲从万千合集站上扒拉了下来,总结归类了一下,一共有将近4000本电子书.经测试,均可免费下载,可能会弹出小广告,可不必理会之.[仅供学术学习和交流,请无用于商业用途.]另外,如有可能,还请尽量支持正版纸质书.   数学史(54)     数学史.rar 55.6 MB   数学的起源与发展.rar 4.3 MB   费马大定理—一个困惑了世间智者358年的谜.pdf 9.5 MB   通俗数学名著译丛14-无穷之旅:关于无穷大的文化史.pdf 14.

【网址】数学网址大全

中文数学专业网站:博士家园http://www.math.org.cnhttp://www.bossh.net 数理逻辑.数学基础:http://www.disi.unige.it/aila/eindex.html意大利逻辑及其应用协会的主页,包括意大利数理逻辑领域的相关内容. http://www.plenum.com/title.cgi?2110<代数与逻辑>,<西伯利亚代数与逻辑期刊>的翻译版,荷兰的Kluwer学术出版社提供其在线服务. http://forum.swart