You are on page 1of 4

UNIVERSITY OF ZIMBABWE

BSc Honours in Statistics Level 2 HSTS204

STATISTICAL COMPUTING 2

May/June 2018
Time : 2 hours

Candidates should attempt ALL questions in section A and 2 questions in section B.


Marks will be allocated as indicated.

SECTION A (40 marks)


Candidates may attempt ALL questions being careful to number them A1 to A3.

A1. (a) What are the three arguments of a document title in LATEX? [3]
(b) Describe any two parameters of a document template in LATEX. [2]
(c) Without using the verbatim environment how else would you type the follow-
ing characters in LATEX:
(i) ` [1]
(ii) ˜ [1]
(iii) \ [1]
(d) Describe how to get opening single and double quotes in LATEX. [2]
(e) What are the effects of the following LATEX commands?
(i) \vspace{2in}.
[2]
(ii) \textsc{}.
[2]
(f) Describe the use and effects of the options [htbp] when inserting
graphics in a LATEX document. [4]

A2. (a) Briefly describe the use of a script in R and outline how to create one
and how to use it. [3]
(b) Differentiate between the two R help commands help("keyword") and
help.search("keyword") [2]
(c) Which are the two right-to-left assignment operators which can be used in
R. [2]
(d) State any three types of R objects. [3]

page 1 of 4
HSTS204

(e) What is the matrix multiplication operator in R? [1]

A3. (a) Describe the five STATA windows you get when you start up STATA. [5]
(b) Describe any 4 elements of the general STATA command syntax. [4]
(c) What commands do you type to change your working directory in R
and in STATA? [2]

SECTION B (60 marks)


Candidates may attempt TWO questions being careful to number them B4 to B6.

B4. (a) Describe how data is imported from STATA into R. [2]
(b) Describe how data is imported from Excel into R. [2]
(c) Give the command structure of estimating an ordinary least squares
regression model with an intercept in R. [3]
(d) Give the R command for finding the inverse of a matrix A. [1]
(e) Define a data frame in R. [2]
(f) Explain the terms attaching and dettaching a data frame as used in R. [4]
(g) Differentiate the use of the following environments in typing an
equation in LATEX:
\begin{math}...\end{math},

\begin{equation}...\end{equation},

and
\begin{displaymath}...\end{displaymath}.
[3]
(h) Which is the only required element of a STATA command syntax? [1]
(i) Describe, with the aid of an example, the use of the insheet, infile and infix com-
mands in STATA. [6]
(j) Give the STATA command for producing a scatter plot of variable Y on X1 . [2]
(k) Logical operators are a common feature in STATA programming.
Distinguish between the following pairs of operators:
(i) == and = [2]
(ii) ! and | [2]

B5. (a) Explain the uses of both the do-file and the log-file in STATA. [3,3]

page 2 of 4
HSTS204

(b) Explain, giving an example, any three ways in which the label command may
be used in STATA. [6]
(c) How do you change a string variable containing numbers to numeric in
STATA. [2]
(d) Explain the effects of the following STATA command:

recode age (0/5=1 "Under5") (5/14=2 "young")


(15/24=3 "adolescent"), generate(ageg) label(ageg)
[4]
(e) Explain the uses of the following commands pertaining to the normal
distribution in R:
dnorm, pnorm, qnorm, and rnorm. [4]
(f) A vector capturing the marital status of 10 respondents is as follows:

(married, single, single, widowed, divorced, married, widowed, seperated, married,


widowed).
To ease data capturing and analysis the following coding is adopted:
1=single, 2=married, 3=widowed, 4=divoced, 5=seperated.
Describe the procedure for capturing this vector in R as a factor
variable/vector. [6]
(g) The results from 10 tosses of a coin are as follows: (H, T, H, H, T, T, H, T, T, H).
What command would you type in R to capture this as a vector of
string values? [2]

B6. On a fresh page write the output of the following LATEX commands:
(Use A4 bond paper provided)

\documentclass[a4paper 12pt]{article}
\usepackage[centertags]{amsmath}
\title{\begin{Large} UNIVERSITY OF ZIMBABWE \end{Large}}
\author{\underline {BSc Honours in Statistics Level 2} \\
HSTS204 STATISTICAL COMPUTING 2 Practical}
\date{\begin{flushleft}August 2016
\begin{flushright}Time :2 Hours \end{flushright}}
\begin{document}
\maketitle

Mathematical formulae in LATEX \footnote{ LATEX is the


best typesetting programme for the sciences}

\begin{enumerate}

page 3 of 4
HSTS204

\item
$
\textbf{S}=\left(\begin{array}{cc}4.46&-3.40\\
-3.40&5.35\\
\end{array}\right)
$

\item The Weibull probability density function is


given by
\begin{center}
$f(x)=abxˆ{b-1}eˆ{-axˆb},$ \ $x>0$, $a>0$ and $b>0$.
\end{center}

\item \begin{equation}
$$y_{i}\sim f(\alpha;\beta_{i})= \frac{1}{\beta_{i}ˆ
{\alpha}\Gamma(\alpha)}y_{i}ˆ{\alpha-1}eˆ{-\frac{y_{i}
}{\beta_{i}}}$$
\label{est}\end{equation}
\item $\frac{\left(\frac{1-\sqrt{\Lambda}}{\sqrt
{\Lambda}}\right)\left(\sum n_i-g-1\right)}{(g-1)}
\sim F_{2(g-1),2(\sum n_i-g-1)$
\item The table below looks nice.
\begin{footnotesize}
\begin{table}[h]
\begin{tabular}{|r|cccc|cccc|cccc|}\hline
&\multicolumn{12}{|c|}{\Huge Values in appropriate
units}\\\cline{2-13}
Machine&\multicolumn{4}{|c|}{$I$}&\multicolumn{4}
{|c|}{$II$}&\multicolumn{4}{|c|}{$III$}\\\hline
Fibre strength (Y)&36&41&39&42&49&40&48&39&45&
44&35&37\\\hline
Diameter(X)&20&25&24&25&32&22&28&22&30&28&21
&23\\\hline
\end{tabular}
\caption{Machine profiles }
\end{table}
\end{footnotesize}
\end{enumerate}
\end{document}

Please pay attention to detail. [30]

END OF EXAMINATION

page 4 of 4

You might also like