Question

How do I set the problems below in R? Use the rnorm function in R to generate 100 samples of X ~N(-1.0,2.5) (for help use ?rnorm ) and for each draw, simulate Yǐ from the simple linear regression model = 2.5+2.0x,+티, where e, N N(0,3 ).

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

(a)
rm(list=ls())
x=rnorm(100,-1,2.5)
sig=rnorm(100,0,3)
y=0
for(i in 1:100){
y[i]=2.5+2*x[i]+sig
}
y
(b)
hist(y)
qqplot(y,x)
qnorm(.89,-1,2.5)
plot(x,y,col=2)
lines(x,y,ltyp=2,col=3)

Conclusion; Here we see that this the best fit.

Add a comment
Know the answer?
Add Answer to:
How do I set the problems below in R? Use the rnorm function in R to...
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
  • How do I set the problems below in R? Use the rnorm function in R to...

    How do I set the problems below in R? Use the rnorm function in R to generate 100 samples of X ~N(-1.0,2.5) (for help use ?rnorm ) and for each draw, simulate Yǐ from the simple linear regression model = 2.5+2.0x,+티, where e, N N(0,3 ). (iii) What is the marginal sample mean for Y? What is the true marginal mean?

  • How do I set the problems below in R? Use the rnorm function in R to...

    How do I set the problems below in R? Use the rnorm function in R to generate 100 samples of X ~N(-1.0,2.5) (for help use ?rnorm ) and for each draw, simulate Yǐ from the simple linear regression model = 2.5+2.0x,+티, where e, N N(0,3 ). (ii) Split the sample into 2 subsets of size 25 and 75. For each subset, run the regression of Y on X. Add each fitted regression line (use color) to your plot from (i)....

  • Note: In the following, if is a set and both and are positive integers, then matrices with entries from . The problem below has many applications. If is a linear map from complex vector space t...

    Note: In the following, if is a set and both and are positive integers, then matrices with entries from . The problem below has many applications. If is a linear map from complex vector space to itself, and is an eigenvalue of , then is a simple eigenvalue of if  . 1. Suppose is a vector space of dimension over field where you may assume that is either or , and let be a linear map from to . Show...

  • I need to plot a histogram for estimates of Beta_0 and Beta_1 (over the 100 simulations)....

    I need to plot a histogram for estimates of Beta_0 and Beta_1 (over the 100 simulations). I know I can use the coefficients function with the model to display these estimates for each simulation, but how can I access them individually, or save them to a column vector such that I can plot the histogram as needed? Suppose we want to simulate the following linear model: Bo + BiX; + Ei where ti~ N(0,22). Assume Xi~ N(0,12), Bo = 0.5...

  • Use the transformation and to evaluate the integral where is the region bounded on the   by...

    Use the transformation and to evaluate the integral where is the region bounded on the   by the ellipse   Let S be the image of R under T on the  . Sketch regions R and S. Set up the integral as an iterated integral of a function over region S. Use technology to evaluate the integral. Give the exact answer. We were unable to transcribe this imageWe were unable to transcribe this imageR xdA We were unable to transcribe this imageWe were...

  • R programming question. Please use #comments too ! 1. The data set UN11 in the alr4...

    R programming question. Please use #comments too ! 1. The data set UN11 in the alr4 package contains several variables, including ppgdp, per capita gross domestic product in US dollars, and fertility, number of children per woman, from the year 2009-2011. The data are for 199 localities, and we will study the regression of ppgdp on fertility (a) Draw the scatterplot of ppgdp against fertility and describe the relationship between these two variables. Is the trend linear? nD the simple...

  • 2. Suppose Y ~ Exp(a), which has pdf f(y)-1 exp(-y/a). (a) Use the following R code to generate data from the model Yi...

    2. Suppose Y ~ Exp(a), which has pdf f(y)-1 exp(-y/a). (a) Use the following R code to generate data from the model Yi ~ Exp(0.05/Xi), and provide the scatterplot of Y against X set.seed(123) n <- 500 <-rnorm (n, x 3, 1) Y <- rexp(n, X) (b) Fit the model Yi-Ao + Ax, + ε¡ using the lm function in R and provide a plot of the best fit line on the scatterplot of Y vs X, and the residual...

  • In developing empirically a cost function from observed data on a complex chemical experiment, an analyst...

    In developing empirically a cost function from observed data on a complex chemical experiment, an analyst employed normal error regression model (Yi = 0 +1Xi+ i ). 0 was interpreted here as the cost of setting up the experiment. The analyst hypothesized that this cost should be $7.5 thousand and wished to test the hypothesis by means of a general linear test. a) Indicate the alternative conclusions for the test b) Specify the full and reduced models c) Can you...

  • how do you find the values? i am confused Please complete the problems below related to...

    how do you find the values? i am confused Please complete the problems below related to Bayes' Theorem. You must show any calculations where necessary to receive full credit Disease Present Disease Absent Test Positive 80 100 Test Negative 20 800 a. # of True Positives: b. # of True Negatives: c. # of False Positives: d, # of False Negatives: We were unable to transcribe this imageWe were unable to transcribe this image

  • 2. R programming 2·The data set prostate in the faraway package is froma study on 97...

    2. R programming 2·The data set prostate in the faraway package is froma study on 97 men with prostate cancer who were due to receive a radical prostatectomy We are interest is in predicting lpsa (log prostate specific antigen) with Icavol (log cancer volume). (a) Draw a scatterplot -does a simple linear regression model seem reasonable? (b) Without using the R function Im), compute the values T,Y, Sxx, Syy and Sxy. Com- pute the ordinary least squares estimates of the...

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
ADVERTISEMENT