xuebaunion@vip.163.com
3551 Trousdale Rkwy, University Park, Los Angeles, CA
留学生论文指导和课程辅导
无忧GPA:https://www.essaygpa.com
工作时间:全年无休-早上8点到凌晨3点

微信客服:xiaoxionga100

微信客服:ITCS521
HW2 Stat-comp (due Wed, Oct 19th in D2L) 1) Maximum likelihood estimation and inference with the exponential distribution The density function of an exponential random variable is f(xi|λ) = λe−λxi where xi ≥ 0 is the random variable, and λ > 0 is a rate parameter. The expected value and variance of the random variables are E[X] = 1λ and V ar[X] = 1 λ2 . The following code simulates 50 IID draws from an exponential distribution set.seed(195021) x=rexp(n=50,rate=2) The maximum likelihood estimate of λ has a closed form, indeed L(λ|x) = λne−λnx¯ Thus, l(λ|x) = nlog(λ)− λnx¯, therefore dl dλ = n λ − nx¯. Setting this derivative equal to zero, and solving for λˆ gives λˆ = 1x¯ Using numerical optimization to estimate λ: Since λ > 0, we need to be careful using optim() because this function may report an estimate smaller than zero. Furthermore, for models involving a single parameter, optimize() is preferred relative to optim(); optimize() allows you to provide an interval for the optimization. 1.1) Use optimize() to estimate λ compare your estimate with 1x¯ . 1.2) Use numerical methods to proivde an approximate 95% CI for your estimate. Hint: optimize() does not provide a Hessian. However, you can use the hessian() function of the numDeriv R-package to obtain a numerical approximation to the second order derivative of the logLikelihood at the ML estiamte. To install this package you can use install.packages(pkg='numDeriv',repos='https://cran.r-project.org/') 2) CIs for Predictions from Logistic Regression Recall that in a logistic regresion model, the log-odds are parameterized as log[ θi(1− θi) ] = x ′ iβ = ηi (1) The sampling variance of x′iβ = ηi is V ar(ηi) = x′iVxi, where V is the (co)variance matrix of the estimated effects; therefore, a SE and an approximate 95%CI for ηi can be obtained using SE(ηi) = √ x′iVxi and CI : x′iβˆ + /− 1.96× SE(ηi). 1 Because the inverse-logit is a monotonic map, we can then obtain a 95% CI for the predicted probabilities by applying the inverse logit,θi = e ηi 1+eηi , to the bounds of the CI for the linear predictor. • Using the gout data set, fit a logistic regression for gout using sex, age, and race as predictors (for this you can use glm(), don’t forget the link!). • From the fitted model, and using the formulas presented above, compute the predicted probability of gout for each of the following cases, and the corresponding 95% CI for the predicted risk. Race Sex Age Predicted Risk 95%CI White Male 55 White Female 55 Black Male 55 Black Female 55 3) Bootstrap/ Use 1,000 bootstrap samples to estimate the SE and 95% CIs for the probabilities reported in Question 2. Compare your bootsrap results with those reported in Question 2. 2