General notes
Use RMarkdown (or knitr) used to produce the PDF-handin. See the Learn Announcement about working in the free web based RStudio.cloud if you do not have a local rstudio installation.
Ordinary text should be typset as test, and not as R code chunk comments. Use LaTeX math typsetting with $ $ for inline formulas and $$ $$ for displayed equations (see lecture 8).
The code in the CWB2020code.R file should be included via source(), and not included in your report.
• Write readable code.
• Do not hide R code with echo=FALSE.
To hide unnecessary R output, such as long data listings, with results=’hide’ as RMarkdown code chunk
Avoid unneccessarily repeating identical code, for example when adding to a previous plot, use the pl + new stuff() technique for ggplot().
Suggested RMarkdown startup code chunk:Text Box: set.seed(12345L) source("CWB2020code.R")
suppressPackageStartupMessages(library(tidyverse)) theme_set(theme_bw())
# Read data for part 2 of the assignment:
filament <- read.csv("filamentCWB.csv", stringsAsFactors = FALSE)
# Note: this is a different data file than in CWA.
The functions from CWB2020code.R that you need to call in your own code are either mentioned in the text or part of provided code outlines. Look at the code file for documentation, and to see functions that are used internally and that you do not need to call yourself.
Part 1: Archaeology
“Anno Domini MCCCLXI feria III post Jacobi ante portas Visby in manibus Danorum ceciderunt Gutenses, hic sepulti, orate pro eis!”
“In the year of our Lord 1361, on the third day after St. Jacob, the Goth fell outside the gates of Visby at the hands of the Danish. They are buried here. Pray for them!”
In 1361 the Danish king Valdemar Atterdag conquered Gotland1 and cap- tured the rich Hanseatic town of Visby. The conquest was followed by a plunder of Visby. Most of the defenders2 were killed in the attack and are buried in a field, Korsbetningen3, outside of the walls of Visby.In the 1920s the gravesite was subject to several archaeological excavations. A total of 493 femurs4 (256 left, and 237 right) were found. We want to figure out how many persons were likely buried at the gravesite. It must reasonably have been at least 256, but how many more?
Statistical model
To build a simple model for this problem, we assume that the number of left (y1 = 256) and right (y2 = 237) femurs are two independent observations from a Bin(N, φ) distribution. Here N is the total number of people buried and φ is the probability of finding a femur, left or right, and both N and φ are unknown parameters.The probability function for a single observation y ∼ Bin(N, φ) is y p(y|N, φ) = N φy(1 − φ)N−y.
The function arch loglike() in CWB2020code.R evaluates the combined log- likelihood log[p(y N, φ)] for a collection y of y-observations. If a data.frame with columns N and phi is provided, the log-likelihood for each row-pair (N, φ) is returned.
Questions
1. An archaeological researcher tries to obtain 95% confidence intervals for N and φ. They realise that since φ must fall in the finite interval (0, 1), it is
1Strategically located in the middle of the Baltic sea, Gotland had shifting periods of being partly self-governed, and in partial control by the Hanseatic trading alliance, Sweden, Denmark, and the Denmark-Norway-Sweden union, until settling as part of Sweden in 1645. Gotland has an abundance of archaeological treasures, with coins dating back to Viking era trade routes via Russia to the Arab Caliphates.
2Primarily local farmers that could not take shelter inside the city walls.
3Literal translation: the grazing field that is marked by a cross, as shown in the picture.
4thigh bone
reasonable to reparameterise to θ = log(φ) log(1 φ), the so-called logit - transformation of φ. They then attempt to apply Maximum Likelihood theory to N and θ, where the estimates are assumed to be approximately Gaussian, by running the following code: like_est <- arch_likelihood_estimation(c(256, 237))
The code automatically transforms the confidence interval limits for θ back to the φ scale, as φ = 1/(1 + eθ), and they obtain the intervals
CIN = (−51, 827),
CIφ = (0.073, 0.975).
After also introducing a log-transformation for N in the internal calcu- lations,5 the computed confidence interval for N changes to (125, 1199), with only minor changes to the confidence interval for φ.
Explain, in words, what is problematic with these frequentistic confidence intervals. What assumptions were violated?
2. You should now do a Bayesian analysis of the problem (see Lecture 8), to make an improvement over the researchers failed frequentistic attempt.
Let N have a Geometric(ξ), ξ > 0, prior distribution, and let φ have a Beta(a, b), a, b > 0, prior distribution:
pN (n) = P(N = n) = ξ (1 − ξ)n, n = 0, 1, 2, 3, . . . ,
φa−1(1 − φ)b−1
pφ(φ) = B(a, b) , φ ∈ [0, 1].
Before the excavation took place, the archaeologist believed that around 1000 individuals were buried, and that they would find around half on the femurs. To encode that belief in the Bayesian analysis, set ξ = 1/(1 + 1000), which corresponds to an expected total count of 1000, and a = b = 2, which makes φ more likely to be close to 1/2 than to 0 or 1
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme