rm(list=ls())
my.ds <- read_excel("~/Documents/Onedrive/Social Entrepreneurship/Final Paper/finalsocialentrepreneurship2.xlsx")
my.df <- as.data.frame(my.ds)
# Variance
cat("The output of variance analysis is :\n ")
The output of variance analysis is :
myCov <- cov(my.df, method = c("pearson"))
round(myCov, 3)
SVC RP AA AA*RP DI TR
SVC 0.282 -0.015 0.039 0.020 0.038 0.001
RP -0.015 0.035 -0.003 0.033 -0.004 0.001
AA 0.039 -0.003 0.020 0.016 0.019 0.001
AA*RP 0.020 0.033 0.016 0.050 0.015 0.002
DI 0.038 -0.004 0.019 0.015 0.018 0.001
TR 0.001 0.001 0.001 0.002 0.001 0.000
#Correlation Matrix and Test
cat("\n\nThe output of correlation analysis is :\n ")
The output of correlation analysis is :
myCorr <- cor(my.df, method = c("pearson"))
round(myCorr, 3)
SVC RP AA AA*RP DI TR
SVC 1.000 -0.151 0.524 0.172 0.535 0.189
RP -0.151 1.000 -0.118 0.783 -0.152 0.258
AA 0.524 -0.118 1.000 0.514 0.997 0.603
AA*RP 0.172 0.783 0.514 1.000 0.482 0.603
DI 0.535 -0.152 0.997 0.482 1.000 0.539
TR 0.189 0.258 0.603 0.603 0.539 1.000
library(psych)
corr.test(my.df)
Call:corr.test(x = my.df)
Correlation matrix
SVC RP AA AA*RP DI TR
SVC 1.00 -0.15 0.52 0.17 0.54 0.19
RP -0.15 1.00 -0.12 0.78 -0.15 0.26
AA 0.52 -0.12 1.00 0.51 1.00 0.60
AA*RP 0.17 0.78 0.51 1.00 0.48 0.60
DI 0.54 -0.15 1.00 0.48 1.00 0.54
TR 0.19 0.26 0.60 0.60 0.54 1.00
Sample Size
[1] 15
Probability values (Entries above the diagonal are adjusted for multiple tests.)
SVC RP AA AA*RP DI TR
SVC 0.00 1.00 0.42 1.00 0.42 1.00
RP 0.59 0.00 1.00 0.01 1.00 1.00
AA 0.04 0.68 0.00 0.42 0.00 0.22
AA*RP 0.54 0.00 0.05 0.00 0.48 0.22
DI 0.04 0.59 0.00 0.07 0.00 0.42
TR 0.50 0.35 0.02 0.02 0.04 0.00
To see confidence intervals of the correlations, print with the short=FALSE option
#Summary Statistics
cat("\n\nFinding the summary and description of the data :\n ")
Finding the summary and description of the data :
summary(my.df)
SVC RP AA AA*RP DI TR
Min. :-1.58418 Min. :-0.24503 Min. :-0.220896 Min. :-0.28030 Min. :-0.19424 Min. :-0.0166113
1st Qu.:-0.33063 1st Qu.:-0.11866 1st Qu.:-0.097563 1st Qu.:-0.17052 1st Qu.:-0.07914 1st Qu.:-0.0166113
Median :-0.07505 Median :-0.07893 Median : 0.001705 Median :-0.02529 Median : 0.03597 Median : 0.0099668
Mean :-0.14320 Mean : 0.00000 Mean : 0.000000 Mean : 0.00000 Mean : 0.01679 Mean :-0.0006645
3rd Qu.: 0.14402 3rd Qu.: 0.07405 3rd Qu.: 0.071643 3rd Qu.: 0.12796 3rd Qu.: 0.09353 3rd Qu.: 0.0099668
Max. : 0.75254 Max. : 0.36214 Max. : 0.314549 Max. : 0.56159 Max. : 0.32374 Max. : 0.0099668
library(psych) # Call the pysch library
psych::describe(my.df)
vars n mean sd median trimmed mad min max range skew kurtosis se
SVC 1 15 -0.14 0.53 -0.08 -0.10 0.36 -1.58 0.75 2.34 -0.97 1.33 0.14
RP 2 15 0.00 0.19 -0.08 -0.01 0.21 -0.25 0.36 0.61 0.59 -0.77 0.05
AA 3 15 0.00 0.14 0.00 -0.01 0.13 -0.22 0.31 0.54 0.39 -0.48 0.04
AA*RP 4 15 0.00 0.22 -0.03 -0.02 0.23 -0.28 0.56 0.84 0.77 0.10 0.06
DI 5 15 0.02 0.14 0.04 0.01 0.17 -0.19 0.32 0.52 0.44 -0.44 0.03
TR 6 15 0.00 0.01 0.01 0.00 0.00 -0.02 0.01 0.03 -0.37 -1.98 0.00
corr.test(my.df)
Call:corr.test(x = my.df)
Correlation matrix
SVC RP AA AA*RP DI TR
SVC 1.00 -0.15 0.52 0.17 0.54 0.19
RP -0.15 1.00 -0.12 0.78 -0.15 0.26
AA 0.52 -0.12 1.00 0.51 1.00 0.60
AA*RP 0.17 0.78 0.51 1.00 0.48 0.60
DI 0.54 -0.15 1.00 0.48 1.00 0.54
TR 0.19 0.26 0.60 0.60 0.54 1.00
Sample Size
[1] 15
Probability values (Entries above the diagonal are adjusted for multiple tests.)
SVC RP AA AA*RP DI TR
SVC 0.00 1.00 0.42 1.00 0.42 1.00
RP 0.59 0.00 1.00 0.01 1.00 1.00
AA 0.04 0.68 0.00 0.42 0.00 0.22
AA*RP 0.54 0.00 0.05 0.00 0.48 0.22
DI 0.04 0.59 0.00 0.07 0.00 0.42
TR 0.50 0.35 0.02 0.02 0.04 0.00
To see confidence intervals of the correlations, print with the short=FALSE option
Regression Anslysis:
Model1 <- lm(SVC~RP, data=my.df)
summary(Model1)
Call:
lm(formula = SVC ~ RP, data = my.df)
Residuals:
Min 1Q Median 3Q Max
-1.47459 -0.18721 0.09488 0.22544 0.84521
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.1432 0.1405 -1.019 0.327
RP -0.4259 0.7737 -0.550 0.591
Residual standard error: 0.5443 on 13 degrees of freedom
Multiple R-squared: 0.02277, Adjusted R-squared: -0.0524
F-statistic: 0.303 on 1 and 13 DF, p-value: 0.5914
Regression Anslysis:
Model2 <- lm(SVC~AA, data=my.df)
summary(Model2)
Call:
lm(formula = SVC ~ AA, data = my.df)
Residuals:
Min 1Q Median 3Q Max
-1.00381 -0.26269 0.05129 0.28553 0.88200
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.1432 0.1211 -1.183 0.2580
AA 1.9790 0.8916 2.220 0.0448 *
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4689 on 13 degrees of freedom
Multiple R-squared: 0.2748, Adjusted R-squared: 0.219
F-statistic: 4.927 on 1 and 13 DF, p-value: 0.04485
Model1 <- lm(SVC~RP*AA, data=my.df)
summary(Model1)
Call:
lm(formula = SVC ~ RP * AA, data = my.df)
Residuals:
Min 1Q Median 3Q Max
-0.96985 -0.28250 0.07162 0.19024 0.92400
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.1545 0.1285 -1.202 0.2546
RP -0.1944 0.7121 -0.273 0.7899
AA 1.8464 0.9545 1.935 0.0792 .
RP:AA -3.8627 5.1253 -0.754 0.4669
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4943 on 11 degrees of freedom
Multiple R-squared: 0.3181, Adjusted R-squared: 0.1321
F-statistic: 1.71 on 3 and 11 DF, p-value: 0.2224
Model1 <- lm(SVC~DI, data=my.df)
summary(Model1)
Call:
lm(formula = SVC ~ DI, data = my.df)
Residuals:
Min 1Q Median 3Q Max
-0.99780 -0.26506 0.07571 0.27211 0.87727
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.1785 0.1211 -1.474 0.1643
DI 2.1000 0.9189 2.285 0.0397 *
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4651 on 13 degrees of freedom
Multiple R-squared: 0.2866, Adjusted R-squared: 0.2318
F-statistic: 5.223 on 1 and 13 DF, p-value: 0.03972
Model1 <- lm(SVC~TR, data=my.df)
summary(Model1)
Call:
lm(formula = SVC ~ TR, data = my.df)
Residuals:
Min 1Q Median 3Q Max
-1.32252 -0.16768 -0.01082 0.28262 0.81677
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.1383 0.1398 -0.989 0.341
TR 7.4283 10.7227 0.693 0.501
Residual standard error: 0.5407 on 13 degrees of freedom
Multiple R-squared: 0.0356, Adjusted R-squared: -0.03858
F-statistic: 0.4799 on 1 and 13 DF, p-value: 0.5006
centered.model <- lm(SVC ~ RP*AA, data = my.df)
library(visreg)
visreg(centered.model, "RP", by="AA",
overlay=TRUE, partial=FALSE)