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 18:30
The method of presentation refers to the planning process for the presentation. the information chosen for the presentation. how the presentation topic will be introduced. how the presentation will be delivered.
Answers: 1
question
Computers and Technology, 23.06.2019 01:50
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: a. double the number. b. reverse the digits of the number. c. raise the number to the power of 2, 3, or 4. d. sum the digits of the number. e. if the number is a two-digit number, then raise the first digit to the power of the second digit. f. if the number is a three-digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit. after performing an operation if the number is less than 10, add 10 to the number. also, after each operation determine if the number is prime. each successive operation should be performed on the number generated by the last operation. your program should not contain any global variables and each of these operations must be implemented by a separate function. also, your program should be menu driven. 7. (fraction calculator) write a program that
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
Explain the importance of html in web page designing in 20 sentences..
Answers: 1
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, 20.11.2019 22:31
question
Mathematics, 20.11.2019 22:31
question
Chemistry, 20.11.2019 22:31
Questions on the website: 13722367