้ข˜็›ฎ
้ข˜็›ฎ

DATA1001/1901 (ND) Revision Quiz 5

ๅ•้กน้€‰ๆ‹ฉ้ข˜

Using the ๐‘š ๐‘ก ๐‘ ๐‘Ž ๐‘Ÿ ๐‘  dataset in RStudio, calculate the correlation between ๐‘š ๐‘ ๐‘” and โ„Ž ๐‘ , and then perform a linear regression with ๐‘š ๐‘ ๐‘” as the dependent variable and โ„Ž ๐‘ as the independent variable. What is the correlation and the slope of the regression line? ย  Hint: Use the following code. cor(mtcars$mpg, mtcars$hp) lm(mtcars$mpg ~ mtcars$hp)$coefficients[2] lm(mpg ~ hp, data=mtcars)$coefficient[2] # another method

ๆŸฅ็œ‹่งฃๆž

ๆŸฅ็œ‹่งฃๆž

ๆ ‡ๅ‡†็ญ”ๆกˆ
Please login to view
ๆ€่ทฏๅˆ†ๆž
The question asks to compute two related statistics from the mtcars dataset in R: (1) the correlation between mpg and hp, and (2) the slope of the linear regression of mpg on hp. First, consider the provided commands conceptually. The function cor(mtcars$mpg, mtcars$hp) returns the Pearson correlation coefficient between mpg (miles per gallon) and hp (gross horsepower). In practice, across the mtcars data, mpg tends to decline as horsepower increases, yielding a negative correlation. Next, the regression slope is obtained by fitting a model where mpg is the dependent variable and hp is......Login to view full explanation

็™ปๅฝ•ๅณๅฏๆŸฅ็œ‹ๅฎŒๆ•ด็ญ”ๆกˆ

ๆˆ‘ไปฌๆ”ถๅฝ•ไบ†ๅ…จ็ƒ่ถ…50000้“่€ƒ่ฏ•ๅŽŸ้ข˜ไธŽ่ฏฆ็ป†่งฃๆž,็Žฐๅœจ็™ปๅฝ•,็ซ‹ๅณ่Žทๅพ—็ญ”ๆกˆใ€‚

็ฑปไผผ้—ฎ้ข˜

ๆ›ดๅคš็•™ๅญฆ็”Ÿๅฎž็”จๅทฅๅ…ท

ๅŠ ๅ…ฅๆˆ‘ไปฌ๏ผŒ็ซ‹ๅณ่งฃ้” ๆตท้‡็œŸ้ข˜ ไธŽ ็‹ฌๅฎถ่งฃๆž๏ผŒ่ฎฉๅคไน ๅฟซไบบไธ€ๆญฅ๏ผ