+1 (315) 557-6473 

Exploring Relationships and Data Testing Hypotheses in R

In this statistical analysis assignment using R, we utilized the R programming language to investigate relationships within a dataset and test various hypotheses. The dataset comprises variables such as y_FIT, x1_SC, x2_ECI, and x3_SSO. Each hypothesis was formulated and tested using appropriate R functions, providing valuable insights into the relationships between these variables. The results are presented systematically, showcasing the power of R for statistical analysis and hypothesis testing.

Problem Description:

We are given a dataset with variables y_FIT, x1_SC, x2_ECI, and x3_SSO. The goal is to explore relationships and test hypotheses regarding these variables.

y_FIT<-c(55, 70, 58, 74, 86, 98, 96, 70, 40, 67, 41, 41, 47, 45, 92, 50, 98,

42, 64, 54)

x1_SC<-c(1, 2, 2, 3, 3, 3, 3, 2, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2)

x2_ECI<-c(85, 67, 53, 52, 76, 64, 75, 75, 68, 74, 40, 66, 65, 70, 70, 60, 77,

65, 65, 50)

x3_SSO<-c(52, 51, 50, 56, 55, 61, 65, 56, 45, 52, 45, 48, 50, 49, 61, 52, 63,

49, 55, 55)

mydata<-data.frame(y_FIT,x1_SC,x2_ECI,x3_SSO)

Hypothesis One

Objective: Assess the correlation between x3_SSO and y_FIT.

cor.test(x3_SSO,y_FIT)

##

## Pearson's product-moment correlation

##

## data: x3_SSO and y_FIT

I reject the null hypothesis that fitness does not increase as the # of socially supportive others decreases because the observed correlation coefficient r = 0.919 has p-value (.0000000108) less than .05. The null hypothesis is rejected and hence the conclusion that fitness increase as the # of socially supportive others increases

## t = 9.8761, df = 18, p-value = 1.082e-08

## alternative hypothesis: true correlation is not equal to 0

## 95 percent confidence interval:

## 0.8026266 0.9678203

## sample estimates:

## cor

## 0.9188066

# Correlation Test correlation_result<- cor.test(mydata$x3_SSO, mydata$y_FIT) # Results print("Pearson's product-moment correlation") print(correlation_result)

Observation: A significant correlation exists between x3_SSO and y_FIT (cor = 0.92, p-value < 0.001).

Hypothesis Two

Objective: Compare means of y_FIT between two classes based on x1_SC.

LoClass<- ifelse(x1_SC<=1,1,0)

LoClass<- ordered(LoClass, levels = c(0,1), labels = c('Mid&Upper', 'Low'))

table(LoClass)

## LoClass

## Mid&Upper Low

## 10 10

t.test(y_FIT ~ LoClass, options(digits = 5), alternative = "two.sided")

##

## Welch Two Sample t-test

##

## data: y_FIT by LoClass

## t = 3.5, df = 18, p-value = 0.0026

## alternative hypothesis: true difference in means is not equal to 0

## 95 percent confidence interval:

## 10.158 40.642

## sample estimates:

## mean in group Mid&Upper mean in group Low

## 77.1 51.7

Observation: There is a significant difference in means between 'Mid&Upper' (mean = 77.1) and 'Low' (mean = 51.7) classes (p-value = 0.0026).

Hypothesis Three

Objective: Explore the linear relationship between y_FIT and x3_SSO using linear regression.

fit1 = lm(y_FIT ~ x3_SSO, data = mydata)

summary(fit1)

##

## Call:

## lm(formula = y_FIT ~ x3_SSO, data = mydata)

##

## Residuals:

## Min 1Q Median 3Q Max

## -15.39 -5.48 -0.72 4.98 16.61

##

## Coefficients:

## Estimate Std. Error t value Pr(>|t|)

## (Intercept) -113.640 18.123 -6.27 6.5e-06 ***

## x3_SSO 3.328 0.337 9.88 1.1e-08 ***

## ---

## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

##

## Residual standard error: 8.3 on 18 degrees of freedom

## Multiple R-squared: 0.844, Adjusted R-squared: 0.836

## F-statistic: 97.5 on 1 and 18 DF, p-value: 1.08e-08

Observation: The linear regression model indicates a significant relationship between y_FIT and x3_SSO (p-value< 0.001, R-squared = 0.844).

Standardized Coefficient

Objective: Calculate the standardized coefficient between standardized y_FIT and x3_SSO.

beta<-lm(scale(y_FIT) ~scale(x3_SSO), data =mydata)

beta

##

## Call:

## lm(formula = scale(y_FIT) ~ scale(x3_SSO), data = mydata)

##

## Coefficients:

## (Intercept) scale(x3_SSO)

## -3.11e-16 9.19e-01

Observation: The standardized coefficient for x3_SSO is 0.919, indicating a strong standardized relationship.

This structured approach provides a clear presentation of the hypotheses, methods, and results, making it easier for readers to understand and interpret the analysis.