Issue
I'm brand new to R, and I'm facing a problem without much in- class resources. I need to do something that I'm sure is very simple. Can someone point me in the right direction? This is my task:
Let X denote the monthly return on Microsoft Stock and let Y denote the monthly return on Starbucks stock. Assume that X∼N(0.05,(0.10)2) and Y∼N(0.025,(0.05)2).
Using a grid of values between –0.25 and 0.35, plot the normal curves for X and Y. Make sure that both normal curves are on the same plot.
I've only been able to get a randomly generated normal distribution generated, but not both on the same plot, and not by specifying mean and st dev. Big thanks in advance.
Solution
use the functions lines or points, i.e.
s <- seq(-.25,.35,0.01)
plot(s, dnorm(s,mean1, sd1), type="l")
lines(s, dnorm(s,mean2, sd2), col="red")
also, check the function par (using ?par ) for plotting options, common options include labels (xlab/ylab), plotlimits (xlim/ylim), colors(col), etc...
Answered By - bpeter Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.