Question

R-Studio Write a generic R function of white test. It takes a fit of linear model...

R-Studio

Write a generic R function of white test. It takes a fit of linear model and outputs the value of white statistics, degree of freedom, and p-value for the hypothesis testing of constant-variance assumption. It should be similar to bptest as in lmtest package.

Homework Answers

Answer #1
> mdl = lm(final ~ midterm, data = stat500)
> bptest(mdl)

    studentized Breusch-Pagan test

data:  mdl
BP = 0.86813, df = 1, p-value = 0.3515

> bptest(mdl, studentize = FALSE)

    Breusch-Pagan test

data:  mdl
BP = 0.67017, df = 1, p-value = 0.413

> ncvTest(mdl)
Non-constant Variance Score Test 
Variance formula: ~ fitted.values 
Chisquare = 0.6701721    Df = 1     p = 0.4129916 
> 
> n = nrow(stat500)
> e = residuals(mdl)
> bpmdl = lm(e^2 ~ midterm, data = stat500)
> lambda = (n - 1) / n * var(e^2) / (2 * ((n - 1) / n * var(e))^2)
> Studentized_bp = n * summary(bpmdl)$r.squared
> Original_bp = Studentized_bp * lambda
> 
> Studentized_bp
[1] 0.8681335
> Original_bp
[1] 0.6701721

ANSWERED

PLEASE RATE ME POSITIVE

THANKS

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In R- Studio : Write a function that takes as an input a positive integer and...
In R- Studio : Write a function that takes as an input a positive integer and uses the print() function to print out all the numbers less than the input integer. (Example: for input 5, the function should print the numbers 1,2,3,4 { for input 1, the function should not print a number.) Write a recursive function, do not use any of the loop commands in your code.
Use the lm command to create the linear-log model in R. The linear log function takes...
Use the lm command to create the linear-log model in R. The linear log function takes the form Y=a+blog(x)
Suppose we fit a VAR model to 6 time series simultaneously. At the 0.05 significance level,...
Suppose we fit a VAR model to 6 time series simultaneously. At the 0.05 significance level, a 0.03 p-value of the Jarque-Bera test means that: a) The constant variance assumption is not violated b) The normality assumption is not violated c) The normality assumption is violated d) The constant variance assumption is violated
This is an intro to Python question: #Write a function called linear() that takes two parameters...
This is an intro to Python question: #Write a function called linear() that takes two parameters #- a list of strings and a string. Write this function so #that it returns the first index at which the string is #found within the list if the string is found, or False if #it is not found. You do not need to worry about searching #for the search string inside the individual strings within #the list: for example, linear(["bobby", "fred"], "bob") #should...
1. General features of economic time series: trends, cycles, seasonality. 2. Simple linear regression model and...
1. General features of economic time series: trends, cycles, seasonality. 2. Simple linear regression model and multiple regression model: dependent variable, regressor, error term; fitted value, residuals; interpretation. 3. Population VS sample: a sample is a subset of a population. 4. Estimator VS estimate. 5. For what kind of models can we use OLS? 6. R-squared VS Adjusted R-squared. 7. Model selection criteria: R-squared/Adjusted R-squared; residual variance; AIC, BIC. 8. Hypothesis testing: p-value, confidence interval (CI), (null hypothesis , significance...
Write an R function that will simulate 2 data sets from gamma distributions (``rgamma'' function, this...
Write an R function that will simulate 2 data sets from gamma distributions (``rgamma'' function, this gives us skewed samples) then does a standard t-test comparing the 2 means (``t.test'' function) and returns the p-value. The function should have 2 sample sizes and 2 sets of parameters as input. Now use the function to simulate a case with small sample sizes and the null hypothesis being true (equal means) and see how the type I error rate is affected by...
Write a MATLAB function and test bench script code to solve the above simple RL/RC circuits...
Write a MATLAB function and test bench script code to solve the above simple RL/RC circuits by following the instructions noted below. The input signal and impulse response generation should be done in the function. The test bench script should be used only to call the function and for signal plotting purposes. No plotting should be done inside the function itself. Name your function L2_C Instructions: Input voltage ,x(t), can be AC or DC. Consider a variable ‘w1’ which can...
Multiple linear regression results: Dependent Variable: Cost Independent Variable(s): Summated Rating Cost = -43.111788 + 1.468875...
Multiple linear regression results: Dependent Variable: Cost Independent Variable(s): Summated Rating Cost = -43.111788 + 1.468875 Summated Rating Parameter estimates: Parameter Estimate Std. Err. Alternative DF T-Stat P-value Intercept -43.111788 10.56402 ≠ 0 98 -4.0810021 <0.0001 Summated Rating 1.468875 0.17012937 ≠ 0 98 8.633871 <0.0001 Analysis of variance table for multiple regression model: Source DF SS MS F-stat P-value Model 1 8126.7714 8126.7714 74.543729 <0.0001 Error 98 10683.979 109.02019 Total 99 18810.75 Summary of fit: Root MSE: 10.441273 R-squared: 0.432...
If you run summary() command on a result of linear model fitting returned by lm(), you...
If you run summary() command on a result of linear model fitting returned by lm(), you will see a column Pr(>t). You could guess that it is a result of some t-test. How does it apply here? So far we have seen t-tests in the settings of testing sample locations. The ingredients were: 1) null hypothesis: in earlier cases we looked into the null that stated that two samples came from the distribution(s) with the same mean(s); 2) test statistic:...
Task 2: Compare strings. Write a function compare_strings() that takes pointers to two strings as inputs...
Task 2: Compare strings. Write a function compare_strings() that takes pointers to two strings as inputs and compares the character by character. If the two strings are exactly same it returns 0, otherwise it returns the difference between the first two dissimilar characters. You are not allowed to use built-in functions (other than strlen()) for this task. The function prototype is given below: int compare_strings(char * str1, char * str2); Task 3: Test if a string is subset of another...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT