#REGRESSION ANALYSIS in R
#Descriptive Statistics psych::describe(tendata)
#DEPENDENT VARIABLES #Testing for Regression Assupmsions jpm=c(9.52, 3.82, 13.68, -8.80, -27.12, 5.87, -0.78, 2.27, 6.89, 1.17, -2.36, 5.08, 4.86, 2.60, -4.99, 1.45, 9.48, -5.65, 2.84, -11.81, -0.54, -2.91, 8.47, -0.72, -8.34, 0.55, 3.90, -10.82, -2.67, 1.02, -2.45, 1.32, -1.21, -1.90, -2.19, 1.73, -15.92, 10.61, -3.19, 2.39, 2.37, 0.61, -1.19, -8.20, -7.18, 3.17, 2.17, -3.22, -12.50, -6.64, 3.17, 4.69, 2.15, -6.55, 1.40, 4.59, -2.99, 2.17, 13.21, 4.87, -4.37, 4.97, -5.60, -3.26, -7.46, 8.48, -1.88, -2.66, 2.76, 2.84, 2.05, -0.11, 5.27, -2.49, -7.75, -3.96, -4.11, -5.57, 6.93, -2.67, -4.53, -6.59, -0.45, -15.85, 3.14, -1.04, -5.62, 11.13, -10.73, 3.29, 1.63, -6.36, 5.18, 4.25, 4.32, 3.78, -6.94, -13.96, -26.31, 5.51, 1.97, -4.13, 2.09, 3.93, -4.67, 1.03, 18.48, 6.58, 0.17, 12.89, 1.77, -0.61, 5.53, -6.96, -3.77, 4.54, 0.94, 2.14, -7.69, -1.77)
#Test of Normality #Shapiro Wilk Test shapiro.test(jpm)
gs= c(18.95, 1.27, 5.84, -9.75, -20.30, -0.98, 3.59, 2.99, 5.98, 5.63, -5.48, 6.67, 12.86, -0.70, -3.38, -2.50, 8.47, -8.90, 5.53, -10.27, 1.44, -0.96, 2.18, 2.24, -10.56, -1.30, -3.96, -5.20, -2.57, 2.40, 0.65, 1.13, 0.24, 1.14, -3.17, 0.94, -13.59, 7.62, -2.69, 2.46, 2.65, -0.80, -4.12, -10.54, -10.02, 5.54, -0.92, -7.19, -13.03, -9.52, 3.41, 2.63, -4.67, -8.31, 5.16, 4.93, -6.19, 8.25, 18.59, 6.61, -6.75, 5.44, -9.90, -4.91, -8.07, 3.06, -0.79, -2.92, 3.98, -0.15, -0.24, 0.75, 2.45, -4.73, -6.86, -8.39, -8.35, -4.94, 4.48, -2.73, -8.54, -2.65, -19.83, -15.66, 14.29, -3.34, -4.59, 4.47, -14.48, 9.82, 5.26, -9.28, 0.54, 1.21, 1.86, 2.51, 1.58, -18.41, -26.40, 16.44, 6.21, 0.47, -0.45, 2.78, -2.00, -6.91, 18.99, 12.50, 2.25, 15.13, 0.72, 5.11, 4.93, 0.82, -2.55, 8.53, -9.86, 7.35, -9.71, -1.06) shapiro.test(gs)
#INDEPENDENT VARIABLES sp=c(5.81, 2.64, 4.86, -4.55, -11.58, 2.55, -0.74, 1.13, 1.59, -0.03, -2.95, 2.23, 4.45, -0.24, 0.82, 1.12, 4.89, -4.92, 2.27, -8.10, -0.22, 0.48, 1.56, -0.92, -6.66, 0.19, 0.31, -4.36, -1.33, -0.35, -4.10, 1.52, -3.07, 0.51, -0.24, -0.60, -9.13, 3.51, -2.83, -1.86, -0.57, -2.84, 0.65, -9.37, -5.39, 3.86, -0.57, -4.62, -11.48, -5.00, 4.96, 1.41, -0.01, -5.13, 1.85, 1.95, -4.54, 0.38, 10.67, 1.20, -2.31, 2.46, -5.43, -3.27, -3.72, 3.93, -0.73, -4.08, 2.73, 0.42, 0.87, -0.59, 3.59, -5.86, -7.40, -3.35, -4.11, -4.95, 2.13, -1.72, -5.40, -8.15, -0.58, -14.99, 5.53, -0.53, -5.36, 5.94, -10.06, 4.29, 0.21, -6.83, 2.67, 0.51, 2.90, 0.60, -4.59, -13.54, -25.06, 8.27, 1.73, -1.26, 2.84, 3.39, -4.42, -1.84, 14.62, 4.94, -3.03, 9.50, 3.85, 4.57, 2.95, -4.67, -1.93, 3.60, -3.38, 5.30, -7.52, 0.73)
indp=c(96.36, 96.59, 96.67, 95.83, 96.57, 99.04, 97.57, 99.21, 98.24, 97.33, 97.32, 97.82, 97.89, 98.18, 98.80, 97.86, 98.08, 100.71, 98.86, 101.52, 100.98, 99.80, 99.56, 99.84, 99.79, 100.42, 101.85, 100.40, 101.26, 104.12, 102.38, 104.81, 103.97, 102.88, 103.12, 103.00, 102.43, 102.02, 101.97, 99.67, 99.87, 102.27, 101.07, 103.30, 101.07, 100.08, 98.79, 98.15, 99.11, 98.54, 97.62, 97.19, 97.10, 100.39, 98.67, 100.89, 99.41, 98.80, 97.65, 98.77, 98.67, 98.20, 99.29, 97.76, 98.90, 101.87, 100.08, 101.73, 100.29, 101.03, 100.80, 101.38, 101.51, 101.59, 102.40, 101.93, 101.38, 104.72, 103.32, 106.22, 104.74, 103.74, 103.24, 103.40, 103.07, 102.58, 102.91, 100.59, 101.12, 103.85, 101.74, 104.81, 102.96, 101.43, 101.56, 101.50, 100.85, 101.44, 97.48, 82.10, 84.74, 92.56, 94.80, 98.18, 95.70, 96.72, 96.70, 98.30, 99.60, 96.83, 99.38, 97.76, 98.79, 101.84, 101.08, 103.18, 99.93, 101.23, 101.84, 101.58)
lt=c(1.97, 1.97, 2.17, 2.05, 1.8, 1.62, 1.53, 1.68, 1.72, 1.75, 1.65, 1.72, 1.91, 1.98, 1.96, 1.76, 1.93, 2.3, 2.58, 2.74, 2.81, 2.62, 2.72, 2.9, 2.86, 2.71, 2.72, 2.71, 2.56, 2.6, 2.54, 2.42, 2.53, 2.3, 2.33, 2.21, 1.88, 1.98, 2.04, 1.94, 2.2, 2.36, 2.32, 2.17, 2.17, 2.07, 2.26, 2.24, 2.09, 1.78, 1.89, 1.81, 1.81, 1.64, 1.5, 1.56, 1.63, 1.76, 2.14, 2.49, 2.43, 2.42, 2.48, 2.3, 2.3, 2.19, 2.32, 2.21, 2.2, 2.36, 2.35, 2.4, 2.58, 2.86, 2.84, 2.87, 2.98, 2.91, 2.89, 2.89, 3, 3.15, 3.12, 2.83, 2.71, 2.68, 2.57, 2.53, 2.4, 2.07, 2.06, 1.63, 1.7, 1.71, 1.81, 1.86, 1.76, 1.5, 0.87, 0.66, 0.67, 0.73, 0.62, 0.65, 0.68, 0.79, 0.87, 0.93, 1.08, 1.26, 1.61, 1.64, 1.62, 1.52, 1.32, 1.28, 1.37, 1.58, 1.56, 1.47)
une=c(8.8, 8.7, 8.4, 7.7, 7.9, 8.4, 8.6, 8.2, 7.6, 7.5, 7.4, 7.6, 8.5, 8.1, 7.6, 7.1, 7.3, 7.8, 7.7, 7.3, 7, 7, 6.6, 6.5, 7, 7, 6.8, 5.9, 6.1, 6.3, 6.5, 6.3, 5.7, 5.5, 5.5, 5.4, 6.1, 5.8, 5.6, 5.1, 5.3, 5.5, 5.6, 5.2, 4.9, 4.8, 4.8, 4.8, 5.3, 5.2, 5.1, 4.7, 4.5, 5.1, 5.1, 5, 4.8, 4.7, 4.4, 4.5, 5.1, 4.9, 4.6, 4.1, 4.1, 4.5, 4.6, 4.5, 4.1, 3.9, 3.9, 3.9, 4.5, 4.4, 4.1, 3.7, 3.6, 4.2, 4.1, 3.9, 3.6, 3.5, 3.5, 3.7, 4.4, 4.1, 3.9, 3.3, 3.4, 3.8, 4, 3.8, 3.3, 3.3, 3.3, 3.4, 4, 3.8, 4.5, 14.4, 13, 11.2, 10.5, 8.5, 7.7, 6.6, 6.4, 6.5, 6.8, 6.6, 6.2, 5.7, 5.5, 6.1, 5.7, 5.3, 4.6, 4.3, 3.9, 3.7)
cpi=c(95.63, 96.05, 96.78, 97.08, 96.96, 96.82, 96.66, 97.20, 97.63, 97.60, 97.13, 96.87, 97.16, 97.95, 98.21, 98.11, 98.28, 98.52, 98.56, 98.68, 98.79, 98.54, 98.33, 98.33, 98.69, 99.06, 99.69, 100.02, 100.37, 100.56, 100.52, 100.35, 100.43, 100.18, 99.63, 99.07, 98.60, 99.03, 99.62, 99.82, 100.33, 100.68, 100.69, 100.55, 100.39, 100.35, 100.13, 99.79, 99.96, 100.04, 100.47, 100.95, 101.36, 101.69, 101.52, 101.62, 101.86, 101.99, 101.83, 101.86, 102.46, 102.78, 102.86, 103.17, 103.26, 103.35, 103.28, 103.59, 104.14, 104.07, 104.07, 104.01, 104.58, 105.05, 105.29, 105.71, 106.15, 106.32, 106.32, 106.38, 106.51, 106.69, 106.34, 106.00, 106.20, 106.65, 107.25, 107.82, 108.05, 108.07, 108.25, 108.24, 108.33, 108.58, 108.52, 108.42, 108.84, 109.14, 108.90, 108.17, 108.18, 108.77, 109.32, 109.66, 109.81, 109.86, 109.79, 109.90, 110.36, 110.97, 111.75, 112.67, 113.58, 114.63, 115.18, 115.42, 115.73, 116.70, 117.27, 117.63)
library(lmtest)
a=lm(jpm~sp+indp+lt+une+cpi) summary(a) cor(gs,sp+indp+lt+une+cpi) plot(a) (a) (a) (a) (a)
b=lm(gs~sp+indp+lt+une+cpi) summary(b) plot(b) (b) (b) (b) (b) dwtest(b)
#Test of Independence of Observations #Durbin Watson Test dwtest(a) dwtest(b)
#Homoscedasticity Test #Breusch-Pagan Test bptest(a) bptest(b)
#Multicollinearity library(metan) library(sjPlot) tab_corr(gs) tab_corr(gs,p.numeric = TRUE, triangle = "lower")
tab_corr(jpm) tab_corr(jpm,p.numeric = TRUE, triangle = "lower")
#Variance Inflation Factor vif(a) vif(b)