subject

A) Write a function named diagnostics that takes as input the arguments: model, an object of class lm(), that is a model fit via lm()
pcol, for controlling point colors in plots, with a default value of grey
lcol, for controlling line colors in plots, with a default value of dodgerblue
alpha, the significance level of any test that will be performed inside the function, with a default value of 0.05
plotit, a logical value for controlling display of plots with default value TRUE
testit, a logical value for controlling outputting the results of tests with default value TRUE
The function should output:
A list with two elements when testit is TRUE:
p_val, the p-value for the Shapiro-Wilk test for assessing normality
decision, the decision made when performing the Shapiro-Wilk test using the alpha value input to the function. "Reject" if the null hypothesis is rejected, otherwise "Fail to Reject."
Two plots, side-by-side, when plotit is TRUE:
A fitted versus residuals plot that adds a horizontal line at y=0, and labels the x-axis "Fitted" and the y-axis "Residuals." The points and line should be colored according to the input arguments. Give the plot a title.
A Normal Q-Q plot of the residuals that adds the appropriate line using qqline(). The points and line should be colored according to the input arguments. Be sure the plot has a title.
Consider using this function to help with the remainder of the assignment as well.
B) Run the following code.
set. seed(40)
data_1 = data. frame(x = runif(n = 30, min = 0, max = 10),
y = rep(x = 0, times = 30))
data_1$y = with(data_1, 2 + 1 * x + rexp(n = 30))
fit_1 = lm(y ~ x, data = data_1)
data_2 = data. frame(x = runif(n = 20, min = 0, max = 10),
y = rep(x = 0, times = 20))
data_2$y = with(data_2, 5 + 2 * x + rnorm(n = 20))
fit_2 = lm(y ~ x, data = data_2)
data_3 = data. frame(x = runif(n = 40, min = 0, max = 10),
y = rep(x = 0, times = 40))
data_3$y = with(data_3, 2 + 1 * x + rnorm(n = 40, sd = x))
fit_3 = lm(y ~ x, data = data_3)
diagnostics(fit_1, plotit = FALSE)$p_val
diagnostics(fit_2, plotit = FALSE)$decision
diagnostics(fit_1, testit = FALSE, pcol = "black", lcol = "black")
diagnostics(fit_2, testit = FALSE, pcol = "grey", lcol = "green")
diagnostics(fit_3)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:10
3. consider the following class definitions: class smart class supersmart: public smart { { public: public: void print() const; void print() const; void set(int, int); void set(int, int, int); int sum(); int manipulate(); smart(); supersmart(); smart(int, int); supersmart(int, int, int); private: private: int x; int z; int y; int secret(); }; }; . which private members, if any, of smart are public members of supersmart? a. which members, functions, and/or data of the class smart are directly accessible in class supersmart?
Answers: 2
question
Computers and Technology, 22.06.2019 11:10
The total cost of textbooks for the term was collected from 36 students. create a histogram for this data. $140 $160 $160 $165 $180 $220 $235 $240 $250 $260 $280 $285 $285 $285 $290 $300 $300 $305 $310 $310 $315 $315 $320 $320 $330 $340 $345 $350 $355 $360 $360 $380 $395 $420 $460 $460
Answers: 2
question
Computers and Technology, 22.06.2019 12:20
Usually, when we sniff packets, we are only interested certain types of packets. we can do that by setting filters in sniffing. scapy’s filter use the bpf (berkeley packet filter) syntax; you can find the bpf manual from the internet. set the following filters and demonstrate your sniffer program again (each filter should be set separately): (a) capture only the icmp packet. (b) capture any tcp packet that comes from a particular ip and with a destination port number 23. (c) capture packets comes from or to go to a particular subnet. you can pick any subnet, such as 128.230.0.0/16; you should not pick the subnet that your vm is attached to.
Answers: 3
question
Computers and Technology, 22.06.2019 18:40
Mariah was working on a multimedia presentation that included both video and audio files. the file was huge, and she wanted to send it to her coworker in another office. she needed to reduce the size of the file so that it could be transmitted faster. the utility she used to do this was
Answers: 2
You know the right answer?
A) Write a function named diagnostics that takes as input the arguments: model, an object of class...
Questions
question
Mathematics, 03.05.2020 13:21
question
Mathematics, 03.05.2020 13:21