HELP

noormohid

New Member
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
• the generated dataset (in appendix)
• R code for analysis
• detailed interpretation of the results

staassis

Active Member
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.

noormohid

New Member
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?

noormohid

New Member
also is the e in the regression model the standard error or the sum of least squares?

noormohid

New Member
> 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:

noormohid

New Member
now when I type abline(asd) the regression line doesn't show up

noormohid

New Member
> 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
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:

noormohid

New Member
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

Dason

Of course it showed a different number. That's like the entire reason we need statistics.

noormohid

New Member
I just have to reverse plot the regression line
How do I do that?
As in obtain the scatterplot from this and then show this line going through it

hlsmith

Less is more. Stay pure. Stay poor.
What is the formula for a slope (line)?

Dason

Use plot with the data directly. Like plot(x,y) and then call abline

noormohid

New Member
The abline doesn’t fit the scatterplot. It shows a line not passing through the points.

noormohid

New Member
Can one of you please solve this and send the code? Deadline is to tonight and I really have a lot to cover with mids going on

Dason

what output just run the code if you have r. thank you all for wasting my time 