Description Usage Format Source References Examples
To better understand whether the relationship between heart disease and obesity could be due to the social stigma associated with obesity, researchers examined cardiovascular disease rates of obese and non-obese women in American Samoa, where obesity was considered socially desirable. 3,112 women were categorized according to whether they were obese or not and whether they died from cardiovascular disease (CVD).
1 |
A data frame with 2 observations on the following 3 variables.
a factor with levels "NotObese"
and
"obese"
the number of women who died from CVD
the number that died from other causes
Ramsey, F.L. and Schafer, D.W. (2013). The Statistical Sleuth: A Course in Methods of Data Analysis (3rd ed), Cenage Learning.
Crews, D.E. (1988). Cardiovascular Mortality in American Samoa, Human Biology 60: 417–433.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | str(case1801)
attach(case1801)
## EXPLORATION
myTable <- cbind(Deaths,NonDeaths) # Form a 2 by 2 table of counts
row.names(myTable) <- Obesity # Assign the levels of Obesity as row names
myTable # Show the table
## INFERENCE (4 methods for getting p-values and confidence intervals)
prop.test(myTable, alternative="greater", correct=FALSE) # Compare 2 proportions
prop.test(myTable, alternative="greater", correct=TRUE) # ...with cont. corect.
prop.test(myTable,correct=TRUE) # 2-sided alternative (default) to get CI
chisq.test(myTable) # Pearson's Chi-Squared Test
fisher.test(myTable, alternative="greater") # Fisher's exact test
fisher.test(myTable) # 2-sided alternative to get CI for odds ratio
myGlm1 <- glm(myTable ~ Obesity, family=binomial) # Logistic reg (CH 21)
summary(myGlm1) # Get p-value-- 0.734
beta <- myGlm1$coef
exp(beta[2]) #Odds of death are estimated to be 17% higher for obese women
exp(confint(myGlm1,2)) # 95% confidence interval
## GRAPHICAL DISPLAY FOR PRESENTATION
myTable
# Deaths NonDeaths
#Obese 16 2045
#NotObese 7 1044
prop.test(16,(16+2045)) #For one proportion, est: 0.0078 95% CI: 0.0046 to 0.013
prop.test(7,(7+1044)) #For one proportion, est: 0067 95% CI: 0.0029 to 0.014
pHat <- c(0.007763222, 0.006660324)*1000 # Get estimated deaths per 1,000 women
lower95 <- c(0.00459943, 0.002921568)*1000
upper95 <- c(0.01287243, 0.014318321)*1000
if(require(Hmisc)) { # Use Hmisc library
myObj <- Cbind(pHat,lower95,upper95)
Dotplot(Obesity ~ myObj, # Draw a dot plot of estimates and CIs
xlab="Estimated CVD Deaths Per 1,000 Women (and 95% Confidence Intervals)",
ylab="Weight Category", ylim=c(.5,2.5), cex=2)
}
detach(case1801)
|
'data.frame': 2 obs. of 3 variables:
$ Obesity : Factor w/ 2 levels "NotObese","Obese": 2 1
$ Deaths : int 16 7
$ NonDeaths: int 2045 1044
Deaths NonDeaths
Obese 16 2045
NotObese 7 1044
2-sample test for equality of proportions without continuity
correction
data: myTable
X-squared = 0.11541, df = 1, p-value = 0.367
alternative hypothesis: greater
95 percent confidence interval:
-0.004107007 1.000000000
sample estimates:
prop 1 prop 2
0.007763222 0.006660324
2-sample test for equality of proportions with continuity correction
data: myTable
X-squared = 0.014031, df = 1, p-value = 0.4529
alternative hypothesis: greater
95 percent confidence interval:
-0.004825345 1.000000000
sample estimates:
prop 1 prop 2
0.007763222 0.006660324
2-sample test for equality of proportions with continuity correction
data: myTable
X-squared = 0.014031, df = 1, p-value = 0.9057
alternative hypothesis: two.sided
95 percent confidence interval:
-0.005823425 0.008029221
sample estimates:
prop 1 prop 2
0.007763222 0.006660324
Pearson's Chi-squared test with Yates' continuity correction
data: myTable
X-squared = 0.014031, df = 1, p-value = 0.9057
Fisher's Exact Test for Count Data
data: myTable
p-value = 0.4625
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
0.5161345 Inf
sample estimates:
odds ratio
1.166817
Fisher's Exact Test for Count Data
data: myTable
p-value = 0.8277
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.4524487 3.3646287
sample estimates:
odds ratio
1.166817
Call:
glm(formula = myTable ~ Obesity, family = binomial)
Deviance Residuals:
[1] 0 0
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.0049 0.3792 -13.198 <2e-16 ***
ObesityObese 0.1543 0.4548 0.339 0.734
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 1.1741e-01 on 1 degrees of freedom
Residual deviance: 9.8299e-13 on 0 degrees of freedom
AIC: 12.414
Number of Fisher Scoring iterations: 3
ObesityObese
1.166888
Waiting for profiling to be done...
2.5 % 97.5 %
0.4964985 3.0439343
Deaths NonDeaths
Obese 16 2045
NotObese 7 1044
1-sample proportions test with continuity correction
data: 16 out of (16 + 2045), null probability 0.5
X-squared = 1995.5, df = 1, p-value < 2.2e-16
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.00459943 0.01287243
sample estimates:
p
0.007763222
1-sample proportions test with continuity correction
data: 7 out of (7 + 1044), null probability 0.5
X-squared = 1021.2, df = 1, p-value < 2.2e-16
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.002921568 0.014318321
sample estimates:
p
0.006660324
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2
Attaching package: ‘Hmisc’
The following objects are masked from ‘package:base’:
format.pval, units
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.