Starting from:

$35

AMS597  Homework/Exam #7 Solved


1.     Estimate the bias, standard error, standard normal bootstrap CI, basic bootstrap CI and bootstrap t-interval at 95% of the sample median for x where

set.seed(123)

x <- rnorm(50)

2.     Another test statistic for two group comparison, i.e., H0 : F = G vs Ha : F 6= G in the univariate case is the Cramer-von Mises statistic

 

where Fn is the ecdf of x1,...,xn and Gm is the ecdf of y1,...,ym.

Implement the two group comparison using Cramer-von Mises test statistic but obtaining the p-value from permutation test.

3.     Implement the bivariate Spearman rank correlation test as a permutation test. Compare the achieved significance level of the permutation test with the p-value reported by cor.test on the following samples:

set.seed(123)

x <- rnorm(50)

y <- 0.2*x+rnorm(50)

4.     (a) Derive the Newton-Raphson iteration for solving

e2x = x + 6

Implement your iteration as a R function and report the solution to the equation.

(b) Compare your answer to the solution using uniroot function (i.e., Brent’s method).

5.     (a) Let x1,...,xn be a random sample from a Poisson(λ). Find the maximum likelihood estimator of λ using the function optimize in R. Apply this to

set.seed(123) lambda.true <- 10 x <- rpois(1000,lambda.true)



 c PF.Kuan

(b) Let x1,...,xn be a random sample from a Beta(a,b). Find the maximum likelihood estimator of θ = (a,b) using the function optim and optimx in R. Apply this to

set.seed(123) a.true <- 5

b.true <- 2

x <- rbeta(1000,shape1=a.true,shape2=b.true)



 

More products