Write an R function that accepts X and Z as input

Assignment Help Mathematics
Reference no: EM131478241

Q1. A Hidden Markov Model in discrete time is a stochastic process involving two layers: (i) a hidden state which forms a Markov chain, and (ii) an observed state, which, given the hidden state, is independently distributed across time. The following is an example:

The hidden states Z1, Z2, . . . follow a two state Markov chain (with states 0 and 1) with transition probability matrix

1590_Figure.png

where π00 + π01 = 1 and π10 + π11 = 1. This means, for each i,

P(Zi+1 = l|Zi = k) = πkl, for k, l ∈ {0, 1}.

Given, Zi = k, we observe Xi ∼ N(µk, σ2k), for k = 0, 1, independently for each i. Here µ0, µ1 are real numbers and σ0, σ1 > 0.

(a) Write an R function that takes the following input: π00, π10, µ0, µ1, σ0, σ1, n and Z0 (the initial state of Z), to generate the processes (X1, . . . , Xn) and (Z1, . . . , Zn). Set default values of all the parameters, in your function definition. The function should return all the parameters, and two vectors containing the values of Xi's and Zi's.

(b) Generate a data set with n = 200, π00 = 0.8, π10 = 0.2, µ0 = 0, µ1 = 2, σ0 = σ1 = 1, and Z0 = 0.

(c) Generate a data set with n = 200, π00 = 0.8, π10 = 0.2, µ0 = µ1 = 0, σ0 = 1, σ1 = 4, and Z0 = 0.

(d) Assuming that you only observe the Xi's, for each of (b) and (c), compute the following statistics: (i) Ui = j=1i Xj, i = 1, . . . , n; and (ii) Vi = j=1i X2j - i(X-i)2, i = 1, . . . , n, where X-i = (j=1i Xj)/i.

(e) Based on your results in (d), can you say which of the statistics (among (i) and (ii)) provides information about the transitions in the hidden states {Z1, . . . , Zn}? Justify your answer. [Hint: It will help to plot the values of Ui's and Vi's against index i.]

Q2. Suppose we are given a set of bivariate observations (Xi, Zi) for i = 1, . . . , n, where Zi's are categorical, that is, Zi's can take a finite number of distinct values. We want to see whether the values of Xi's differ for the different categories of the Z variable. In the following, we assume that we have two different vectors X = (X1, . . . , Xn) and Z = (Z1, . . . , Zn) as our data.

(a) Write an R function that accepts X and Z as input and returns the following output:

(i) The set of distinct values of the variable Z;

(ii) The sets of indices for which Z takes these values;

(ii) Mean and standard deviation of X corresponding to the distinct values of Z.

You must avoid using for or while loops when writing this function.

(b) Now suppose we consider the data set generated in 1(b). Treat both X = (X1, . . . , Xn) and Z = (Z1, . . . , Zn) as observed. Use the function created in 2(a) to check whether the Xi's corresponding to different values of Z are from the same population. Provide a brief argument to justify your answer. Clearly state any assumption you are making and any result that you are using.

(c) Write an R function to repeat the process in 2(b) m times (i.e., generate the data following 1(b) m times, and in each case decide whether the populations for distinct Zi's are the same). Report the success rate of your decision rule for m = 100.

Reference no: EM131478241

Questions Cloud

What makes tax law even more complex : Overview of Tax Research- What makes tax law even more complex is that it is full of areas that are either not clear, incomplete, or usually both.
Briefly describe the process of installing a shell pile : Briefly describe and contrast typical slope failure in a pure cohesionless soil and a pure cohesive soil.
Explain what type of effort it will take to fully address it : Compare its significance to the national priorities of Healthy People 2020 goals (is it a national priority or just one found in your state/community).
Additional external research source : You must use one additional external research source in addition to the text. Your answers should not be less than 500 word each question.
Write an R function that accepts X and Z as input : STA 141A Spring 2017 Homework. Write an R function that accepts X and Z as input and returns the following output: The set of distinct values of the variable Z;
Occupational and safety and health law : We cover the Occupational and Safety and Health Law of 1970 (OSHA) this week. This groundbreaking law took decades to become a reality
Learning aid about workforce retention : For this assignment, assume that you are the new Director of Human Resources for a mid-sized healthcare organization.
The democrats against republican donald trump : Would Bernie Sanders have been a better candidate for the Democrats against Republican Donald Trump than Hillary Clinton was?
Explain the key characteristics of a whistleblower : Describe the key characteristics of a whistleblower, and briefly summarize one researched instance of whistleblowing in one publicly traded company.

Reviews

len1478241

4/29/2017 2:46:08 AM

Submit the assignment both electronically (through smartsite) and by submitting the printed copy. The electronic submission must be in the form of a zip folder (with extension .zip, .7z, etc.) containing two files: (i) descriptions of your analysis (as appropriate) and results; (ii) codes used. Honor Code: “The codes and results derived by using these codes constitute my own work. I have consulted the following resources regarding this assignment:” (ADD: names of persons or web resources, if any, excluding the instructor, TAs, and materials posted on course website).

Write a Review

Mathematics Questions & Answers

  Questions on ferris wheel

Prepare a Flexible Budget Gator Divers is a company that provides diving services such as underwater ship repairs to clients in the Tampa Bay area.

  Logistic map

This assignment has two question related to maths. Questions are related to bifurcation cascade and logistic map.

  Finding the probability of cards

This assignment has questions related to probabiltiy.

  Systems of ode

Find all the xed points, and study their stability and Draw the phase portrait of the system, as well as the graphs of the solutions in all relevant cases.

  Derive the boolean expression

Derive the Boolean Expression and construct the switching circuit for the truth table stated

  System of equations

Evaluate which equations are under-identified, just-identified, and over-identified.

  Linear programming problem

Linear programming problem consisting of only two constraints with one objective function.

  Find the natural domain

Find the natural domain of the given functions.

  Introduction to numerical methods

Compute the coecients of the polynomials using the term recurrence relation.

  Chart of the topological manifold

De?nition of smoothness of functions on a smooth manifold is chart independent and hence geometric.

  Mathematics in computing

Questions related on mathematics in computing.

  Complex problems

Complex problems

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd