SECTION A
I. Answer any 6 questions, each question carries 2 marks: (6x2=12)
1. What is a Lists?
Lists are a heterogeneous data structure and can contain many
different types of elements inside it. The elements of a list can be
numeric, characters, vectors, character vectors, matrices, arrays,
lists, and functions.
2. What is an array?
Arrays are n-dimensional homogeneous data structures. While
matrices are confined to two dimensions, arrays can be of any
number of dimensions. For example, an array of dimensions (2, 3,
3) contains 3 rectangular matrices each with 2 rows and 3 columns.
The array function takes a dim attribute which creates the required
number of dimension.
3. Mention two output statements in R?
Print() and cat().
4. What is a Package?
Packages in R are essential tools for expanding the capabilities of
R by adding new functions, datasets, and even compiled code.
They are a fundamental part of the R ecosystem, allowing users to
perform a wide range of tasks, from data manipulation to statistical
analysis and graphical representation.
5. What is probability?
Probability in R is the measure of the likelihood that an event will
occur. The probability of an event A, denoted as P(A), lies
between 0 and 1, where 0 indicates impossibility and 1 indicates
certainty.
6. What is Median and Mode?
The mean is the average of a data set.
, The mode is the most common number in a data set.
7. What is Error?
Errors most often occur when code is used in a way that it is not
intended to be used.
8. List two components of a hypothesis test?
H0 - Null Hypothesis
HA - Alternate Hypothesis
9. Mention any two method names for linear model selection?
Select a subset of features to include in a linear model.
Use shrinkage methods to constrain the flexibility of linear
models.
Reduce the dimensionality of the data for a linear model.
SECTION B
II. Answer any 4 questions, each question carries 6 marks: (4x6=24)
10. What is R? Describe the basic features of the R Program.
R is a free and open-source programming language and software
environment for statistical computing and graphics. The R
language is widely used among statisticians and data miners for
developing statistical software and data analysis.
Features:
One of key strength of R is the ease with which a well-designed
and high-quality plots can be produced, including mathematical
symbols and formula wherever needed.
R is an integrated suite of software facilities for data manipulation,
calculation and graphical display. It includes:
o An effective data handling and storage facility.
o A suite of operators for calculations on arrays, in particular
matrices.
o A large, coherent, integrated collection of intermediate tools for
data analysis.
o Graphical facilities for data analysis and display either on-screen or
on hard-copy.
, o A well-developed, simple and effective programming language
which includes conditionals, loops, user-defined recursive
functions and input and output facilities.
R has its own LaTeX-like documentation format, which is used for
comprehensive documentation.
R is available as Free Software under the terms of the Free
Software Foundation’s GNU General Public License in source code
form. It compiles and runs on a wide variety of UNIX platforms
and similar systems (including FreeBSD and Linux), Windows and
MacOS.
11. Write a note on Matrix data structure.
Matrices are two-dimensional, homogeneous data structures.
Matrices are not a separate type of object but simply an atomic
vector with dimensions; the number of rows and columns. As like
atomic vectors, the elements of a matrix must be of the same data
type.
A Matrix can be created using a vector input to the matrix function.
Example:
#creating a matrix
mat <- matrix( c(10, 20, 30, 40, 50, 60),
nrow = 2, ncol = 3,
byrow = TRUE)
#printing the matrix
print(mat)
The output of the above code will be:
[,1] [,2] [,3]
[1,] 10 20 30
[2,] 40 50 60
12. Explain any two if-statements in R with syntax and examples.
If Statement
The If statement is used to execute a block of code when the
condition is evaluated to be true. When the condition is evaluated
to be false, the program will skip the if-code block.
, Syntax
if (condition) {
statements
}
In the example below, the if code block is created which executes
only when the variable i is divisible by 3.
i <- 15
if (i %% 3 == 0){
sprintf("%d is divisible by 3.", i)
}
The output of the above code will be:
[1] "15 is divisible by 3."
If-else Statement
The else statement is always used with if statement. It is used to
execute block of codes whenever if condition gives false result.
Syntax
if (condition) {
statements
} else {
statements
}
In the example below, else statement is used to print a message if
the variable i is not divisible by 3.
i <- 16
if (i %% 3 == 0) {
sprintf("%d is divisible by 3.", i)
} else {
sprintf("%d is not divisible by 3.", i)
}
The output of the above code will be:
[1] "16 is not divisible by 3."
13. Explain poisson distribution in R.