Set the seed number to 1234098765 and the sample size to 100. Use the data-generating process for y_A.  Use the untransformed values of x1 and x2.  Assume that the error is homoskedastic. Estimate the model using least squares. Use the Breusch-Pagan Test. What is the Value of the test statistic?

MATLAB: An Introduction with Applications
6th Edition
ISBN:9781119256830
Author:Amos Gilat
Publisher:Amos Gilat
Chapter1: Starting With Matlab
Section: Chapter Questions
Problem 1P
icon
Related questions
Question

Read the given information for Part A.

Set the seed number to 1234098765 and the sample size to 100. Use the data-generating process for y_A.  Use the untransformed values of x1 and x2.  Assume that the error is homoskedastic. Estimate the model using least squares. Use the Breusch-Pagan Test. What is the Value of the test statistic? (Note: Write the first three decimal places without rounding off. For instance, if what you got in R is 0.12309, you should write 0.123.)

##########
######## #########
library (MASS) #run install.packages ("MASS") if you haven't installed the package yet.
#Invoking the MASS package enables `mvrnorm'.
#
library (lmtest) #This is needed to implement tests for heteroskedasticity.
#
set.seed ( 1 ) #usual seed number
#
N <- 1 #Size of the random sample.
x1 <- rnorm(N, 0,20) #normal distribution
x2 <- rnorm (N, 0,10) #normal distribution
#
x1 <-
x2 <-
#
###########################
2*x1 #normal distribution
2*x2 #normal distribution
x1 <-
3*x1 #normal distribution
x2 <- 3*x2 #normal distribution
#
#Generate new variables
#
x1sq <-x1^2 #square of x1
x2sq <-x2^2 #square of x2
int <-x1*x2 #interaction between x1 and x2
#
#
#
epsilon1 <- rnorm (N, 0,1) #stochastic error term; variance of error is 1
epsilon1 <- sqrt(int) *epsilon1
epsilon1 <- -sqrt(int)*epsilon1
#Part A
#The data-generating process is denoted by #(*).
#The data-generating process highlights population-level relationships. This is
your true model. No errors are present, and no
#endogeneity issues arise. There are no measurement errors, as well.
#Note that the interaction term between x1 and x2 is added. Usually, the
#interaction term measures the joint effect of x1 and x2.
#
y_A < 1 +0.3*x1 +0.75*x2-0.9*x1sq -0.5*x2sq + 2.5*int + epsilon1 #(*)
#
#Note the respective coefficients of x1, x2, x1sq, x2sq, and int.
#
#Fit the model using OLS
#
model.A <- lm (y_A~x1+x2+x1sq +x2sq+int +1)
#
summary (model.A)
#
#Breush-Pagan Test
#The result should not come as a surprise. Based on how the model was constructed,
#no reason to believe that the variance will vary across observations.
bptest(model.A)
#
#You should be able to interpret the statistics generated by the bptest.
#BP is the test statistic, and df is the degrees of freedom. Based on the p-value,
#we accept that errors are homoskedastic. Can you argue otherwise?
#
#Note that the fitted model is close to the DGP. Just check the model summary.
#
summary (model.A)
#
Transcribed Image Text:########## ######## ######### library (MASS) #run install.packages ("MASS") if you haven't installed the package yet. #Invoking the MASS package enables `mvrnorm'. # library (lmtest) #This is needed to implement tests for heteroskedasticity. # set.seed ( 1 ) #usual seed number # N <- 1 #Size of the random sample. x1 <- rnorm(N, 0,20) #normal distribution x2 <- rnorm (N, 0,10) #normal distribution # x1 <- x2 <- # ########################### 2*x1 #normal distribution 2*x2 #normal distribution x1 <- 3*x1 #normal distribution x2 <- 3*x2 #normal distribution # #Generate new variables # x1sq <-x1^2 #square of x1 x2sq <-x2^2 #square of x2 int <-x1*x2 #interaction between x1 and x2 # # # epsilon1 <- rnorm (N, 0,1) #stochastic error term; variance of error is 1 epsilon1 <- sqrt(int) *epsilon1 epsilon1 <- -sqrt(int)*epsilon1 #Part A #The data-generating process is denoted by #(*). #The data-generating process highlights population-level relationships. This is your true model. No errors are present, and no #endogeneity issues arise. There are no measurement errors, as well. #Note that the interaction term between x1 and x2 is added. Usually, the #interaction term measures the joint effect of x1 and x2. # y_A < 1 +0.3*x1 +0.75*x2-0.9*x1sq -0.5*x2sq + 2.5*int + epsilon1 #(*) # #Note the respective coefficients of x1, x2, x1sq, x2sq, and int. # #Fit the model using OLS # model.A <- lm (y_A~x1+x2+x1sq +x2sq+int +1) # summary (model.A) # #Breush-Pagan Test #The result should not come as a surprise. Based on how the model was constructed, #no reason to believe that the variance will vary across observations. bptest(model.A) # #You should be able to interpret the statistics generated by the bptest. #BP is the test statistic, and df is the degrees of freedom. Based on the p-value, #we accept that errors are homoskedastic. Can you argue otherwise? # #Note that the fitted model is close to the DGP. Just check the model summary. # summary (model.A) #
Expert Solution
steps

Step by step

Solved in 3 steps with 13 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
MATLAB: An Introduction with Applications
MATLAB: An Introduction with Applications
Statistics
ISBN:
9781119256830
Author:
Amos Gilat
Publisher:
John Wiley & Sons Inc
Probability and Statistics for Engineering and th…
Probability and Statistics for Engineering and th…
Statistics
ISBN:
9781305251809
Author:
Jay L. Devore
Publisher:
Cengage Learning
Statistics for The Behavioral Sciences (MindTap C…
Statistics for The Behavioral Sciences (MindTap C…
Statistics
ISBN:
9781305504912
Author:
Frederick J Gravetter, Larry B. Wallnau
Publisher:
Cengage Learning
Elementary Statistics: Picturing the World (7th E…
Elementary Statistics: Picturing the World (7th E…
Statistics
ISBN:
9780134683416
Author:
Ron Larson, Betsy Farber
Publisher:
PEARSON
The Basic Practice of Statistics
The Basic Practice of Statistics
Statistics
ISBN:
9781319042578
Author:
David S. Moore, William I. Notz, Michael A. Fligner
Publisher:
W. H. Freeman
Introduction to the Practice of Statistics
Introduction to the Practice of Statistics
Statistics
ISBN:
9781319013387
Author:
David S. Moore, George P. McCabe, Bruce A. Craig
Publisher:
W. H. Freeman