You are on page 1of 30

EXP 1

> name<-c("ramu","raju","ravi","vamsi","naveen","kishor","chatu","rani","sita","lakshmi")

> t1<-c(15,17,20,12,14,9,15,19,25,19)

> t2<-c(NA,19,24,16,19,20,18,16,20,NA)

> gd<-c(1,1,1,1,0,1,0,1,1,0)

> dt<-data.frame(name,t1,t2,gd)

> str(dt)

'data.frame': 10 obs. of 4 variables:

$ name: chr "ramu" "raju" "ravi" "vamsi" ...

$ t1 : num 15 17 20 12 14 9 15 19 25 19

$ t2 : num NA 19 24 16 19 20 18 16 20 NA

$ gd : num 1 1 1 1 0 1 0 1 1 0

> dt['gd']<-as.factor(dt$gd)

> str(dt)

'data.frame': 10 obs. of 4 variables:

$ name: chr "ramu" "raju" "ravi" "vamsi" ...

$ t1 : num 15 17 20 12 14 9 15 19 25 19

$ t2 : num NA 19 24 16 19 20 18 16 20 NA

$ gd : Factor w/ 2 levels "0","1": 2 2 2 2 1 2 1 2 2 1

> dt$t2[is.na(dt$t2)]<-mean(dt$t2,na.rm = T)

> str(dt)

'data.frame': 10 obs. of 4 variables:

$ name: chr "ramu" "raju" "ravi" "vamsi" ...

$ t1 : num 15 17 20 12 14 9 15 19 25 19

$ t2 : num 19 19 24 16 19 20 18 16 20 19

$ gd : Factor w/ 2 levels "0","1": 2 2 2 2 1 2 1 2 2 1

> boxplot(dt$t1,dt$t2)

pg. 1
> out<-boxplot.stats(dt$t2)$out

> out

[1] 24

> dt$t2[dt$t2%in%out]<-median(dt$t2)

> boxplot(dt$t1,dt$t2)

pg. 2
EXP 2

> #exp 2

> #ABA-K.CHATURVEDA REDDY

> x=c(60,60,60)

> p=c(1/3,1/3,1/3)

> chisq.test(x=x,p=p)

Chi-squared test for given probabilities

data: x

X-squared = 0, df = 2, p-value = 1

> x=c(70,50,30)

> p=x/sum(x)

>p

[1] 0.4666667 0.3333333 0.2000000

> chisq.test(x=x,p=p)

Chi-squared test for given probabilities

data: x

X-squared = 0, df = 2, p-value = 1

> p1=c(1/2,1/6,1/5)

> p1=c(1/2,1/6,1/3)

> chisq.test(x=x,p=p1)

Chi-squared test for given probabilities

data: x

X-squared = 33.333, df = 2, p-value = 5.778e-08

> #NH:the distribution of observed data is same as expecte

> #AH: the distribution of observed data is not same as expecte

pg. 3
EXP 3

> #exp3

> #ABA-Correlation Analysis -K.Chaturveda reddy

> dt<-mtcars

> cor(dt$mpg,dt$wt)

[1] -0.8676594

> cor(dt$hp,dt$cyl)

[1] 0.8324475

> #multi-variant correlation

> dt1<-mtcars[,c(1,3:7)]

> dt11<-cor(dt1)

> library(corrplot)

corrplot 0.92 loaded

Warning message:

package ‘corrplot’ was built under R version 4.1.2

> corrplot(dt11,method = 'number')

pg. 4
EXP 4

> #EXP 4

> #ABA-K.CHATURVEDA REDDY

> #simple liner regression

> dt<-lm(mpg~hp,data = mtcars)

> dt

Call:

lm(formula = mpg ~ hp, data = mtcars)

Coefficients:

(Intercept) hp

30.09886 -0.06823

> summary(dt)

Call:

lm(formula = mpg ~ hp, data = mtcars)

Residuals:

Min 1Q Median 3Q Max

-5.7121 -2.1122 -0.8854 1.5819 8.2360

Coefficients:

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

(Intercept) 30.09886 1.63392 18.421 < 2e-16 ***

hp -0.06823 0.01012 -6.742 1.79e-07 ***

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.863 on 30 degrees of freedom

pg. 5
Multiple R-squared: 0.6024, Adjusted R-squared: 0.5892

F-statistic: 45.46 on 1 and 30 DF, p-value: 1.788e-07

> #multiple liner regression

> dt<-lm(mpg~.,data = mtcars)

> dt

Call:

lm(formula = mpg ~ ., data = mtcars)

Coefficients:

(Intercept) cyl disp hp drat

12.30337 -0.11144 0.01334 -0.02148 0.78711

wt qsec vs am gear

-3.71530 0.82104 0.31776 2.52023 0.65541

carb

-0.19942

> summary(dt)

Call:

lm(formula = mpg ~ ., data = mtcars)

Residuals:

Min 1Q Median 3Q Max

-3.4506 -1.6044 -0.1196 1.2193 4.6271

Coefficients:

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

(Intercept) 12.30337 18.71788 0.657 0.5181

cyl -0.11144 1.04502 -0.107 0.9161

pg. 6
disp 0.01334 0.01786 0.747 0.4635

hp -0.02148 0.02177 -0.987 0.3350

drat 0.78711 1.63537 0.481 0.6353

wt -3.71530 1.89441 -1.961 0.0633 .

qsec 0.82104 0.73084 1.123 0.2739

vs 0.31776 2.10451 0.151 0.8814

am 2.52023 2.05665 1.225 0.2340

gear 0.65541 1.49326 0.439 0.6652

carb -0.19942 0.82875 -0.241 0.8122

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 2.65 on 21 degrees of freedom

Multiple R-squared: 0.869, Adjusted R-squared: 0.8066

F-statistic: 13.93 on 10 and 21 DF, p-value: 3.793e-07

pg. 7
EXP 5

> #exp 5

> #ABA LOGISTIC REGRESSION

> #binomial logistic regression

> str(mtcars)

'data.frame': 32 obs. of 11 variables:

$ mpg : num 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...

$ cyl : num 6 6 4 6 8 6 8 4 4 6 ...

$ disp: num 160 160 108 258 360 ...

$ hp : num 110 110 93 110 175 105 245 62 95 123 ...

$ drat: num 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...

$ wt : num 2.62 2.88 2.32 3.21 3.44 ...

$ qsec: num 16.5 17 18.6 19.4 17 ...

$ vs : num 0 0 1 1 0 1 0 1 1 1 ...

$ am : num 1 1 1 0 0 0 0 0 0 0 ...

$ gear: num 4 4 4 3 3 3 3 4 4 4 ...

$ carb: num 4 4 1 1 2 1 4 2 2 4 ...

> dt<-as.factor(mtcars$am)

> str(dt)

Factor w/ 2 levels "0","1": 2 2 2 1 1 1 1 1 1 1 ...

> am<-as.factor(mtcars$am)

> str(am)

Factor w/ 2 levels "0","1": 2 2 2 1 1 1 1 1 1 1 ...

> mt<-mtcars[,c(3:7)]

> dt<-sample(c(1,2),32,32)

> str(dt)

num [1:32] 2 1 1 1 1 1 1 2 1 2 ...

> dt<-as.factor(dt)

> md<-glm(dt~mtcars$mpg,family = 'binomial')

> md

pg. 8
Call: glm(formula = dt ~ mtcars$mpg, family = "binomial")

Coefficients:

(Intercept) mtcars$mpg

-0.202813 -0.002415

Degrees of Freedom: 31 Total (i.e. Null); 30 Residual

Null Deviance: 43.86

Residual Deviance: 43.86 AIC: 47.86

> summary(md)

Call:

glm(formula = dt ~ mtcars$mpg, family = "binomial")

Deviance Residuals:

Min 1Q Median 3Q Max

-1.082 -1.074 -1.066 1.281 1.299

Coefficients:

Estimate Std. Error z value Pr(>|z|)

(Intercept) -0.202813 1.258501 -0.161 0.872

mtcars$mpg -0.002415 0.060110 -0.040 0.968

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 43.860 on 31 degrees of freedom

Residual deviance: 43.858 on 30 degrees of freedom

AIC: 47.858

Number of Fisher Scoring iterations: 3

pg. 9
> library(nnet, lib.loc = "C:/Program Files/R/R-4.1.1/library")

> dt<-sample(1:4,32,32)

> #multinom logistic regression

> md<-multinom(dt~mtcars$mpg)

# weights: 12 (6 variable)

initial value 44.361420

iter 10 value 39.620203

final value 39.619342

converged

> md

Call:

multinom(formula = dt ~ mtcars$mpg)

Coefficients:

(Intercept) mtcars$mpg

2 1.5037549 -0.1088401

3 0.6804832 -0.0142661

4 -3.4490522 0.1509189

Residual Deviance: 79.23868

AIC: 91.23868

> summary(md)

Call:

multinom(formula = dt ~ mtcars$mpg)

Coefficients:

(Intercept) mtcars$mpg

2 1.5037549 -0.1088401

3 0.6804832 -0.0142661

4 -3.4490522 0.1509189

pg. 10
Std. Errors:

(Intercept) mtcars$mpg

2 2.309482 0.12598808

3 1.744554 0.08717987

4 2.173418 0.09592167

Residual Deviance: 79.23868

AIC: 91.23868

> #ordinal logistic regression

> library(MASS, lib.loc = "C:/Program Files/R/R-4.1.1/library")

> str(dt)

int [1:32] 4 3 4 3 2 1 1 3 3 2 ...

> dt<-factor(dt,levels = c(1,2,3,4),ordered = T)

> str(dt)

Ord.factor w/ 4 levels "1"<"2"<"3"<"4": 4 3 4 3 2 1 1 3 3 2 ...

> md<-polr(dt~mtcars$mpg)

> md<-polr(dt~mtcars$mpg,Hess = T)

> summary(md)

Call:

polr(formula = dt ~ mtcars$mpg, Hess = T)

Coefficients:

Value Std. Error t value

mtcars$mpg 0.1199 0.06425 1.866

Intercepts:

Value Std. Error t value

1|2 1.1288 1.2427 0.9083

2|3 1.8821 1.2534 1.5017

3|4 3.7377 1.4184 2.6352

Residual Deviance: 81.79075

AIC: 89.79075

pg. 11
EXP 6

> #EXP 6

> #ABA- MEDIATION ANALYSIS -K.CHATURVEDA

> dt<-trees

> library(psych)

> md<-mediate(x='Height',m='Volume',y='Girth',data=dt)

> print(md,short = F)

Mediation/Moderation Analysis

Call: mediate(y = "Girth", x = "Height", m = "Volume",

data = dt)

The DV (Y) was Girth . The IV (X) was Height . The mediating variable(s) = Volume .

Total effect(c) of Height on Girth = 0.26 S.E. = 0.08 t = 3.27 df= 29 with p = 0.0028

Direct effect (c') of Height on Girth removing Volume = -0.05 S.E. = 0.03 t = -1.61 df= 28
with p = 0.12

Indirect effect (ab) of Height on Girth through Volume = 0.3

Mean bootstrapped indirect effect = 0.3 with standard error = 0.08 Lower CI = 0.16 Upper CI =
0.46

R = 0.97 R2 = 0.94 F = 222.47 on 2 and 28 DF p-value: 1.25e-19

Full output

Call: mediate(y = "Girth", x = "Height", m = "Volume",

data = dt)

Direct effect estimates (traditional regression) (c') X + M on Y

Girth se t df Prob

Intercept 10.82 1.97 5.48 28 7.45e-06

Height -0.05 0.03 -1.61 28 1.19e-01

Volume 0.20 0.01 17.82 28 8.22e-17

pg. 12
R = 0.97 R2 = 0.94 F = 222.47 on 2 and 28 DF p-value: 6.5e-18

Total effect estimates (c) (X on Y)

Girth se t df Prob

Intercept -6.19 5.96 -1.04 29 0.30800

Height 0.26 0.08 3.27 29 0.00276

'a' effect estimates (X on M)

Volume se t df Prob

Intercept -87.12 29.27 -2.98 29 0.005830

Height 1.54 0.38 4.02 29 0.000378

'b' effect estimates (M on Y controlling for X)

Girth se t df Prob

Volume 0.2 0.01 17.82 28 8.22e-17

'ab' effect estimates (through mediators)

Girth boot sd lower upper

Height 0.3 0.3 0.08 0.16 0.46

pg. 13
EXP-7

> #exp 7

> #ABA MODRATION ANALYSIS -K.CHATURVEDA

> dt<-trees

> md<-lm(Height~Girth*Volume,data = dt)

> md

Call:

lm(formula = Height ~ Girth * Volume, data = dt)

Coefficients:

(Intercept) Girth Volume Girth:Volume

75.40148 -2.29632 1.86095 -0.05608

> summary(md)

Call:

lm(formula = Height ~ Girth * Volume, data = dt)

Residuals:

Min 1Q Median 3Q Max

-6.7781 -3.5574 -0.1512 2.3631 10.5879

Coefficients:

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

(Intercept) 75.40148 8.49147 8.880 1.7e-09 ***

Girth -2.29632 1.03601 -2.217 0.035270 *

Volume 1.86095 0.47932 3.882 0.000604 ***

Girth:Volume -0.05608 0.01909 -2.938 0.006689 **

---

Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

pg. 14
Residual standard error: 4.482 on 27 degrees of freedom

Multiple R-squared: 0.5546, Adjusted R-squared: 0.5051

F-statistic: 11.21 on 3 and 27 DF, p-value: 5.898e-05

pg. 15
EXP 8

> #exp9

> #ABA PRINCIPAL COMPONENT ANALYSIS

> dt<-attitude

> str(dt)

'data.frame': 30 obs. of 7 variables:

$ rating : num 43 63 71 61 81 43 58 71 72 67 ...

$ complaints: num 51 64 70 63 78 55 67 75 82 61 ...

$ privileges: num 30 51 68 45 56 49 42 50 72 45 ...

$ learning : num 39 54 69 47 66 44 56 55 67 47 ...

$ raises : num 61 63 76 54 71 54 66 70 71 62 ...

$ critical : num 92 73 86 84 83 49 68 66 83 80 ...

$ advance : num 45 47 48 35 47 34 35 41 31 41 ...

> md<-prcomp(rating)

Error in prcomp(rating) : object 'rating' not found

> md<-prcomp(dt)

> md

Standard deviations (1, .., p=7):

[1] 22.798964 11.581920 9.852083 9.232512 6.404264 5.073539

[7] 4.668443

Rotation (n x k) = (7 x 7):

PC1 PC2 PC3 PC4 PC5

rating 0.4467200 0.42184464 -0.2400295 0.1261907 -0.20102006

complaints 0.5206244 0.37207702 -0.1432265 -0.1081087 0.37237853

privileges 0.3757726 -0.07632652 0.6513217 -0.6263275 -0.07783612

learning 0.4209952 -0.14566925 0.1864780 0.4851365 -0.62078169

raises 0.3762536 -0.23339685 -0.2239163 0.1041004 0.44682483

critical 0.1300302 -0.39828981 -0.6330345 -0.5170667 -0.37798712

advance 0.2290738 -0.66592166 0.1095758 0.2579729 0.29490695

PC6 PC7

pg. 16
rating -0.47248738 0.5341317

complaints -0.02200456 -0.6474239

privileges 0.01814123 0.1734231

learning 0.30156007 -0.2347416

raises 0.59329347 0.4374176

critical -0.01806699 -0.1147434

advance -0.57678447 -0.0765914

> install.packages("factoextra")

WARNING: Rtools is required to build R packages but is not currently installed. Please download and
install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/

Installing package into ‘C:/Users/reddy/Documents/R/win-library/4.1’

(as ‘lib’ is unspecified)

also installing the dependencies ‘lazyeval’, ‘carData’, ‘crosstalk’, ‘viridis’, ‘car’, ‘DT’, ‘ellipse’,
‘flashClust’, ‘leaps’, ‘scatterplot3d’, ‘dendextend’, ‘FactoMineR’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/lazyeval_0.2.2.zip'

Content type 'application/zip' length 173419 bytes (169 KB)

downloaded 169 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/carData_3.0-4.zip'

Content type 'application/zip' length 1822339 bytes (1.7 MB)

downloaded 1.7 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/crosstalk_1.2.0.zip'

Content type 'application/zip' length 409618 bytes (400 KB)

downloaded 400 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/viridis_0.6.2.zip'

Content type 'application/zip' length 3000025 bytes (2.9 MB)

downloaded 2.9 MB

pg. 17
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/car_3.0-12.zip'

Content type 'application/zip' length 1413348 bytes (1.3 MB)

downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/DT_0.20.zip'

Content type 'application/zip' length 1830670 bytes (1.7 MB)

downloaded 1.7 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/ellipse_0.4.2.zip'

Content type 'application/zip' length 72291 bytes (70 KB)

downloaded 70 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/flashClust_1.01-2.zip'

Content type 'application/zip' length 36943 bytes (36 KB)

downloaded 36 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/leaps_3.1.zip'

Content type 'application/zip' length 103084 bytes (100 KB)

downloaded 100 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/scatterplot3d_0.3-41.zip'

Content type 'application/zip' length 338278 bytes (330 KB)

downloaded 330 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/dendextend_1.15.2.zip'

Content type 'application/zip' length 3890800 bytes (3.7 MB)

downloaded 3.7 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/FactoMineR_2.4.zip'

Content type 'application/zip' length 3758419 bytes (3.6 MB)

pg. 18
downloaded 3.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/factoextra_1.0.7.zip'

Content type 'application/zip' length 417133 bytes (407 KB)

downloaded 407 KB

package ‘lazyeval’ successfully unpacked and MD5 sums checked

package ‘carData’ successfully unpacked and MD5 sums checked

package ‘crosstalk’ successfully unpacked and MD5 sums checked

package ‘viridis’ successfully unpacked and MD5 sums checked

package ‘car’ successfully unpacked and MD5 sums checked

package ‘DT’ successfully unpacked and MD5 sums checked

package ‘ellipse’ successfully unpacked and MD5 sums checked

package ‘flashClust’ successfully unpacked and MD5 sums checked

package ‘leaps’ successfully unpacked and MD5 sums checked

package ‘scatterplot3d’ successfully unpacked and MD5 sums checked

package ‘dendextend’ successfully unpacked and MD5 sums checked

package ‘FactoMineR’ successfully unpacked and MD5 sums checked

package ‘factoextra’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in

C:\Users\reddy\AppData\Local\Temp\RtmpsXJTpT\downloaded_packages

> library(factoextra)

Loading required package: ggplot2

Attaching package: ‘ggplot2’

The following objects are masked from ‘package:psych’:

%+%, alpha

pg. 19
Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa

Warning message:

package ‘factoextra’ was built under R version 4.1.2

> fviz_eig(md)

pg. 20
EXP 10

> #exp 10

> #ABA CLUSTER ANALYSIS CHATURVEDA

> library(cluster, lib.loc = "C:/Program Files/R/R-4.1.1/library")

> library(NbClust)

> dt<-USArrests

> str(dt)

'data.frame': 50 obs. of 4 variables:

$ Murder : num 13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...

$ Assault : int 236 263 294 190 276 204 110 238 335 211 ...

$ UrbanPop: int 58 48 80 50 91 78 77 72 80 60 ...

$ Rape : num 21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8 ...

> dt$Assault<-as.numeric(dt$Assault)

> dt$UrbanPop<-as.numeric(dt$UrbanPop)

> str(dt)

'data.frame': 50 obs. of 4 variables:

$ Murder : num 13.2 10 8.1 8.8 9 7.9 3.3 5.9 15.4 17.4 ...

$ Assault : num 236 263 294 190 276 204 110 238 335 211 ...

$ UrbanPop: num 58 48 80 50 91 78 77 72 80 60 ...

$ Rape : num 21.2 44.5 31 19.5 40.6 38.7 11.1 15.8 31.9 25.8 ...

> NbClust(dt,method = 'complete')

Error in plot.new() : figure margins too large

In addition: Warning message:

In pf(beale, pp, df2) : NaNs produced

> NbClust(dt,method = 'complete')

*** : The Hubert index is a graphical method of determining the number of clusters.

In the plot of Hubert index, we seek a significant knee that corresponds to a

significant increase of the value of the measure i.e the significant peak in Hubert

index second differences plot.

*** : The D index is a graphical method of determining the number of clusters.

pg. 21
In the plot of D index, we seek a significant knee (the significant peak in Dindex

second differences plot) that corresponds to a significant increase of the value of

the measure.

*******************************************************************

* Among all indices:

* 7 proposed 2 as the best number of clusters

* 11 proposed 3 as the best number of clusters

* 1 proposed 6 as the best number of clusters

* 2 proposed 11 as the best number of clusters

* 3 proposed 15 as the best number of clusters

***** Conclusion *****

* According to the majority rule, the best number of clusters is 3

*******************************************************************

$All.index

KL CH Hartigan CCC Scott Marriot TrCovW TraceW Friedman Rubin Cindex DB


Silhouette Duda Pseudot2 Beale

2 2.7484 106.9905 62.2745 11.0340 225.9490 2.268713e+15 2035098647 110192.414 87.7922


18.6411 0.3493 0.5764 0.5763 0.3134 70.1152 5.1295

3 12.5168 150.8274 11.3540 9.8880 276.7118 1.849448e+15 313176246 47964.265 119.0856


42.8257 0.3775 0.6366 0.5319 0.5230 12.7699 2.0553

4 0.2839 125.8901 23.9736 8.7049 296.9867 2.191867e+15 171342493 38631.826 148.2522


53.1713 0.4135 0.6356 0.5000 0.3129 39.5217 5.0218

5 2.4327 146.3657 12.8730 9.6776 332.2164 1.692907e+15 70003283 25396.190 209.1949


80.8824 0.4336 0.6313 0.4713 0.3817 19.4368 3.6096

6 2.0103 149.7599 8.0290 9.7387 367.5585 1.202314e+15 37584350 19747.167 257.0256


104.0202 0.4130 0.6859 0.4561 0.6789 5.6766 1.0542

7 2.2030 145.5269 5.0351 9.4186 390.9434 1.025163e+15 31980866 16699.826 293.4762


123.0015 0.4093 0.9055 0.4135 0.6151 5.0060 1.3429

pg. 22
8 0.3533 136.8055 9.0419 8.8535 404.9117 1.012627e+15 24055494 14949.328 308.3085
137.4044 0.4099 1.0192 0.3837 0.3122 13.2186 4.5589

9 1.6765 143.1149 6.3337 9.0249 427.5631 8.147177e+14 13425501 12301.112 420.3586


166.9852 0.4134 0.9307 0.3932 0.3649 6.9626 3.3618

10 0.8074 143.9696 7.5625 8.9161 449.0028 6.550866e+14 9060265 10655.110 511.3989


192.7811 0.4623 0.8379 0.4007 0.1006 26.8341 16.1958

11 3.1807 150.9555 3.5219 9.0915 471.7238 5.031903e+14 6470333 8960.939 719.7569


229.2286 0.4755 0.7076 0.4184 188.9260 0.0000 0.0000

12 0.9683 146.1005 3.4295 8.6998 484.8934 4.601718e+14 5423590 8218.739 739.0346


249.9293 0.5123 0.6310 0.4498 11.4056 -5.4739 -1.8879

13 0.5501 142.4481 5.0238 8.3542 501.5279 3.872205e+14 4491203 7538.402 836.9277


272.4853 0.4954 0.6031 0.4382 0.4683 4.5414 2.1928

14 1.7295 145.6838 3.4164 8.3382 521.9335 2.985981e+14 3958619 6637.208 1032.5740


309.4831 0.5302 0.6426 0.4398 44.1568 -2.9321 -1.7697

15 0.8535 144.2386 3.7724 8.0889 538.6967 2.451377e+14 3664060 6061.935 1320.8021


338.8529 0.5354 0.6232 0.4534 4.2421 -2.2928 -1.3838

Ratkowsky Ball Ptbiserial Frey McClain Dunn Hubert SDindex Dindex SDbw

2 0.3797 55096.2071 0.6979 1.0644 0.3167 0.1533 0 0.0426 40.8403 0.7464

3 0.3849 15988.0885 0.6498 0.6244 0.6320 0.2503 0 0.0395 28.6403 0.3294

4 0.3387 9657.9564 0.6447 1.2331 0.6625 0.2948 0 0.0424 26.2844 0.0736

5 0.3205 5079.2379 0.5736 1.2538 0.8944 0.3438 0 0.0550 20.8217 0.0483

6 0.3072 3291.1945 0.5293 1.0390 1.0648 0.3031 0 0.0729 18.3104 0.0362

7 0.3048 2385.6894 0.4799 1.2690 1.2864 0.2908 0 0.0985 17.0665 0.0353

8 0.2944 1868.6660 0.4480 0.5442 1.4665 0.3107 0 0.1045 16.2498 0.0334

9 0.2795 1366.7902 0.4323 0.5674 1.5339 0.3418 0 0.1027 14.6818 0.0263

10 0.2695 1065.5110 0.4218 0.4409 1.5811 0.4014 0 0.1058 13.7373 0.0229

11 0.2577 814.6308 0.4152 0.4136 1.6009 0.4322 0 0.0971 12.4439 0.0172

12 0.2509 684.8949 0.4141 0.7641 1.6036 0.4519 0 0.0923 11.6733 0.0119

13 0.2436 579.8771 0.4039 0.7303 1.6620 0.4533 0 0.0958 11.0650 0.0107

14 0.2365 474.0863 0.3902 0.6754 1.7431 0.5090 0 0.1135 10.4001 0.0098

15 0.2294 404.1290 0.3840 0.6364 1.7800 0.5266 0 0.1199 9.8584 0.0088

$All.CriticalValues

CritValue_Duda CritValue_PseudoT2 Fvalue_Beale

pg. 23
2 0.4943 32.7341 0.0007

3 0.3357 27.7018 0.0990

4 0.3890 28.2672 0.0013

5 0.3008 27.8883 0.0119

6 0.3008 27.8883 0.3894

7 0.2019 31.6230 0.2756

8 0.1265 41.4361 0.0070

9 0.0160 246.4030 0.0353

10 -0.0628 -50.8045 0.0001

11 -0.5879 0.0000 NaN

12 0.1265 41.4361 1.0000

13 0.0160 246.4030 0.1161

14 -0.0628 -50.8045 1.0000

15 -0.0628 -50.8045 1.0000

$Best.nc

KL CH Hartigan CCC Scott Marriot TrCovW TraceW Friedman Rubin Cindex


DB Silhouette Duda PseudoT2 Beale

Number_clusters 3.0000 11.0000 3.0000 2.000 3.0000 3.000000e+00 3 3.00 15.0000


11.0000 2.0000 2.0000 2.0000 3.000 3.0000 6.0000

Value_Index 12.5168 150.9555 50.9205 11.034 50.7628 7.616833e+14 1721922401 52895.71


288.2281 -15.7469 0.3493 0.5764 0.5763 0.523 12.7699 1.0542

Ratkowsky Ball PtBiserial Frey McClain Dunn Hubert SDindex Dindex SDbw

Number_clusters 3.0000 3.00 2.0000 2.0000 2.0000 15.0000 0 3.0000 0 15.0000

Value_Index 0.3849 39108.12 0.6979 1.0644 0.3167 0.5266 0 0.0395 0 0.0088

$Best.partition

Alabama Alaska Arizona Arkansas California Colorado Connecticut


Delaware Florida Georgia

1 1 1 2 1 2 3 1 1 2

Hawaii Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana


Maine Maryland

3 3 1 3 3 3 3 1 3 1

pg. 24
Massachusetts Michigan Minnesota Mississippi Missouri Montana Nebraska
Nevada New Hampshire New Jersey

2 1 3 1 2 3 3 1 3 2

New Mexico New York North Carolina North Dakota Ohio Oklahoma Oregon
Pennsylvania Rhode Island South Carolina

1 1 1 3 3 2 2 3 2 1

South Dakota Tennessee Texas Utah Vermont Virginia Washington West


Virginia Wisconsin Wyoming

3 2 2 3 3 2 2 3 3 2

Warning message:

In pf(beale, pp, df2) : NaNs produced

> md<-kmeans(dt,3)

> clusplot(dt,md$cluster,shade = T)

Warning messages:

1: In doTryCatch(return(expr), name, parentenv, handler) :

display list redraw incomplete

2: In doTryCatch(return(expr), name, parentenv, handler) :

invalid graphics state

3: In doTryCatch(return(expr), name, parentenv, handler) :

invalid graphics state

pg. 25
4: In doTryCatch(return(expr), name, parentenv, handler) :

display list redraw incomplete

5: In doTryCatch(return(expr), name, parentenv, handler) :

invalid graphics state

6: In doTryCatch(return(expr), name, parentenv, handler) :

invalid graphics state

pg. 26
EXP 11

> #exp 11

> #ABA DISCRIMINATE ANALYSIS CHATURVEDA

> library(MASS, lib.loc = "C:/Program Files/R/R-4.1.1/library")

> dt<-USArrests

> head(dt)

Murder Assault UrbanPop Rape

Alabama 13.2 236 58 21.2

Alaska 10.0 263 48 44.5

Arizona 8.1 294 80 31.0

Arkansas 8.8 190 50 19.5

California 9.0 276 91 40.6

Colorado 7.9 204 78 38.7

> md<-lda(Murder~.,data = dt)

> md

Call:

lda(Murder ~ ., data = dt)

Prior probabilities of groups:

0.8 2.1 2.2 2.6 2.7 3.2 3.3 3.4 3.8 4 4.3

0.02 0.04 0.04 0.04 0.02 0.02 0.02 0.02 0.02 0.02 0.02

4.4 4.9 5.3 5.7 5.9 6 6.3 6.6 6.8 7.2 7.3

0.02 0.02 0.02 0.02 0.02 0.04 0.02 0.02 0.02 0.02 0.02

7.4 7.9 8.1 8.5 8.8 9 9.7 10 10.4 11.1 11.3

0.02 0.02 0.02 0.02 0.02 0.04 0.02 0.02 0.02 0.02 0.02

11.4 12.1 12.2 12.7 13 13.2 14.4 15.4 16.1 17.4

0.02 0.02 0.02 0.02 0.02 0.04 0.02 0.04 0.02 0.02

Group means:

Assault UrbanPop Rape

0.8 45.0 44.0 7.30

pg. 27
2.1 70.0 53.5 8.65

2.2 52.0 44.5 11.25

2.6 86.5 60.0 12.50

2.7 72.0 66.0 14.90

3.2 120.0 80.0 22.90

3.3 110.0 77.0 11.10

3.4 174.0 87.0 8.30

3.8 86.0 45.0 12.80

4 145.0 73.0 26.20

4.3 102.0 62.0 16.50

4.4 149.0 85.0 16.30

4.9 159.0 67.0 29.30

5.3 46.0 83.0 20.20

5.7 81.0 39.0 9.30

5.9 238.0 72.0 15.80

6 112.0 59.5 17.20

6.3 106.0 72.0 14.90

6.6 151.0 68.0 20.00

6.8 161.0 60.0 15.60

7.2 113.0 65.0 21.00

7.3 120.0 75.0 21.40

7.4 159.0 89.0 18.80

7.9 204.0 78.0 38.70

8.1 294.0 80.0 31.00

8.5 156.0 63.0 20.70

8.8 190.0 50.0 19.50

9 227.0 80.5 34.40

9.7 109.0 52.0 16.30

10 263.0 48.0 44.50

10.4 249.0 83.0 24.00

11.1 254.0 86.0 26.10

pg. 28
11.3 300.0 67.0 27.80

11.4 285.0 70.0 32.10

12.1 255.0 74.0 35.10

12.2 252.0 81.0 46.00

12.7 201.0 80.0 25.50

13 337.0 45.0 16.10

13.2 212.0 58.5 24.05

14.4 279.0 48.0 22.50

15.4 292.0 73.0 27.05

16.1 259.0 44.0 17.10

17.4 211.0 60.0 25.80

Coefficients of linear discriminants:

LD1 LD2 LD3

Assault 0.02038940 -0.02821854 -0.001846574

UrbanPop 0.04847377 0.03946608 -0.095054873

Rape -0.34985475 0.03364126 0.018963587

Proportion of trace:

LD1 LD2 LD3

0.4704 0.3804 0.1491

> summary(md)

Length Class Mode

prior 43 -none- numeric

counts 43 -none- numeric

means 129 -none- numeric

scaling 9 -none- numeric

lev 43 -none- character

svd 3 -none- numeric

N 1 -none- numeric

call 3 -none- call

terms 3 terms call

xlevels 0 -none- list

pg. 29
> partimat(Murder~.,data =dt)

pg. 30

You might also like