You are on page 1of 4

231

UNIVERSITY OF ZIMBABWE
BSc Honours in Actuarial Science Level 2 HASC216

STATISTICAL COMPUTING FOR ACTUARIAL SCIENCE

February 2020
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 A4.

A1. (a) Explain the difference between input and output when typing a document in
LATEX and in Microsoft Word. [4]
(b) Differentiate between an environment and a command in LATEX. [4]

A2. (a) Differentiate between the following pairs of LATEX environments:


(i) enumerate and itemize, [2]
(ii) displaymath and equation, and [2]
(iii) table and tabular. [2]
(b) Without using the verbatim command, how would you type the following spe-
cial characters in LATEX to be part of the output text;
(i) # [1]
(ii) % [1]
(iii) \ [1]
(iv) ˆ [1]

A3. (a) Explain the use of the following R commands


(i) windows(record=T), [1]
(ii) dev.new(), and [1]
(iii) dev.off(2). [1]
(b) Describe the use and effects of the options [htbp] when inserting
graphics in a LATEX document. [4]

page 1 of 4
HASC216

A4. (a) Describe the five STATA windows you get when you start up STATA. [5]
(b) Which are the two right-to-left assignment operators which can be used in
R. [2]
(c) The STATA commands follow a standard syntax structure. Give and explain
any FOUR syntax elements. [8]

SECTION B (60 marks)


Candidates may attempt TWO questions being careful to number them B5 to B7.

B5. Consider the data below.

Reg Name Year of Sex Marks (%)


No birth 1=Male 2=Female Test 1 Assign 1 Test 2 Test 3
regno stud yob sex t1 a1 t2 t3
A1 Dube P 2001 2 83 90 76 81
A2 Carter A 2002 1 65 86 75 86
A3 Willie S 1998 1 29 95 56 63
A4 Mpofu Z 1999 2 87 80 77 82
A5 Dziva H 1998 2 71 79 72 65

The second row of the table as variable names. Write one STATA do-file with all the
commands to perform the following tasks:

(a) Declare your delimiter and create a log named hsts204exam, which can be
opened in any plain text editor, such as Notepad. [4]
(b) Capture the data using the commands methods. [10]
(c) Label all variables. [2]
(d) Label values for Sex of student. [2]
(e) Compute the age of the students, name the variable age and label it accord-
ingly. [2]
(f) Compute the coursework for each student which is given by the average of the
4 pieces of work, name it cw. [2]
(g) Recode the course into the following labelled categories : <50 Fail , 50-59
Pass, 60-64 Credit, 65-74 Merit, 75+ Distinction, name the variable
CWcat and label it accordingly [3]
(h) Save your data naming the file using your UZ registration number. [1]
(i) Produce frequency tables for variable sex. [1]
(j) Produce descriptive statistics for cw . [2]
(k) Close your log file. [1]

page 2 of 4
HASC216

B6. (a) What is attaching and detaching a data frame in R? [2]


(b) Write the display of the following R loop function:
for(i in 1:5){ print(1:(i+2))} [3]
(c) Differentiate the use of the R commands
par(mfrow=c(3,2))and par(mfcol=c(3,2)) [3]
(d) Give three ways of creating a numeric vector in R, giving examples of each. [6]
(e) Explain three different ways/functions of creating a matrix in R. [6]
(f) Explain the uses of the following commands in R explicitly specifying the
arguments of the functions :
dnorm,
pnorm,
qnrom, and
rnorm . [8]
(g) Give the STATA commands for converting a string variable to numeric
specifying the alternative options for the command. [2]

B7. (a) A script file with the contents below was created and saved with the name
trialdata.
# trialdata
k=c(0,1,2,3,4)
x =c(109,65, 22, 3, 1)
p =x / sum(x)
print(p)
r =sum(k *p)
v =sum(x *(k - r)ˆ2) / 199
print(r)
print(v)
f =dpois(k, r)
print(cbind(k, p, f))
(i) Give the command you would type to run the script file above if it was
saved in your working directory. [2]
(ii) EXPLAIN the effects of each of the command lines of the script file above. [8]
(b) On the next page (page 4) of this question paper is an article. Write down what
you would type (text and commands) in LATEX to produce this document
(the whole page). [20]

END OF EXAMINATION

page 3 of 4
HASC216

UNIVERSITY OF ZIMBABWE
HSTS204/HASC216 LATEX Q6 Article
February 2020

(a) LATEX IS A VERY USEFUL APPLICATION

(b)
yij = β0 + βˆ1 xi + β2 xj + ij (1)
α α2
(c) σ = β
σ1 = β6

(d) Consider the following table1

Table 1: Classes of students at a college


Marks (%)
Name Reg No Test 1 Test 2 Test 3 CW
Solonglife Zvanguzvakaitakare R190001A 15 20 25 20
Thathekile Anythinggoes R190002B 29 33 31 31
Sibotshwa Socialmedia R190003C 49 56 57 54
Focused Lifenotagame R190004D 68 75 76 73
Givingitmyall Tisuanhuacho R190005E 81 95 91 89

1
Use it to classify yourself

page 4 of 4

You might also like