[SOLVED] IT Write an R function called estegn, to implement the theory described above

$25

File Name: IT_Write_an_R_function_called_estegn,_to_implement_the_theory_described_above.zip
File Size: 725.34 KB

5/5 - (1 vote)

Write an R function called estegn, to implement the theory described above and calculate approximate confidence intervals for both u and o?. The arguments to your
function should be: x, a vector of observations; and alpha, a number between 0 and 1 specifying the value of a used to determine the confidence interval. The default
value of alpha should be 0.05. Your function should return a list containing components Estimate (a vector of length 2, containing the sample mean and variance in
that order): G (the 2 2 matrix G), V (the 2 2 matrix VI: Cov (the estimated 2 2 covariance matrix of the sample mean and variance); StdErr (a vector of length 2

Copyright By Assignmentchef assignmentchef

giving the estimated standard errors); and ConfInts (a 2 x2 matrix such that the first row contains the required confidence interval for u and the second row contains
the interval for a2. the first column should contain the lower ends of the intervals).

Introduction
Suppose you have n independent observations x1, , *n from a distribution with finite mean u and variance 62, both of which are unknown. The sample mean and
variance, I = n La, x; and s?
= (n 1)- E=1 (x; *) , are unbiased estimators of u and o? respectively. Your uncertainty about the underlying values can be
summarised using the covariance matrix of these estimators. For example, if the underlying distribution is normal then the sample mean and variance are independent
and have known sampling distributions: that for the sample mean is N(M, 02/n), and that for the sample variance is derived from the fact that (n 1)52/02
These results allow the required covariance matrix to be estimated as a diagonal matrix with elements s2/n and 2s4 / (n 1).
If the underlying distribution is not normal however, the covariance matrix calculation above is no longer justified. If you are not prepared to make strong assumptions
about the form of the distribution, then the theory of estimating equations provides an alternative way to estimate the required covariance matrix. In its most general
form, this theory applies to any situation in which parameters are estimated by equating some function of the data and parameters to zero. Examples include least-
squares estimation for linear regression models (minimise the residual sum of squares by solving the normal equations), as well as in many maximum likelihood
estimation problems (differentiate the log-likelihood and set to zero to find a maximum). Estimating equations provide a much more general framework, however.
In the present context, the theory of estimating equations can be applied by noticing that the estimators ^ = > and &?
= s2 can be obtained by solving the vector
equation g (u, o2) = 0 for M and o2, where g (M. o2)
= Li=18; and
(n 1)62/n
Notice that the (g:} are independent and identically distributed (lid) because the (x;} are. As a sum of id terms therefore, a Central Limit Theorem (CLT) applies to
g (41, 82) which has approximately a bivariate normal distribution in large samples. This can be used to derive a corresponding CLT for f and
themselves: in large
samples, their ioint distribution is approximatelv bivariate normal with covariance matrix G-lVG-1 where
and V is the covariance matrix of g (4, 02).
The matrix G can be estimated by substituting & for u in the expression above, to give G =
J. To estimate the matrix
V = Var (g (4,07)| = Var | E- 81|, we can again exploit the independence of the (g; ) to write V = E
a Var|3| = E E (BIBE) (E (8)| (E (B.). Nex.,
novice that E (st (4.03)| = (,
) this is approximately a zero vector when n is large, so V is approximately I-, E (&, Bf). This can itself be estimated to the
required degree of accuracy by removing the expectation to give E-, 81g/. Finally, the values of & and s? can be substituted for u and o? in the definition of g; above,
to give V = L, Big in an obvious notation. The estimate of the reguired covariance matrix is then G
: the square roots of the diagonal elements of this are
the estimated standard errors of the sample mean and variance, and approximate 100(1 a)% confidence intervals for u and o
2 can be constructed using the formula
estimate (Zw2 std. err.) as usual, where Zan is the appropriate percentage point of a standard normal distribution.

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] IT Write an R function called estegn, to implement the theory described above
$25