I posit that there is a correlation between the level of rebellion in teenage years and later success. In plain English, children who are more rebellious are more likely to achieve success.
Success is not a quantitative variable. Proxies include income and self-satisfaction. Let’s pretend there is a simple metric for success called “success”.
Similarly, rebellion can be defined in multiple ways, such as:
1. How well did you get along with your parents?
2. At what age did you leave home for good?
3. How much influence did your parents have on your college and career choices?
I hypothesize that the correlation between rebelliousness and success is positive.
\(H_{0}: \rho = 0; H_{1}: \rho > 0\)
My alternative hypothesis is that \(H_{1}: \rho = 0.3\). I would like 80% power in my survey.
library(pwr)
pwr.r.test(r = 0.3, sig.level = 0.01, power = 0.8, alternative = "greater")
##
## approximate correlation power calculation (arctangh transformation)
##
## n = 107.0966
## r = 0.3
## sig.level = 0.01
## power = 0.8
## alternative = greater
pwr <- pwr.r.test(r = 0.3, sig.level = 0.01, power = 0.8, alternative = "greater")
plot(pwr)
I need 107 individuals in my survey. I’ll shoot for 110.
Data is simulated. We have 110 observations, 55 of whom are pre-defined as satisfied and 55 of whom are not.
set.seed(1234)
#response- success
success <- runif(55, 5, 10)
not_success <- runif(55, 4, 9)
response <- c(success, not_success)
#predictor-rebel
rebel <- runif(55, 5, 10)
not_rebel <- runif(55, 3,7)
predictor = c(rebel, not_rebel)
plot(predictor, response)
abline(lm(response ~ predictor))
cor(scale(response) , scale(predictor))
## [,1]
## [1,] 0.3371862
The correlation is 0.337, which is pretty close to the 30% correlation.
We’ll bootstrap the confidence intervals for this test.
library(boot)
library(simpleboot)
## Simple Bootstrap Routines (1.1-7)
boot.cor <- pairs_boot(predictor, response, FUN = cor, R = 10000)
boot.ci(boot.cor, type = "all")
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 10000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = boot.cor, type = "all")
##
## Intervals :
## Level Normal Basic
## 95% ( 0.1827, 0.4945 ) ( 0.1858, 0.4995 )
##
## Level Percentile BCa
## 95% ( 0.1749, 0.4885 ) ( 0.1736, 0.4875 )
## Calculations and Intervals on Original Scale
Based on the bootstrapped CI’s we can certainly reject the null hypothesis that the correlation is equal to 0.
summary(lm(response ~ scale(predictor)))
##
## Call:
## lm(formula = response ~ scale(predictor))
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.4685 -1.2371 -0.2937 1.0360 2.8374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.5933 0.1388 47.505 < 2e-16 ***
## scale(predictor) 0.5190 0.1394 3.722 0.000316 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.456 on 108 degrees of freedom
## Multiple R-squared: 0.1137, Adjusted R-squared: 0.1055
## F-statistic: 13.85 on 1 and 108 DF, p-value: 0.0003156
Based on the model, the predictor is significant. Average satisfaction is 6.6, and each SD increase in rebelliousness increases success by .5 points.