You are on page 1of 6

Roll No: --------------

COLLEGES, GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD


External Semester Examination Spring 2022
Degree/ Discipline BS Statistics (8th Semester) Objective Part
Course Code: STA-604 Time: 30 Minutes Marks: 20
Course Title: Statistical Computing-II Credit hours: 3(0-3)
Q. No. 01 Choose the correct answer:

1: All columns in a matrix must have the:


(a) Same data type (b) integer data type (c) Character data type (d) None of these
2: A data frame can be converted into a matrix by _______ command:
(a) is.matrix (b) as.matrix (c) cbind (d) None of these
3: dim (MAT) is used to get number of ______ of matrix MAT.
(a) Rows and Columns (b) Rows (c) Columns (d) None of these
4: In R the command read.table is used to:
(a) Import data (b) Cross-tabulation (c) export data (d) None of these
5: Which of the following command will find minimum value of the vector x?
(a) max(x) (b) min(x) (c) lowest(x) (d) Any of these
6: The output of the command seq (from=1, to=10, by=2) will be _________
(a) 1,2,3,4,5,6,7,8,9,10 (b) 1,10,2 (c) 1,3,5,7,9 (d) None of these
7: The output of the command rep (c (1,3,8), 2) will be____:
(a) 1,3,8,1,3,8 (b) 1,1,3,3,8,8 (c) 1,3,8,2 (d) None of these
8: If we want to retain only integer part of a number, then which command can be used
(a) is.integer (b) as.integer (c) number.integer (d) None of these
9: In R, for multiplying two matrices X and Y, the command will be____
(a) X%*%Y (b) X*Y (c) X%%Y (d) None of these
10: The random number following continuous uniform distribution can be generated using function_____
(a) pnorm (b) runif (c) dbinom (d) None of these
11: In R, the transpose of a matrix X can be obtained using____
(a) transpose(X) (b) t(X) (c) X.t (d) None of these
12: In R, the transpose of a matrix X can be obtained using___________
(a) inverse(X) (b) inv(X) (c) solve(X) (d) None of these
13: Which of the following command will create a matrix with 4 rows and 2 colums?
(a) matrix (1:8, nrow=4) (b) matrix(1:4) (c) matrix(1:8) (d) None of these
th
14: To print 5 element of a vector Y in R, we will use following command_____
(a) Y[1:5] (b) Y(5) (c) Y[5] (d) None of these
th
15: To print all elements of a vector Y but not 5 element in R, we will use following command_:
(a) Y[–1: –5] (b) –Y(5) (c) Y[–5] (d) None of these
16: If X=7 and Y=10, then the output of command X>Y will be:
(a) –3 (b) TRUE (c) FALSE (d) None of these
17: Suppose we want to load an add-on package “DescTools” in R, which of these commands will be executed?
(a) install (DescTools) (b) library (DescTools) (c) attach (add-on) (d) None of these
18: In R, the command to compute standard deviation of a vector is______
(a) sd(x) (b) std(x) (c) SD(x) (d) None of these
19: To compute correlation between variable x and y, which function is used in R?
(a) cor(x,y) (b) correlation (x,y) (c) correlate (x,y) (d) None of these
20: Diagonal elements of a matrix A can be extracted using_______
(a) diag (A) (b) diagonal (A) (c) Trace (A) (d) None of these

----------------------------------------------------------------------------------------------------------------------------- -------------
Roll No: --------------

COLLEGES, GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD


External Semester Examination Spring 2022
Degree/ Discipline BS Statistics (8th Semester) Objective Part
Course Code: STA-604 Time: 30 Minutes Marks: 20
Course Title: Statistical Computing-II Credit hours: 3(0-3)
Q. No. 01 Choose the correct answer:

1: In R, object name cannot start with:


(a) Numbers (b) Capital letters (c) Small letters (d) None of these
2: The output of seq(from=10, to=1, by=-2) is
(a) 10 8 6 4 2 (b) 10 8 6 4 (c)8 6 4 2 0 (d) None of these
3: Which of the following command will find the 30th percentile for the variable x
(a) quantile (x, 0.30) (b) quantile (x, P30) (c) quantile (x, 30) (d) None of these
4: A list is represented as a vector but can contain objects of _______
(a) Different type (b) Same type (c) integer type (d) None of these
5: How many elements will be in vector b, if b = 2:7
(a) 06 (b) 07 (c) 27 (d) None of these
6: To create an identity matrix of order 5, which command will be executed?
(a) identity (5) (b) diag (5) (c) diag(5,5) (d) None of these
7: In R, the command det(X) will compute ______ of matrix X.
(a) determinant (b) inverse (c) trace (d) None of these
8: Suppose we want to print element located in 5th row and 3 column of matrix B, which command must be
executed:
(a) B[3,5] (b) B[c(5,3)] (c) B[5,3] (d) B (5,3)
9: In R, linear regression of Y on X1 and X2 can be performed using command ________
(a) lm (Y~X1, X2) (b) lm(Y~X1) +lm(Y~X2) (c) lm(Y~X1+X2) (d) None of these
10: In R, the box and whisker plot of a variable x can be created using__________
(a) box(x) (b) box.whisker (x) (c) boxplot(x) (d) box.plot(x)
11: The scatter diagram of variables X and Y can be plotted using _____
(a) plot (X, Y) (b) plot(X+Y) (c) scatter (X, Y) (d) scatter.plot(X,Y)
12: In R, the output of the command 22%%4 will be _______
(a) 2 (b) 5 (c) 5.5 (d) Error
13: In R, the output of the command 22%/%4 will be _______
(a) 2 (b) 5 (c) 5.5 (d) Error
14: To compute median of a vector y, which of following command can be used?
(a) average (y, median) (b) MED (y) (c) median (y) (d) None of these
15: Which of the following cannot be computed with built-in R packages?
(a) Geometric mean (b) Harmonic mean (c) Coefficient of Skewness (d) All of these
16: Basically, there are _____ type of operators in R
(a) Two (b) Three (c) Six (d) None of these
17: To check which folder is being used as working directory in current R session, command is _____
(a) get.directory() (b) working () (c) getwd() (d) None of these
18: Suppose we have a matrix A in R, then output of the command class(A) will be______
(a) "matrix" (b) TRUE (c) FALSE (d) None of these
19: If X is matrix, then command var(X) will give _____
(a) Variances of columns of X (b) variance-covariance matrix of X
(c) Unit matrix (d) None of these
20: To make all columns of a data frame D directly accessible in current R environment, the command will
be____
(a) load(D) (b) data.frame(D) (c) attach(D) (d) None of these

----------------------------------------------------------------------------------------------------------------------------- -------------
Roll No: --------------

COLLEGES, GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD


External Semester Examination Spring 2022
Degree/ Discipline BS Statistics (8th Semester) Objective Part
Course Code: STA-604 Time: 30 Minutes Marks: 20
Course Title: Statistical Computing-II Credit hours: 3(0-3)
Q. No. 01 Choose the correct answer:

1: In R the command read.table is used to:


(b) Import data (b) Cross-tabulation (c) export data (d) None of these
2: The output of the command rep (c (1,3,8), 2) will be____:
(b) 1,3,8,1,3,8 (b) 1,1,3,3,8,8 (c) 1,3,8,2 (d) None of these
3: In R, for multiplying two matrices X and Y, the command will be____
(b) X%*%Y (b) X*Y (c) X%%Y (d) None of these
4: The random number following continuous uniform distribution can be generated using function_____
(b) pnorm (b) runif (c) dbinom (d) None of these
5: In R, the transpose of a matrix X can be obtained using____
(b) transpose(X) (b) t(X) (c) X.t (d) None of these
6: In R, the transpose of a matrix X can be obtained using___________
(b) inverse(X) (b) inv(X) (c) solve(X) (d) None of these
7: Which of the following command will create a matrix with 4 rows and 2 colums?
(b) matrix (1:8, nrow=4) (b) matrix(1:4) (c) matrix(1:8) (d) None of these
8: If X=7 and Y=10, then the output of command X>Y will be:
(b) –3 (b) TRUE (c) FALSE (d) None of these
9: In R, the command to compute standard deviation of a vector is______
(b) sd(x) (b) std(x) (c) SD(x) (d) None of these
10: To compute correlation between variable x and y, which function is used in R?
(b) cor(x,y) (b) correlation (x,y) (c) correlate (x,y) (d) None of these
11: Which of the following command will find the 30th percentile for the variable x
(a) quantile (x, 0.30) (b) quantile (x, P30) (c) quantile (x, 30) (d) None of these
12: A list is represented as a vector but can contain objects of _______
(a) Different type (b) Same type (c) integer type (d) None of these
13: To create an identity matrix of order 5, which command will be executed?
(a) identity (5) (b) diag (5) (c) diag(5,5) (d) None of these
14: In R, the command det(X) will compute ______ of matrix X.
(a) determinant (b) inverse (c) trace (d) None of these
15: In R, linear regression of Y on X1 and X2 can be performed using command ________
(a) lm (Y~X1, X2) (b) lm(Y~X1) +lm(Y~X2) (c) lm(Y~X1+X2) (d) None of these
16: In R, the output of the command 22%%4 will be _______
(a) 2 (b) 5 (c) 5.5 (d) Error
17: In R, the output of the command 22%/%4 will be _______
(a) 2 (b) 5 (c) 5.5 (d) Error
18: To compute median of a vector y, which of following command can be used?
(a) average (y, median) (b) MED (y) (c) median (y) (d) None of these
19: Which of the following cannot be computed with built-in R packages?
(a) Geometric mean (b) Harmonic mean (c) Coefficient of Skewness (d) All of these
20: To check which folder is being used as working directory in current R session, command is _____
(a) get.directory() (b) working () (c) getwd() (d) None of these

------------------------------------------------------------------------------------------------------------------------------------------
Roll No: --------------

COLLEGES, GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD


External Semester Examination Spring 2022
Degree/ Discipline BS Statistics (8th Semester) Subjective Part
Course Code: STA-604 Time: 03:00 Hours Marks: 100
Course Title: Statistical Computing-II Credit hours: 3(0-3)
Note: Attempt all questions. All questions carry equal marks.

Question # 1: Consider the following sample values,

3,9,13,10,8,10,12,8,18,14,13,11,15,12,17,19,13,17,15,16,17,18,20,
22,25,23,22,25,26,29,30,31,32,33,27,26,28,29,26,24,23,22,21,20,18

Write R commands to compute: length, sum, mean, median, 90th percentile, variance, standard deviation and
product of the vector containing these observations (20)

Question # 2: Suppose you have following vectors available in R environment,

Y 227.2 196 278.7 272.3 267.4 254.5 224.7 181.5 227.5


X1 694.85 638.1 774.55 757.9 753.35 704.7 666.8 568.55 653.1
X2 37 36.76 34.62 35.4 35.96 36.26 36.34 35.9 31.84
X3 15.83 16.41 13.1 13.63 14.51 15.38 16.1 16.73 10.58
Write R command(s) to:
(a) Create a single matrix X from the vectors X1, X2 and X3. (03)
(b) Calculate variance-covariance matrix of X. (03)
(c) Calculate correlation matrix of X. (03)
(d) Compute inverse of correlation matrix obtained in (c). (03)
(e) What is determinant of correlation matrix obtained in (c). (03)
(f) Run linear regression of Y on X1, X2 and X3. (05)

Question # 3 (a): Let you have vector of values in R environment, write R commands to: (10)

(i) compute natural log (ii) compute square root (iii) Round to 2 decimals
(iv) Retain the integer part (v) compute product of vector

Question # 3 (a): For the following sample,

X=34.46,34.6,35.38,35.85,35.68,35.35,35.04,34.07,32.2,34.32,31.08

Write R commands to test the hypothesis that population mean is 35 against alternative that it is not 35.
Use 5% level of significance. (10)

Question # 4 (a): For a binomial random variable X with parameters n  12 and P  0.7 , write R command(s) to
compute: (10)

(i) P( X  3 ) (ii) P( X  4 ) (iii) P( X  9 ) (iv) P( 4  X  7 )

Question # 4 (b): Write an R function/programme that takes a vector as input and returns Range and Coefficient of
Range as output (the function must work for vector of any length). (10)

Question # 5 (a): Write an R function/programme that takes a vector as input and returns its Geometric mean as output
(the function must work for vector of any length). (10)

Question # 5 (b): Let you have a vector of " n " observations. If it is decided that any value that falls outside the limits
X  3  S.DX  will be considered as an outlier. Write a function/program in R that takes vector as
input and returns (i) Observations which are outlier (ii) Percentage of outliers in the original vector
as output. (10)
Roll No: --------------

COLLEGES, GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD


External Semester Examination Spring 2022
Degree/ Discipline BS Statistics (8th Semester) Subjective Part
Course Code: STA-604 Time: 03:00 Hours Marks: 100
Course Title: Statistical Computing-II Credit hours: 3(0-3)
Note: Attempt all questions. All questions carry equal marks.

Question # 1: Write R commands to compute: mean, median, variance, standard deviation, lower quartile and upper
quartile of the vector containing the following sample values. (20)

3,9,13,10,8,10,12,8,18,14,13,11,15,12,17,19,13,17,15,16,17,18,20,
22,25,23,22,25,26,29,30,31,32,33,27,26,28,29,26,24,23,22,21,20,18

Question # 2: Suppose you have following vectors available in R environment,

Y 227.2 196 278.7 272.3 267.4 254.5 224.7 181.5 227.5


X1 694.85 638.1 774.55 757.9 753.35 704.7 666.8 568.55 653.1
X2 37 36.76 34.62 35.4 35.96 36.26 36.34 35.9 31.84
X3 15.83 16.41 13.1 13.63 14.51 15.38 16.1 16.73 10.58
Write R command(s) to:
(a) Create a single matrix X from the vectors X1, X2 and X3. (03)
(b) Calculate variance-covariance matrix of X. (03)
(c) Calculate correlation matrix of X. (03)
(d) Compute inverse of correlation matrix obtained in (c). (03)
(e) What is determinant of correlation matrix obtained in (c). (03)
(f) Run linear regression of Y on X1, X2 and X3. (05)

Question # 3: Consider the following samples of X and Y,

X = 34.46,34.6,35.38,35.85,35.68,35.35,35.04,34.07,32.2,34.32,31.08

Y = 34.14,34.85,35.89,33.53,33.79,34.72,35.22,36.5,37.6,37.89,37.71

Write R commands to test the hypothesis that

(i) population variances are equal against the alternative that they are not equal. (10)
(ii) population means are equal against the alternative that they are not equal. (10)

Question # 4 (a): A random variable X is normally distributed with mean 50 and standard deviation 10. Write R
command(s) to find the probability that random variable X takes a value: (10)

(i) between 55 and 100 (ii) greater than 54 (iii) smaller than 57

(iv) Find value of random variable X having 77% are to right.

Question # 4 (b): Write an R function/programme that takes a vector as input and returns its Harmonic mean as output
(the function must work for vector of any length). (10)

n
Question # 5 (a): Write a function/program in R that takes two numbers n and r as input and Pr (n permutation r)
as output. (10)

Question # 5 (b): Write a function/program in R that takes a vector as input and returns its mean deviation from mean
as output. (10)
Roll No: --------------

COLLEGES, GOVERNMENT COLLEGE UNIVERSITY, FAISALABAD


External Semester Examination Spring 2022
Degree/ Discipline BS Statistics (8th Semester) Subjective Part
Course Code: STA-604 Time: 03:00 Hours Marks: 100
Course Title: Statistical Computing-II Credit hours: 3(0-3)
Note: Attempt all questions. All questions carry equal marks.

Question # 1 (a): Samples from each of four populations (G1, G2, G3, and G4) have been taken and the data is given,
Write R commands to test the hypothesis that means of the four populations are equal (using a
significance level of 5%)? (10)

Sample (G1) Sample (G2) Sample (G3) Sample (G4)


40 76 45 53
50 65 38 63
60 66 60 58
65 50 42 61

Question # 1 (b): Suppose you have following vectors available in R environment,

Y 227.2 196 278.7 272.3 267.4 254.5 224.7 181.5 227.5


X1 694.85 638.1 774.55 757.9 753.35 704.7 666.8 568.55 653.1
X2 37 36.76 34.62 35.4 35.96 36.26 36.34 35.9 31.84
X3 15.83 16.41 13.1 13.63 14.51 15.38 16.1 16.73 10.58
Write R command(s) to:
(i) run linear regression of Y on X1, X2 and X3. (05)
(ii) Print the summary results of linear regression run in part (i). (05)

Question # 2: From the following sample values,

3,9,13,10,8,10,12,8,18,14,13,11,15,12,17,19,13,17,15,16,17,18,20,
22,25,23,22,25,26,29,30,31,32,33,27,26,28,29,26,24,23,22,21,20,18

Write R commands to compute: length, sum, mean, median, 90th percentile, variance, standard deviation and
product of the vector containing these observations (20)

Question # 3: Consider the following samples of X and Y,

X = 34.46,34.6,35.38,35.85,35.68,35.35,35.04,34.07,32.2,34.32,31.08

Y = 34.14,34.85,35.89,33.53,33.79,34.72,35.22,36.5,37.6,37.89,37.71

Write R commands to test the hypothesis that

(i) population variances are equal against the alternative that they are not equal. (10)
(ii) population means are equal against the alternative that they are not equal. (10)

Question # 4 (b): For a binomial random variable X with parameters n  12 and P  0.7 , write R command(s) to
compute to give results: (10)

(i) P( X  3 ) (ii) P( X  4 ) (iii) P( X  9 ) (iv) P( 4  X  7 )

Question # 4 (b): Write an R function/programme that takes a vector as input and returns Range and Coefficient of
Range as output (the function must work for vector of any length). (10)

Question # 5 (a): Write an R function/programme that takes a vector as input and returns its Geometric mean as output
(the function must work for vector of any length). (10)

Question # 5 (b): Write an R function/programme that takes a vector as input and returns Coefficient of variation as
output (the function must work for vector of any length). (10)

You might also like