Reference no: EM132245725
Question - One important application in remote sensor systems is the localization of a system node based on received signal strength indication (RSSI) measurements. Suppose m stationary nodes equipped with radio signal receivers are deployed in an environment, which is mathematically a region within R2. Suppose an additional mobile node to be localized is equipped with a radio signal transmitter. The strength of the signal (RSSI) received at each stationary node is inversely proportional to the distance between that node and the mobile node (that is, the transmission distance).
The Weibull density is often used to model survival times, and other positive random variables. Parameterizations vary, but it commonly incorporates a shape parameter κ > 0 and scale parameter μ > 0 as follows:
f(z; κ, μ) = κ/μ (z/μ)κ-1 e-(z/μ)κ, z ≥ 0.
Then suppose Y is an RSSI measurement which is calibrated so that Z = 1/Y has a Weibull distribution where κ = 8.25 and μ is the transmission distance. There are m = 3 stationary nodes, labeled i = 1, 2, 3, located on the two-dimensional deployment region at coordinates (in miles):
(x1, y1) = (-0.50, 0.00)
(x2, y2) = (0.42, 2.00)
(x3, y3) = (1.50, 1.27).
Suppose θ = (θx, θy) is the current location of the mobile node. After transmitting a radio signal, three RSSI measurements (Y1, Y2, Y3) = (0.926, 0.943, 0.787) are collected from the respective stationary nodes. Assume the RSSI measurements are independent.
(a) The object is to construct a Bayesian model for the inference of θ = (θx, θy). For the prior density π(θ), use a uniform distribution over some large enough region containing all nodes. Then accept as the data the reciprocals Z = (Z1, Z2, Z3) = (1/Y1, 1/Y2, 1/Y3). Write explicitly the conditional density of Z given θ, say f(z1, z2, z3 | θ), and then give the posterior density of θ given Z = z, say π(θ | z1, z2, z3). Note that the posterior density need not be normalized.
(b) Evaluate the posterior density on a two-dimensional grid, with x and y coordinates defined as follows
xgrid = seq(-0.7,1.0,0.01)
ygrid = seq(-0.1,1.8,0.01)
That is, π(θ | z1, z2, z3) is evaluated in a rectangle θx ∈ [-0.7, 1.0] and θy ∈ [-0.1, 1.8], with spacing δ = 0.01 between grid points in each axis direction. Use the data given here for the values (z1, z2, z3). Use the persp function to create a 3-dimensional image of this density. Use options theta=0, phi=30.
HINT: In R, densities and distribution functions can usually be evaluated on a logarithmic scale, using the log = TRUE or log.p = TRUE option, as appropriate. This is far preferable for an application like this. A good strategy would be to write a function which evaluates and returns the density on a logarithmic scale, which can later be exponentiated if needed. Again, note that the posterior density need not be normalized.
(c) In this example, the maximum likelihood estimate θ^MLE will be the value of θ which maximizes π(θ|z1, z2, z3) (assuming there is only one global maximum). Why is this the case? Use the grid evaluation of Part (b) to obtain an approximation of θ^MLE. HINT: This can be done with the which function, using the arr.ind = TRUE option.
(d) Create a Hastings-Metropolis algorithm to simulate a sample from π(θ|z1, z2, z3). Implement the following features:
(i) Use as a proposal rule something like theta.new = theta.old + runif(2, -1/10, 1/10). This means the resulting state space is not discrete, but the algorithm will work in much the same way.
Under this proposal rule we can take 1 = Q(θ2|θ1)/Q(θ1|θ2) when calculating the acceptance probability.
(ii) Allow N = 100, 000 transitions. Capture in a single object all sampled values of θ. You can used θ = (0, 0) as the initial state. HINT: When constructing an MCMC algorithm, rather than calculate a ratio of densities, it is better to calculate a difference Δ in log-densities, and then calculate the exponential function of the difference, that is, eΔ. For this reason, the function constructed in Part (b) should return log-densities.
(e) The posterior density is defined on a two-dimensional plane. There are a number of R functions that can be used to visualize functions or densities defined on R2.
(i) Use the smoothScatter function to plot the sampled θ values (this function is part of the graphics library). Rather than draw a simple scatter plot, this function draws a heat map representation of the sample density. Essentially, a deeper color shade indicates a higher density of sampled points. Use options xlim = c(-1, 1.5),ylim=c(-0.5, 2.1). Include horizontal and vertical axes lines which pass through the origin (0, 0) (you can use the abline function for this). Also indicate the locations of the three stationary nodes (you can use the points function for this). Then indicate the location of θ^MLE, using a distinct symbol for clarity.
(ii) Superimpose on your plot a contour plot of the posterior density evaluated in Part (b). Use the contour function with the add = TRUE option.
(f) One advantage of the use of MCMC sampling to estimate posterior densities is that various forms of inference become easy to implement. For example, suppose there is interest in the distance of the mobile node from the origin (0, 0). Use the MCMC to estimate the posterior density of this distance. This can be done by first transforming the sampled values of θ, then constructing a histogram of these transformed values.