Mvda Lab Da 5 22MDT0044

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Name: Neha Mahesh

Reg no: 22MDT0044

Date of submission: 15-11-2023

MVDA LAB DA 5

PROBLEM DEFINITION:

To compute 𝑑𝑖 2 (squared generalised distance) and use it as test statistic for testing the multivariate
normality for a stiffness measure by variables x1, x2, x3, x4.

SOFTWARE USED:

➢ Excel – Calculating variance covariance matrix

➢ R studio – Calculating the inverse of matrix and product of matrices

METHODOLOGY:

• Compute X̅ (x bar)
• Calculate Variance, Covariance
• Calculate Variance-Covariance matrix
• Calculate 𝑆 −1
• Compute 𝑑𝑖 2
• Conclusion

COMPUTATIONS:

The following computations done in excel and R are shown below:


#The dataset is imported

x1=c(1889,2403,2119,1650,1975,1700,1940,2100,3000,1750,1725,2000,1850,1870,1860,1950,1325,14

x2=c(1650,2040,1700,1630,1910,1720,1680,1820,2790,1600,1590,1900,1840,1685,1650,2150,1170,13

x3=c(1560,2080,1800,1115,1615,1450,1280,1720,2410,1390,1520,1630,1600,1490,1390,1200,1000,12

x4=c(1780,2190,2200,1535,1880,1545,1670,1875,2580,1500,1680,1900,1750,1680,1720,1300,1190,13

datamatrix=matrix(c( x1,x2, x3, x4),


nrow=length( x1),byrow = FALSE)

colmean=colMeans(datamatrix)

y1=c(100087.9053, 90176.85156, 80343.26172, 88574.84863,


90176.85156, 96622.75, 69615.46875, 76882.61719,
80343.26172, 69615.46875,88979.29688 , 83464.94141,
88574.84863 ,76882.61719, 83464.94141 ,96019.50684)

covmatrix = matrix(data= y1, nrow=4,ncol=4, byrow=TRUE)


covmatrix

## [,1] [,2] [,3] [,4]


## [1,] 100087.91 90176.85 80343.26 88574.85
## [2,] 90176.85 96622.75 69615.47 76882.62
## [3,] 80343.26 69615.47 88979.30 83464.94
## [4,] 88574.85 76882.62 83464.94 96019.51

inv_covmatrix = solve(covmatrix)
inv_covmatrix

## [,1] [,2] [,3] [,4]


## [1,] 1.315448e-04 -7.106549e-05 -1.477316e-05 -5.160224e-05
## [2,] -7.106549e-05 6.730171e-05 3.079424e-06 8.990451e-06
## [3,] -1.477316e-05 3.079424e-06 6.336404e-05 -4.391711e-05
## [4,] -5.160224e-05 8.990451e-06 -4.391711e-05 8.899224e-05

# ca7cu7ate nmax for each row

nmax_list=lapply(1:nrow(datamatrix), function(i)
{nmax_row=datamatrix [i ,] - colmean
return(nmax_row) })

1
# Transpose nmax

nmax_transpose_list=lapply(nmax_list, t)
print(nmax_list)

## [[1]]
## [1] -1.03125 -80.75000 39.37500 65.15625
##
## [[2]]
## [1] 512.9688 309.2500 559.3750 475.1562
##
## [[3]]
## [1] 228.9688 -30.7500 279.3750 485.1562
##
## [[4]]
## [1] -240.0312 -100.7500 -405.6250 -179.8438
##
## [[5]]
## [1] 84.96875 179.25000 94.37500 165.15625
##
## [[6]]
## [1] -190.0312 -10.7500 -70.6250 -169.8438
##
## [[7]]
## [1] 49.96875 -50.75000 -240.62500 -44.84375
##
## [[8]]
## [1] 209.9688 89.2500 199.3750 160.1562
##
## [[9]]
## [1] 1109.9688 1059.2500 889.3750 865.1562
##
## [[10]]
## [1] -140.0312 -130.7500 -130.6250 -214.8438
##
## [[11]]
## [1] -165.03125 -140.75000 -0.62500 -34.84375
##
## [[12]]
## [1] 109.9688 169.2500 109.3750 185.1562
##
## [[13]]
## [1] -40.03125 109.25000 79.37500 35.15625
##
## [[14]]

2
## [1] -20.03125 -45.75000 -30.62500 -34.84375
##
## [[15]]
## [1] -30.03125 -80.75000 -130.62500 5.15625
##
## [[16]]
## [1] 59.96875 419.25000 -320.62500 -414.84375
##
## [[17]]
## [1] -565.0312 -560.7500 -520.6250 -524.8438
##
## [[18]]
## [1] -470.0312 -350.7500 -260.6250 -414.8438
##
## [[19]]
## [1] -60.03125 -100.75000 79.37500 45.15625
##
## [[20]]
## [1] -165.03125 -136.75000 -210.62500 -64.84375
##
## [[21]]
## [1] 389.9688 459.2500 29.3750 385.1562
##
## [[22]]
## [1] 8.96875 -110.75000 -90.62500 -234.84375
##
## [[23]]
## [1] -260.0312 -230.7500 -220.6250 -184.8438
##
## [[24]]
## [1] 169.9688 139.2500 329.3750 335.1562
##
## [[25]]
## [1] -40.03125 -240.75000 -160.62500 -184.84375
##
## [[26]]
## [1] -165.0312 -300.7500 -270.6250 -214.8438
##
## [[27]]
## [1] 279.9688 169.2500 179.3750 135.1562
##
## [[28]]
## [1] -230.0312 -55.7500 -120.6250 -114.8438
##
## [[29]]

3
## [1] 435.9688 569.2500 559.3750 535.1562
##
## [[30]]
## [1] -390.0312 -350.7500 -300.6250 -414.8438
##
## [[31]]
## [1] -290.0312 -330.7500 -220.6250 -314.8438
##
## [[32]]
## [1] -190.0312 -230.7500 279.3750 -114.8438

print(nmax_transpose_list )

## [[1]]
## [,1] [,2] [,3] [,4]
## [1,] -1.03125 -80.75 39.375 65.15625
##
## [[2]]
## [,1] [,2] [,3] [,4]
## [1,] 512.9688 309.25 559.375 475.1562
##
## [[3]]
## [,1] [,2] [,3] [,4]
## [1,] 228.9688 -30.75 279.375 485.1562
##
## [[4]]
## [,1] [,2] [,3] [,4]
## [1,] -240.0312 -100.75 -405.625 -179.8438
##
## [[5]]
## [,1] [,2] [,3] [,4]
## [1,] 84.96875 179.25 94.375 165.1562
##
## [[6]]
## [,1] [,2] [,3] [,4]
## [1,] -190.0312 -10.75 -70.625 -169.8438
##
## [[7]]
## [,1] [,2] [,3] [,4]
## [1,] 49.96875 -50.75 -240.625 -44.84375
##
## [[8]]
## [,1] [,2] [,3] [,4]
## [1,] 209.9688 89.25 199.375 160.1562
##
## [[9]]

4
## [,1] [,2] [,3] [,4]
## [1,] 1109.969 1059.25 889.375 865.1562
##
## [[10]]
## [,1] [,2] [,3] [,4]
## [1,] -140.0312 -130.75 -130.625 -214.8438
##
## [[11]]
## [,1] [,2] [,3] [,4]
## [1,] -165.0312 -140.75 -0.625 -34.84375
##
## [[12]]
## [,1] [,2] [,3] [,4]
## [1,] 109.9688 169.25 109.375 185.1562
##
## [[13]]
## [,1] [,2] [,3] [,4]
## [1,] -40.03125 109.25 79.375 35.15625
##
## [[14]]
## [,1] [,2] [,3] [,4]
## [1,] -20.03125 -45.75 -30.625 -34.84375
##
## [[15]]
## [,1] [,2] [,3] [,4]
## [1,] -30.03125 -80.75 -130.625 5.15625
##
## [[16]]
## [,1] [,2] [,3] [,4]
## [1,] 59.96875 419.25 -320.625 -414.8438
##
## [[17]]
## [,1] [,2] [,3] [,4]
## [1,] -565.0312 -560.75 -520.625 -524.8438
##
## [[18]]
## [,1] [,2] [,3] [,4]
## [1,] -470.0312 -350.75 -260.625 -414.8438
##
## [[19]]
## [,1] [,2] [,3] [,4]
## [1,] -60.03125 -100.75 79.375 45.15625
##
## [[20]]
## [,1] [,2] [,3] [,4]

5
## [1,] -165.0312 -136.75 -210.625 -64.84375
##
## [[21]]
## [,1] [,2] [,3] [,4]
## [1,] 389.9688 459.25 29.375 385.1562
##
## [[22]]
## [,1] [,2] [,3] [,4]
## [1,] 8.96875 -110.75 -90.625 -234.8438
##
## [[23]]
## [,1] [,2] [,3] [,4]
## [1,] -260.0312 -230.75 -220.625 -184.8438
##
## [[24]]
## [,1] [,2] [,3] [,4]
## [1,] 169.9688 139.25 329.375 335.1562
##
## [[25]]
## [,1] [,2] [,3] [,4]
## [1,] -40.03125 -240.75 -160.625 -184.8438
##
## [[26]]
## [,1] [,2] [,3] [,4]
## [1,] -165.0312 -300.75 -270.625 -214.8438
##
## [[27]]
## [,1] [,2] [,3] [,4]
## [1,] 279.9688 169.25 179.375 135.1562
##
## [[28]]
## [,1] [,2] [,3] [,4]
## [1,] -230.0312 -55.75 -120.625 -114.8438
##
## [[29]]
## [,1] [,2] [,3] [,4]
## [1,] 435.9688 569.25 559.375 535.1562
##
## [[30]]
## [,1] [,2] [,3] [,4]
## [1,] -390.0312 -350.75 -300.625 -414.8438
##
## [[31]]
## [,1] [,2] [,3] [,4]
## [1,] -290.0312 -330.75 -220.625 -314.8438

6
##
## [[32]]
## [,1] [,2] [,3] [,4]
## [1,] -190.0312 -230.75 279.375 -114.8438

# Calculate result for each row


result_list=lapply(1:length(nmax_list),function(i){
result_row=nmax_transpose_list[[i]]%*%inv_covmatrix %*% nmax_list[[i]]
return(result_row) })

#Output the results

result_matrix= do.call(rbind,result_list)
print(result_matrix)

## [,1]
## [1,] 0.57179705
## [2,] 5.15130353
## [3,] 8.27227558
## [4,] 4.96687584
## [5,] 1.52142227
## [6,] 2.60734759
## [7,] 4.46485538
## [8,] 1.32793949
## [9,] 13.62446640
## [10,] 0.81653584
## [11,] 1.21288618
## [12,] 1.12418849
## [13,] 2.26138429
## [14,] 0.08427609
## [15,] 1.31306283
## [16,] 18.05592196
## [17,] 3.60746164
## [18,] 3.46847207
## [19,] 0.85293120
## [20,] 1.82461201
## [21,] 8.43116649
## [22,] 5.30723490
## [23,] 0.91770073
## [24,] 2.50418395
## [25,] 4.89413281
## [26,] 2.94150478
## [27,] 2.24814083
## [28,] 2.83627993
## [29,] 6.71241652
## [30,] 2.03733735

7
## [31,] 1.60525906
## [32,] 10.43462679

8
LITERATURE REVIEW:

In examining material properties, multivariate analysis, such as Mahalanobis distance and chi-square
tests, is applied to assess the normality of stiffness measurements. Deviations from normality in such
datasets can impact statistical analyses and require specialized treatment, ensuring accurate
characterization of material behavior in various applications. Mahalanobis distance is a measure of
the distance between a data point and a distribution, considering correlation and variance. It's used
in multivariate statistics to identify outliers. Chi-square tests assess the association between
categorical variables or test whether observed data follows an expected distribution, providing
insights into statistical significance.

RESULT & CONCLUSION:

As all the values are less than chi-squared value i.e., 45 at a 5% level of significance. We can say 100%
of data points lie within the contour which is greater than or equal to 50%. Therefore, we do not
reject null hypothesis i.e., our data following normal distribution.

You might also like