0% found this document useful (0 votes)
35 views

University of Zimbabwe: Time: 2 Hours

This document provides instructions for a statistical computing exam consisting of two sections - Section A with 4 multiple choice questions and Section B with 3 long answer questions. Candidates are required to attempt all questions in Section A and 2 out of 3 questions in Section B. The questions test knowledge of LaTeX, R and Stata.

Uploaded by

lynn zigara
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)
35 views

University of Zimbabwe: Time: 2 Hours

This document provides instructions for a statistical computing exam consisting of two sections - Section A with 4 multiple choice questions and Section B with 3 long answer questions. Candidates are required to attempt all questions in Section A and 2 out of 3 questions in Section B. The questions test knowledge of LaTeX, R and Stata.

Uploaded by

lynn zigara
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/ 5

231

UNIVERSITY OF ZIMBABWE
HSTS204
BSc Honours in Statistics and Actuarial Science Level 2 HASC216

STATISTICAL COMPUTING 2

November/December 2019
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) LATEX is the application used for typesetting dissertations in the Statistics De-
partment. Give any three advantages of using LATEX over word processors like
Microsoft Word. [3]

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


(i) enumerate and itemize, [2]
(ii) math and displaymath, and [2]
(iii) table and tabular. [2]
(b) Explain the use of the following special characters in LATEX;
(i) # [1]
(ii) {} [1]
(iii) % [1]
(iv) \ [1]
(v) ˆ [1]

page 1 of 5
HSTS204/HASC216

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


(i) windows(record=T), [1]
(ii) dev.new(), [1]
(iii) dev.set(3), and [1]
(iv) dev.off(3). [1]
(b) Differentiate the use of the read.table, read.delim, read.csv and
read.csv2 commands in R. [4]

A4. (a) What is the use of a log file in STATA? [1]


(b) Differentiate the two types of log files that can be created for use
in STATA? [2]
(c) Explain the effects of the options: text, replace, append on a STATA
command for creating a log file. [3]
(d) With the help of an example, differentiate the use of the four commands used
for supplying data in STATA: input, insheet, infile, and infix. [8]

SECTION B (60 marks)


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

B5. Consider the CSPro dictionary file below.

(a) The above CSPro dictionary was used in a survey and the survey responses
data was saved in fixed format in the working folder as file hhdata.dat.
Write one STATA do-file with all the commands to perform the following tasks:
(i) Declare your delimiter and create a log named hsts204exam, which can
be opened in any plain text editor, such as Notepad. [2]
(ii) Import the .dat [2]
(iii) Label the data set as ‘Household data’. [1]
(iv) Label all variables. [2]

page 2 of 5
HSTS204/HASC216

(v) Insert a note for the variable A6: ‘The expenditure includes food, non food
and fees expenses for the household’. [2]
(vi) Label the values for Sex of head of household, where the following code
scheme applies: 1=Male, 2=Female. [2]
(vii) Compute the age of the head of household, name the variable agehhh and
label it accordingly. [2]
(viii) Recode the ages of the household heads into the following labelled cate-
gories : <18 Child head , 18-24 Young adult, 25-40 Lower middle
age , 41-59 Upper middle age, 60+ Elderly, name the
variable agehhCAT and label it accordingly [3]
(ix) Save your data naming the file using your UZ registration number. [1]
(x) Produce frequency tables for variable A1. [1]
(xi) Produce descriptive statistics for A5 . [2]
(xii) Regress A7 on A8. [2]
(xiii) Close your log file. [1]
(b) The same data set generated by the CSPro dictionary above was saved as a
comma delimited file (.csv) which has the variable names on the first row.
(i) Write the R command to import and store the data in the workspace. [2]
(ii) Variable A3 is a categorical variable with the following coding scheme:
1=single, 2=married, 3=widowed, 4=divorced, 5=separated.
Upon importation into R, variable A3 has been treated as an integer vari-
able. Write the commands to correct this and attach the value set to A3. [5]

B6. (a) As used in R language, what is a data frame? [1]


(b) What is attaching and detaching a data frame? [2]
(c) Consider the following R commands in a session showing how the function
rep can be used.
>x<-c(3, 22, 5, 7)
> rep(x, times=2)
> rep(x, times=c(1, 2, 2 ,3))
> rep(x, length.out=8)
> rep(1:3, each=2)
> rep(1:3, times=c(1:3))
Give the results of each of the command lines number 2-6 [5]
(d) Give three different ways of creating the matrix
1 1 2
 
 0 2 2 
A=  in R. [6]
 
 1 0 1 
1 4 1

page 3 of 5
HSTS204/HASC216

(e) Explain the uses of the following commands in R explicitly specifying the
arguments of the functions :
dpois(x, λ),
ppois(q, λ),
qpois(p, λ), and
rpois(n, λ) . [8]
(f) What does the STATA command clear do? [1]
(g) Give the STATA commands for converting a string variable to numeric speci-
fying the alternative options for the command. [2]
(h) Describe the five STATA windows you get when you start up STATA. [5]

B7. (a) What is an R script file and what command would you type to execute one? [2]
(b) Consider five numeric vectors of equal length in R: Y, X1, X2, X3, X4.
Give the R commands to display four plots of Y against each of the X’s on the
same page. [5]
(c) The standard structure of STATA commands usually follows the syntax:
[by varlist:] command [varlist] [=exp] [if exp] [in range] [weight]
[using filename] [,options] .
Describe any 3 syntax elements. [3]
(d) On the next page (page 5) 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 4 of 5
HSTS204/HASC216

UNIVERSITY OF ZIMBABWE
HSTS204/HASC216 LATEX Q6 Article
November 2019

(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 5 of 5

You might also like