HELP

#1
In R software, randomly generate the bivariate data of 30 observations for regression model Y = 32 + 11X + ε, with X ∼ N(0,1);ε ∼ N(0,s). Let the error variance s is the square root of the last 3 digits from your student ID. Save the data as .csv file. Fit the simple linear regression model to the generated data, and interpret the results in detail. Your written assignment must contain:
• Your student ID # ie 212
• the R code for the data generation; the value of the error variance s used(re
to your ID#)
• the generated dataset (in appendix)
• R code for analysis
• detailed interpretation of the results
 

staassis

Active Member
#2
So? What is you code, which does not seem to be working? Or is your code exactly 0 lines since you expect somebody else to do the complete assignment for you? To get good will from many people here, you would need to demonstrate at least some effort. Thank you.
 
#3
so basically I don't understand what I should generate. I generated 30 random values for x and used the regression model to generate 30 values of y with error calculated using the error variance. I get the scatterplot but the abline function doesn't give any output. also the value for sigma is not the same. maybe I am interpreting the question wrong?
 
#6
> x = rnorm> x = rnorm(30,0,1)> y = rnorm(30,0,1)> y = 32+ 11*x + rnorm(30,0,3.815786)> plot(x,y)> asd= lm(y~x)> summary(asd)Call:lm(formula = y ~ x)Residuals: Min 1Q Median 3Q Max -9.163 -2.430 -0.205 2.390 9.227 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 31.2287 0.7511 41.58 < 2e-16 ***x 10.9577 0.8386 13.07 1.95e-13 ***---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 3.949 on 28 degrees of freedomMultiple R-squared: 0.8591, Adjusted R-squared: 0.8541 F-statistic: 170.7 on 1 and 28 DF, p-value: 1.948e-13> plot(asd)Hit <Return> to see next plot: Hit <Return> to see next plot: Hit <Return> to see next plot: Hit <Return> to see next plot:
 
#8
> x = rnorm
> x = rnorm(30,0,1)
> y = rnorm(30,0,1)
> y = 32+ 11*x + rnorm(30,0,3.815786)> plot(x,y)
> asd= lm(y~x)
> summary(asd)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-9.163 -2.430 -0.205 2.390 9.227
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 31.2287 0.7511 41.58 < 2e-16 ***x
10.9577 0.8386 13.07 1.95e-13 ***---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.949 on 28 degrees of freedomMultiple R-squared: 0.8591, Adjusted R-squared: 0.8541 F-statistic: 170.7 on 1 and 28 DF, p-value: 1.948e-13
> plot(asd)
Hit <Return> to see next plot:
Hit <Return> to see next plot:
Hit <Return> to see next plot:
Hit <Return> to see next plot:
 

staassis

Active Member
#9
Great. Your code seems fine. The assignment does not stipulate that you use the abline() function. What they want is for you to interpret the output generated by the summary() function.
 
Last edited:
#10
But my summary function shows different value of sigma as compared to the entered value. Also the assignment is asking me to fit the regression line to the data