Question

Part I: qqplots This part deals with qqplots of all kinds. Lets do some easy expe riments, first. Lets take a sample from a normal distribution with mu-2, sigma 3, and then look at the hist and the qqplot of that data: set.seed(3) n 100 # Sample size x norm(n,2,3) # Sample from N(mu-2, sigma-3) hist(x) # Looks normal. But that depends on breaks. qqnorm(x) # This doesnt depend on binsize, and it looks linear abline(2,3, col-2) how much a qqplot varies, linear. So, now you get a sense of how much istribution. To eye-ball the What you just got is a qqplot based on a sample, i.e., its essentially a random variabe. To get a sense of l of these qaplots are from a run the whole block of code several times but EXcluding the set.seed0 line. Remember that a distribution/population that is truly normal, i.e, hat the population qgplot would look 1 variability to allow for when you look at qqplots in the future. Also, recall that the intercept and slope of the qgplot are estimates of the mu and sigma of that normal d t. But you want to make sure to focus mostly on the linear portion intercept and the slope, its convenient to draw a line on the qqplo of the qqplot and mostly ignore the end points. For the set.seed(3) sample, I decided that a line with (intercept, slope) 2, enough, and so my estimate of mu and sigma would be 2 and 3, respectively. This being a simulation, we already know that mu sigma -3, and so everything is consistent. Now, lets see what qqplots look like if the population is not normal at all. To that end a) Write code to take a sample of size 1000 from Exp(lambda-1), and make a histogram and a qqplot of the sample. IMPORTANT: use set.seed(3) You will see that the qaplot is not straight at all. In fact, we could have anticipated that it would not be straight by just thinking about three special quantiles: the 0th, the 0.5th and the Ist. b) What are those special quantiles for the standard normal distribution? c) What are those special quantiles for the exponential distribution? Hint: the median of Exp(lambda) is In(2)/lambda. Just imagine a very, very large sample (i.e., nearly the population). In the qqplot the three numbers in part b would go on the x-axis, and the matching three nunbers in part c would go on the y-axis. And, as you can see, the qqplot would have to look like the one got in part a, i.e., it cannot be linear. These qqplots are called normal qqplots, because the quantiles on the x-axis are those of the standard normal. But the idea of a qgplot can be generalized for testing ANY distribution. For example, if you want to see whether the data come from an exponential distribution, you can put quantiles of *that* distribution on the x-axis. If you get a straight line on that qaplot, then there is evidence that your data have come from an exponential distribution. Although there are R packages that can put on the x-axis quantiles of any distribution you specify, we will do it by h the way to make the normal qqplot by hand: and. Her is n-100 x-rnorm (n,2,3) # Here is som e data from Normal(2,3), and here is the normal qq plot by hand n-length(x) probs seq(0, 1,length-n) # Probabilities at which quantiles are to be computed Q ; qnorm(probs,0,1 ) # The quantiles of the normal distribution plot(Q, sort(x)) abline(2,3, col-2) # The same line as above # Sample size # qqplotd) Write code to take a sample of size 100 from Exp(lambda 2), and make a qqplot with quantiles ofx IMPORTANT: Use set.seed(3) at the start of your code. Exp(lambda=2) on the x-axis. e) By using abline0, approximate the intercept and slope of the qqplot in part d. Part II: Correlation Coefficient 1 To get some practice with scatterplots and correlation, write code to produce the two scatterplots at the top of page 6 in lecture 9 involving 1000 points, AND compute the correlation coefficient for each. IMPORTANT: use set.seed(3).

Solve d,e and f please using R code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

i (32-bit) File History Resize Windows 回目回 R Console R R Graphics: Device 2 (ACTIVE) > # (d) sample !from exponentiallaists U

Add a comment
Know the answer?
Add Answer to:
Solve d,e and f please using R code Part I: qqplots This part deals with qqplots...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please use R Part I: qqplots. This part deals with qaplots of al inds. Let's do...

    Please use R Part I: qqplots. This part deals with qaplots of al inds. Let's do some easy experiments, first. Let's take a sample from a normal distribution with mu-2, sigma -3, and then look at the hist and the qqplot of that data: set.seed(3) n 100 # Sample size # Sample from N(mu-2, sigma-3) # Looks normal. But that depends on breaks. x morm(n,2.3) hist(x) qqnorm(x) # This doesn't depend on binsize, and it looks linear. abline(2,3, col-2) What...

  • what code in R should I use if I want to achieve 10 different outputs with the same n. n= a number that doesnt satisfies the CLT my distributions are pois(0.8) and t(2) the one I used is below but...

    what code in R should I use if I want to achieve 10 different outputs with the same n. n= a number that doesnt satisfies the CLT my distributions are pois(0.8) and t(2) the one I used is below but I don’t think it’s right if anyone can help me please resolve this code so I can do the same thing with 10 different values of n. and of that n I need to know the mean, the min, max,...

  • I need help with parts A B D E and F. Please show hand work for...

    I need help with parts A B D E and F. Please show hand work for solving A and B while D and E should be matlab codes. How do i pick the right graph for part F? 5 2 4 6 Linear spline: s fi+ (x-x) 2) Given the points 40 78 125 256 348 425 X1-x a) Write the correct linear spline equation to interpolate for x 4.72, simplifying where appropriate to get to the slope-intercept form. (4...

  • Please solve on only PART 2 b) and c) , PART 1 is only for REFERENCE...

    Please solve on only PART 2 b) and c) , PART 1 is only for REFERENCE :) Part I: Ene concept of a percentile (equivalently, quantile) is very important in data analysis. It applies to both samples and distributions. So, let's get some wi practice with them, starting with the binomial distribution. In prelab, you learned that the function gbinom(p. size prob) gives the p-th quantile of the binomial distribution with parameters n - size and pi prob. tocus on...

  • PLEASE ANSWER ALL parts . IF YOU CANT ANSWER ALL, KINDLY ANSWER PART (E) AND PART(F)...

    PLEASE ANSWER ALL parts . IF YOU CANT ANSWER ALL, KINDLY ANSWER PART (E) AND PART(F) FOR PART (E) THE REGRESSION MODEL IS ALSO GIVE AT THE END. REGRESSION MODEL: We will be returning to the mtcars dataset, last seen in assignment 4. The dataset mtcars is built into R. It was extracted from the 1974 Motor Trend US magazine, and comcaprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973-74 models). You can find...

  • Please include all code from R that was used to calculate everything. Problem 2 (0.5 x...

    Please include all code from R that was used to calculate everything. Problem 2 (0.5 x 3 = 1.5 point ) Simulate a sample of y1, ..., 4100 from a simple linear model Y = 1 + 2x + €, where € ~ N(0,62), and x is an arithmetic sequence from 1 to 100, with a step size of 1. Run set.seed(1) to set the seed of R's random number generator so that the simulation can be reproduced. • Make...

  • I am supposed to answer these questions using R software. However, I have little to no experience...

    I am supposed to answer these questions using R software. However, I have little to no experience with R or any other type of programming. Can someone please help me with the R code for these questions? Q1. Suppose you have a population of size 5 [ie. N= corresponding numbers are: You measure sorne quantity (X) and the 21,22,23, 24,25 a) Calculate the population mean () b) Calculate the population variance (ơ2) using the formula ơ2-41 -P Q2. Imagine you...

  • I must use R Program to solve them. Please help! Thank you ünif uniform random variable...

    I must use R Program to solve them. Please help! Thank you ünif uniform random variable 1) Draw the graphs of the p.d.f. of the following distributions (a) The standard normal p.d.f (b) The normal pdf with ? = 50, ? = 10 (c) The uniform p.d.f. over interval [10, 20] (d) The exponential P.d.f with parameter ? 4. 2) Illustrating the central limit theorem. Let X be a random variable having the uniform distribution over the interval [6, 12]...

  • Really short question! Please help me to solve ONLY part(b) with R code. Thank you! Problem...

    Really short question! Please help me to solve ONLY part(b) with R code. Thank you! Problem 4 [26 points] (Section 2.4): Consider a one-sample z-test (known variance) with hypotheses: Ho: μ lo vs H, μ *Ho. The probability of Type II error can be written in the form |ß D(%2_Jnd)-0(-%2_Jnd) where Φ㈠ is the CDF of N(0,1), d Isyo, and δ is the difference between the true mean and the mean under Ho (a) [10 points] Based on the fact...

  • Really short question! Please help me to solve part(b), also need the R code, thank you!...

    Really short question! Please help me to solve part(b), also need the R code, thank you! Problem 4 [26 points] (Section 2.4): Consider a one-sample z-test (known variance) with hypotheses: Ho: μ lo vs H, μ μο. a/2 where φ(.)Is the CDF of N(0,1), d-layo, and δ is the difference between the true mean and the mean under Ho (a) [10 points] Based on the fact that φ(x) [pdf of N(0,1)] is a decreasing function in x when x> 0,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT