联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Algorithm 算法作业Algorithm 算法作业

日期:2019-10-19 10:57

Please do not share this handout outside the class.

STAT 3032 Homework4 Instruction (Fall 2019)

Due Thursday, Oct 17 @ 11:59pm in Canvas

20 points in total

Please show your work on each problem for full credit. A correct answer, unsupported by the

necessary explanation, R code or output will receive very little if any credit. Your work needs

to be organized in a reasonably neat and coherent way, and submitted as a pdf file on

Canvas.

You are welcome to discuss with your classmates, but you must write up your homework

individually!

Problem 1

This problem will use the RateMyProfeesor dataset we saw in the lectures! Download the data

file RateprofThree.csv from Canvas. Each observation is a professor. The variables are:

quality the quality score of the professor on a scale of 1 to 5, with 1 being the worst and

5 being the best.

gender the gender of the professor. The possible values are “female” and “male”.

pepper if the professor is considered “hot” (i.e. physically attractive). The possible values

are “yes” and “no”.

(a) Import the dataset into R. Among the professors in the sample, how many of them are

male? How many professors received “yes” for their pepper value? Hint: use

summary(dataName)

(b) Fit a model that uses pepper to predict quality. Provide the model summary. What

percentage of the variability in quality is explained by pepper?

Note: You may notice that the percentage is low. We are using Problem 2 to practice

using dummy variable, not to find a good model to predict quality.

(c) What is the base level of pepper (the level that corresponds to 0 in the dummy

variable)?

1

Please do not share this handout outside the class.

(d) Interpret the estimated slope of the model in Part (b) in the context.

(e) Interpret the estimated intercept of the model in Part (b) in the context.

(f) Now fit a model using both gender and pepper to predict quality. Provide the

summary of the model. Write down the fitted model. Please pay attention to the notation.

(g) What is the average of the quality score for male professors with pepper equal to “no”?

Hint: For these professors, what is the value of pepperyes? What is the value of

gendermale?

(h) Please order the following four groups according to their average quality score (from the

highest to the lowest).

-Group A: male professors with pepper equal to “yes”

-Group B: female professors with pepper equal to “yes”

-Group C: male professors with pepper equal to “no”

-Group D: female professors with pepper equal to “no”

Problem 2

This problem is adapted from Question 1 in Section 3.4 (pg. 103) in the textbook A Modern

Approach to Regression with R.

The data file airfares.txt on the book web site gives the one-way airfare (in US dollars)

and distance (in miles) from city A to 17 other cities in the US. Interest centers on modeling

airfare as a function of distance.

2

Please do not share this handout outside the class.

(a) Read in the dataset from a website (see url below) and fit the model that uses

Distance to predict Fare.Provide the summary of your model output.

The url for the data is: http://gattonweb.uky.edu/sheather/book/docs/datasets/airfares.txt

Hint: Use the R function read.table( )

(b) Create a scatterplot of Fare (y-axis) vs. Distance (x-axis) with the fitted regression

model. Color this fitted model red. Hint: Use the R functions plot(y~x, data =

dataName) and abline(modelName, col = ‘red’)

(c) Create a plot where the x-axis is Distance and the y-axis is the standardized residuals

from the model. Include two horizontal lines at -2 and 2 to mark the boundaries of

outliers. Hint: use the R functions rstandard(modName) ,

plot(rstandard(modName)~ dataName$x), and abline(h=2).

(d) Remove the two outliers found in Part (c) in the dataset. Note that one of the outliers has

a standardized residual just below -2. In real life, it is up to you to determine if you want

to remove this borderline case. Here, we will remove it. Fit a polynomial regression

model of order 2. Provide the output of your fitted model.

(e) Write down the fitted model equation from Part (d). Pay attention to the notation.

(f) If we conduct the test of H vs. , where is the slope of . 0

: β2 = 0 HA

: β2 =/ 0 β2 Distance

2

What is the test statistic value based on this sample? What distribution does the test

statistic follow under the null hypothesis? What is the p value?

3


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp