Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

The following R code is for a simulation study. You are asked to explain what is illustrated. What can you learn from it in terms

 

The following R code is for a simulation study. You are asked to explain what is illustrated. What can you learn from it in terms of good or bad statistical practice?

Some information that may help you:

t he error term of the linear regression model is based on a t - distribution with  3  degrees of freedom, which has mean zero and variance  3  and which has heavy tails  ( i . e .  simulations from this t - distribution show more outliers as compared to a normal distribution).

the I QR is the inter - quartile range, which is the difference between the third and the first quartile

set.seed(156918)

beta.hat.complete<-c()

var.beta.hat.complete<-c()

beta.hat.reduced<-c()

var.beta.hat.reduced<-c()

x<-1:200

db<-data.frame(x=x,y=NA)

for(i in 1:10000) {

db$y<-10+.3*x+7*rt(200, df=3)

m.complete<-lm(y~x,data=db)

e<-residuals(m.complete)

iqr<-IQR(e)

keep<-abs(e)<2.5*iqr

m.reduced<-lm(y~x, data=db, subset=(keep))

beta.hat.complete<-c(beta.hat.complete,coef(m.complete)[2])

var.beta.hat.complete<-c(var.beta.hat.complete,summary(m.complete)$coef[2,2]^2)

beta.hat.reduced<-c(beta.hat.reduced,coef(m.reduced)[2])

var.beta.hat.reduced<-c(var.beta.hat.reduced,summary(m.reduced)$coef[2,2]^2)

}

mean(beta.hat.complete)

## [1] 0.2997359

mean(var.beta.hat.complete)

## [1] 0.0002163193

10

mean(beta.hat.reduced)

## [1] 0.2998977

mean(var.beta.hat.reduced)

## [1] 0.000115903

X<-lm(y~x,data=db,x=T)$x

solve(t(X)%*%X)*49*3

## (Intercept) x

## (Intercept) 2.9621608 -0.0221608040

## x -0.0221608 0.0002205055

 
 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students explore these related Computer Network questions

Question

=+a) What is the maximin choice?

Answered: 3 weeks ago