Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Part a and b is done and in the code below, in java public class H4_Q2 { public static void main(String[] args) { //Declare and

image text in transcribed

Part a and b is done and in the code below, in java

public class H4_Q2 { public static void main(String[] args) { //Declare and initialize //2D array result int[][] result = {{ 500 , 700 }, { 250,300 }, {333,800}, {400,1000}}; //For debugging purpose for (int i = 0; i   For the upcoming Arkansas Presidential primary, favorability results for 4 candidates are given in Table 1 based on a collected sample. The second column in the table provides the number of people that view that candidate i favorably (2). The third column in the table provides the number of people asked about each candidate i (ni). Number Questioned (n) 700 Number Favorable (x) 500 250 333 400 Candidate 1 Candidate 2 Candidate 3 Candidate 4 300 800 1000 Table 1: Favorability Results From this information, we can estimate the proportion of people questioned that favor candidate i with the formula and denote the result i. For example, 500 Pi = = 71.4.% 700 which means that 71.4% of the people sampled had a favorable opionion of Candidate 1. In this question, you will use these sample proportions to create confidence intervals on the true proporition of the population that view each candidate favorably. a. Add code to H4_Q2 that declares and initializes a two-dimensional array named results with the integer values in columns 2 and 3 of Table 1. Your array should be 4 x 2. b. In H4_Q2 add a one-dimensinoal array of doubles named z_values initialized with the values 1.96 and 2.576. c. In H4_Q2 add code that calculates a 95% and 99% confidence interval on the proportion of responses that were favorable for each candidate. For a 95% confidence interval, the z-value is 1.96 and for a 99% confidence interval the z-value is 2.576. Given a specfied z-value (2) the formula for a confidence interval on proportion i is given by Pi(1 - D) P - 21 n Pi(1 - i) n d. (In H4_Q2) Print your results to the screen. Each row of your results should have the number of the candidate (e.g. Candidate 1), followed by the two confidence intervals calculated for the candidate (in the same order given in part d.). For example: Candidatel : (25,.75); (.1,-9) is an example of what one row of output should look like. Note that the numeric results are not correct in this example. Notice that in your results the width of the 95% confidence interval should be smaller than the 99% confidence interval. This is correct because a 99% confidence interval calls for a lower acceptable error (1% instead of 5%). To be more certain than the true proportion lies within the confidence interval calculated, we would indeed expect the interval calculated to be wider when we desire 99% confidence.  For the upcoming Arkansas Presidential primary, favorability results for 4 candidates are given in Table 1 based on a collected sample. The second column in the table provides the number of people that view that candidate i favorably (2). The third column in the table provides the number of people asked about each candidate i (ni). Number Questioned (n) 700 Number Favorable (x) 500 250 333 400 Candidate 1 Candidate 2 Candidate 3 Candidate 4 300 800 1000 Table 1: Favorability Results From this information, we can estimate the proportion of people questioned that favor candidate i with the formula and denote the result i. For example, 500 Pi = = 71.4.% 700 which means that 71.4% of the people sampled had a favorable opionion of Candidate 1. In this question, you will use these sample proportions to create confidence intervals on the true proporition of the population that view each candidate favorably. a. Add code to H4_Q2 that declares and initializes a two-dimensional array named results with the integer values in columns 2 and 3 of Table 1. Your array should be 4 x 2. b. In H4_Q2 add a one-dimensinoal array of doubles named z_values initialized with the values 1.96 and 2.576. c. In H4_Q2 add code that calculates a 95% and 99% confidence interval on the proportion of responses that were favorable for each candidate. For a 95% confidence interval, the z-value is 1.96 and for a 99% confidence interval the z-value is 2.576. Given a specfied z-value (2) the formula for a confidence interval on proportion i is given by Pi(1 - D) P - 21 n Pi(1 - i) n d. (In H4_Q2) Print your results to the screen. Each row of your results should have the number of the candidate (e.g. Candidate 1), followed by the two confidence intervals calculated for the candidate (in the same order given in part d.). For example: Candidatel : (25,.75); (.1,-9) is an example of what one row of output should look like. Note that the numeric results are not correct in this example. Notice that in your results the width of the 95% confidence interval should be smaller than the 99% confidence interval. This is correct because a 99% confidence interval calls for a lower acceptable error (1% instead of 5%). To be more certain than the true proportion lies within the confidence interval calculated, we would indeed expect the interval calculated to be wider when we desire 99% confidence

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students explore these related Databases questions