<table width = 900 border = 0><tr><td>
# <b>NMST539 | Lab Test No.2</b>

### <font color = "#880000">LS 2017 | Tuesday 23/05/2017 </font>
###### <a href = "pisomka2017_2.Rmd">Rmd file (UTF8 encoding)</a>

**************
### <font color = "#880000"><b>Data description</b></font>
The data file contains results on a geography questionaire in primary schools in the Czech Republic and Slovakia taking place in 2015. 
The questionaire was designed to test the geographical knowledge of students and their skill to read in geographical maps. 
To be more specific, the test compares the skill of students from three different grades (formally 11 years old students denoted as <i>grade11</i>, 15 years students denoted as <i>grade15</i>, and 18 years old students denoted as <i>grade18</i>).<br><br>

Each student was asked to answer 21 geographical questions while each question was a multiple type question with set of multiple answers which were provided in the test. Each student was supposed to select the right answer(s) (it was possible that more than just one answer was correct). The questions in the test were carefully designed as follows: the first seven questions in the test should be easily answered by all grade students (in general, the knowledge of the 11 "years" old students was required). The next set of questions, questions 8-14, where more difficult, and they were assumed to be correctly answered by the 15 "years" old (grade) students (but they should be also able to correctly answer the easier set of questions). Finaly, the last set of questions, questions 15-21, were meant test the skills of the oldest students - the 18 "years" old (grade) students.  However, <b>each student had to answer all 21 questions</b> (the first grade students were just assumed to have enought knowledge to correctly answer questions 1-7, the second grade students were assumed to have enough knowledge to be able to answer questions 1-14, and finaly, the third grade students should be educated enough to answer all 21 questions properly). In the given dataset there is only some partial information on each student's performance provided: the overal percentual gain from the first set of questions (covariate `tot1`), the overall percentual gain for the second set of questions (covariate `tot2`), and finaly, the percentual gain for the last set of questions (covariate `tot3`). The covariate `total`
denotes the overall percentual gain calculated as (`tot1` + `tot2` + `tot3`)/3. <br><br>

The dataset contains 2048 observations (individual students)  and 14 different covariates. A detailed description of 
all covariates is provided below. 

<ul>
<li><b>country</b> - two level factor distinguishing for the country ('cz' or 'sk');</li>
<li><b>gender</b> - student's gender ('male' or 'female');</li>
<li><b>age</b> - student's age (given in years);</li>
<li><b>class</b> - student's grage ('grade11' for 11 year old students, 'grade15' for 15 years old students, and 'grade18' for 18 years old students). The grade should optimaly reflect the real age of the student however, this is not always true (some students 
had to repeat some grade, some were upgraded to proceed facter for instance).</li>
<li><b>Nsibs</b> - the number of siblings;</li>
<li><b>sibOrder</b> - the order among siblings (1 for the oldest, 'Nsib' value for the youngest);</li>
<li><b>studTime</b> - the number of hours per one week spent by studying geography (student's subjective opinion); </li>
<li><b>Ftravel</b> - traveling frequency  (0 = student does not travel, 5 = strudent travels a lot);</li>
<li><b>grade</b> - the overall geography mark on the last cerificate (1 = best, 5 = worst);</li>
<li><b>popularity</b> - popularity/preferency of the geography class (1 = I like it a lot, 3 = I do not like it);</li>
<li><b>total</b> - the overall percentual gain from the geography test (all 21 questions together);</li>
<li><b>tot1</b> -  percentual gain from the first set of questions (questions 1--7);</li>
<li><b>tot2</b> -  percentual gain from the second set of questions (questions 8--14);</li>
<li><b>tot3</b> -  percentual gain from the last set of questions ( questions 15--21);</li>
</ul>


The corresponding data file can be loaded into the R working environment by running the following command: 

```{r, warning = F, message = F}
rm(list = ls())
data <- read.csv("http://msekce.karlin.mff.cuni.cz/~maciak/NMST539/geoDataExt.csv", header = T)
attach(data)
head(data)
```
<hr size="3" width="100%" noshade style="color:#440000" align="left" />

<br><br>
<hr size="3" width="100%" noshade style="color:#440000" align="left" />
### <font color = "#880000"><b>Questions and task for the individual work</b></font>
<hr size="3" width="100%" noshade style="color:#440000" align="left" />

<ul>
<li>Consider the given dataset and use some graphical tools available in the R software to find some interesting 
structures hidded in the data. Interpret and carrefully explain the provided figures. Try to provide some "interesting"
outputs. </li>

<li>The dataset can be formally considered to be made out of two datasets: the first dataset includes the student's specific covariates - those are covariates in columns 1--10, while the second dataset, covariates in columns 11--14 express each student's performance in the geographical test.  <br>
Consider these two datasets and apply the canonical correlation approach. Interpret the results and provide some discussion. </li>

<li>Use the cluster analysis and try to find some well-interpretable clusters. Are there some natural covariates in the data, which 
could be used to classify students into the given clusters (e.g. some linear discrimination rule)?</li>
</ul>

<hr size="3" width="100%" noshade style="color:#440000" align="left" />
### <font color = "#880000"><b>End of the individual work</b></font>
<hr size="3" width="100%" noshade style="color:#440000" align="left" />

<br><br>

#### <font color = "#880000"><b>Technical details and final instructions</b></font>
<ul>
<li>The work is supposed to be evaluated individually, by each student separately.</li>
<li>It is necessary to submit either a PDF file or an HTML file (both can be created using the RStudio software and the `Sweave` or `Knitr` package). Do not provide the R source code in your report, but  rather state some important results and clearly discuss your important findings. Interpret the results and provide some graphical tools for a better visualization of the results. </li>

<li>If you use the first option (PDF file submission), you need to create the <i>.Rnw</i> file (same approach you used for the homework assignments for instance), which you can later compile in the RStudio software to create the final PDF file. In the second case (HTML file submission), you need to create the <i>.Rmd</i> file, similarly as we did it for the lab sessions, and again, you can compile it in the RStudio to create the   HTML file at the end.</li>
<li>If you make a decision to create the HTML file instead, you can directly use the source file of this lab test assignment (see 
the download link in the header of this page).


</li>
<li>Rename the submission file as <b>surname_givenName.pdf</b> or <b>surname_givenName.html</b>.
</li>

<li>The final PDF (or the HTML) file should to be sent via email to one of the following adresses:
<ul><li><i>maciak *AT* ualberta.ca</li>
<li>maciak *AT* karlin.mff.cuni.cz</li></ul>
<font color = "red">not later than three minutes after the lab session ends (not later than 12:13).</font>


</ul>
<hr size="3" width="100%" noshade style="color:#440000" align="left" />
<br><br>
</td></tr></table>
<br><br><br>