0% found this document useful (0 votes)
32 views2 pages

Assessment 1 PDF

The document generates random positive numbers between 10 and 20, arranges them in a 3x10 matrix with rows named X, Y, and Z. It then calculates various statistics on the data including: 1) The skewness of Y is 0.3273618 2) A multiple regression line is fitted for Y on X and Z 3) The first four moments about the origin are calculated for X
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Assessment 1 PDF

The document generates random positive numbers between 10 and 20, arranges them in a 3x10 matrix with rows named X, Y, and Z. It then calculates various statistics on the data including: 1) The skewness of Y is 0.3273618 2) A multiple regression line is fitted for Y on X and Z 3) The first four moments about the origin are calculated for X
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Name:S.

Shankar
Reg.No:19BEC1191

Generate a data set which has 30 random positive numbers between 10 and 20.
Arrange the data set in 3 rows and name it as X, Y and Z.
> p=sample(10:20,30,replace=TRUE)
> p
[1] 11 18 17 19 12 15 13 13 18 11 15 14 15 11 14 10 11 16 10 19 12 17 20
12 18 20 19 19 12 12
> table=matrix(p,3,10,TRUE)
> table
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 11 18 17 19 12 15 13 13 18 11
[2,] 15 14 15 11 14 10 11 16 10 19
[3,] 12 17 20 12 18 20 19 19 12 12
> x=table[1,]
> x
[1] 11 18 17 19 12 15 13 13 18 11
> y=table[2,]
> y
[1] 15 14 15 11 14 10 11 16 10 19
> z=table[3,]
> z
[1] 12 17 20 12 18 20 19 19 12 12
(ii) Skewness of Y

> library(moments)
> skewness(y)
[1] 0.3273618

(iii) Find the multiple regression line of Y on X and Z

> fit=lm(y~x+z)
> fit

Call:
lm(formula = y ~ x + z)

Coefficients:
(Intercept) x z
22.9307 -0.5316 -0.1004

(iv) First four moments of X about origin

> all.moments(x,4)
[1] 1.0 14.7 224.7 3559.5 58155.9
(i) Find the correlation matrix of X,Y and Z

> cor(table)
[,1] [,2] [,3] [,4] [,5] [,6]
[,7] [,8] [,9]
[1,] 1.00000000 -1.00000000 -0.6362848 -0.7714543 0.05241424 -0.7205767
-0.50000000 0.2401922 -0.84615385
[2,] -1.00000000 1.00000000 0.6362848 0.7714543 -0.05241424 0.7205767
0.50000000 -0.2401922 0.84615385
[3,] -0.63628476 0.63628476 1.0000000 0.0000000 0.73704347 0.9933993
0.98624138 0.5960396 0.12725695
[4,] -0.77145428 0.77145428 0.0000000 1.0000000 -0.67584534 0.1147079
-0.16531163 -0.8029551 0.99186978
[5,] 0.05241424 -0.05241424 0.7370435 -0.6758453 1.00000000 0.6546537
0.83862787 0.9819805 -0.57655666
[6,] -0.72057669 0.72057669 0.9933993 0.1147079 0.65465367 1.0000000
0.96076892 0.5000000 0.24019223
[7,] -0.50000000 0.50000000 0.9862414 -0.1653116 0.83862787 0.9607689
1.00000000 0.7205767 -0.03846154
[8,] 0.24019223 -0.24019223 0.5960396 -0.8029551 0.98198051 0.5000000
0.72057669 1.0000000 -0.72057669
[9,] -0.84615385 0.84615385 0.1272570 0.9918698 -0.57655666 0.2401922
-0.03846154 -0.7205767 1.00000000
[10,] 0.99186978 -0.99186978 -0.7292846 -0.6842105 -0.07509393 -0.8029551
-0.60614265 0.1147079 -0.77145428
[,10]
[1,] 0.99186978
[2,] -0.99186978
[3,] -0.72928455
[4,] -0.68421053
[5,] -0.07509393
[6,] -0.80295507
[7,] -0.60614265
[8,] 0.11470787
[9,] -0.77145428
[10,] 1.00000000

(v) Plot the regression line Y on Z


r1=lm(y~z)
> r1

Call:
lm(formula = y ~ z)

Coefficients:
(Intercept) z
14.92178 -0.08831
> plot(y,z)
> abline(r1)

You might also like