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 ).

(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). Why are they not the same?

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

i)

Console Terminal > set.seed (5) #generate 100 random samples from normal distribution with mean -1 and sd 2.5 >xi rnorm(100, mean--1,sd-2. 5) > yi-2, 5+2.0*xi mnr lot abline(yonx)

Scatter plot -6 -4 -2 0 4 Xi

ii)

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 ). We were unable to transcribe this image

  • 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?

  • 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...

  • For expert using R , I solve it but i need to figure out what I...

    For expert using R , I solve it but i need to figure out what I got is correct or wrong. Thank you # Simple Linear Regression and Polynomial Regression # HW 2 # # Read data from csv file data <- read.csv("C:\data\SweetPotatoFirmness.csv",header=TRUE, sep=",") head(data) str(data) # scatterplot of independent and dependent variables plot(data$pectin,data$firmness,xlab="Pectin, %",ylab="Firmness") par(mfrow = c(2, 2)) # Split the plotting panel into a 2 x 2 grid model <- lm(firmness ~ pectin , data=data) summary(model) anova(model) plot(model)...

  • a) Use the following R code to empirically check the Central Limit Theorem via simulation .n...

    a) Use the following R code to empirically check the Central Limit Theorem via simulation .n <- 40 # sample size m <- c(1:200) #create a vector of length 200 for (i in 1:200) { #simulate 200 samples x <- rnorm(n) m[i] <- mean(x) } hist(m) b) Repeat part (a) with n=200 and compare the histograms. Describe what you observe and what you expect when n increases. c) Repeat parts (a) and (b) with runif() and rexp() respectively instead of...

  • STATS Use the R function rnorm() to simulate selecting a random sample of size 25 from...

    STATS Use the R function rnorm() to simulate selecting a random sample of size 25 from a population with mean 80 and s.d. 20. The goal here is to show how contamination affects the mean, s.d., and z-scores. (a) Obtain the sample mean and sample sd of the simulated sample and use them to obtain the z-score for 100. (b) Create the vector contam = c(0,seq(1000,10000,length=21)) To show the effects of contamination, separately add each value of contam to the...

  • 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...

  • How do I set the problems below in R?

    How do I set the problems below in R?

  • For the following problems, do not use statistical software such as SPSS, SAS, R and so...

    For the following problems, do not use statistical software such as SPSS, SAS, R and so on. Please nish your work only using basic calculator and describe how you get your answer. X 3 6 8 2 5 1 5 Y 4 5 6 2 5 0 3 (a) Compute the sample covariance of X and Y and explain how X and Y are related. (b) Compute the sample correlation coecient and explain its meaning. (c) Consider the simple linear...

  • This is how you import the Carseats data into Rstudio software: library(“ISLR”) data(“Carseats”) ...

    This is how you import the Carseats data into Rstudio software: library(“ISLR”) data(“Carseats”) view(Carseats) after that, please provide codes for following: a. Split the data into a training set and a test set. b. Fit a linear model using least squares on the training set to predict Sales using the entire collection of predictors. Report the Cp, BIC, R2, and RSS for this model c. Use the fitted model to predict responses for the test data and report the test...

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
Active Questions
ADVERTISEMENT