Question
Exercise 3: Write the following matlab code in R. mleThetaSgmaHat = zeros(m,2); for g = 1:m gThCol = yDataMatrix(:,g); gThCD = gThCol(gThCol < c.*R); mu1YHatMLE
Exercise 3: Write the following matlab code in R.
mleThetaSgmaHat = zeros(m,2);
for g = 1:m
gThCol = yDataMatrix(:,g);
gThCD = gThCol(gThCol < c.*R);
mu1YHatMLE = mean(gThCD); mu2YHatMLE = mean(gThCD.^2);
muYHatMLE = [mu1YHatMLE mu2YHatMLE];
n1Y = length(gThCD); n2Y = n-n1Y;
sigma0MLE = sqrt((mu2YHatMLE./c.^2) - (mu1YHatMLE./c).^2);
tz0MLE = -(mu1YHatMLE./(c.*sigma0MLE));
xStartMLE = [tz0MLE sigma0MLE];
PymtYMLEobjFun = @(x)PymtYMLEEqns(x,n,n1Y,n2Y,c,muYHatMLE,R);
PymtYMLESol = fsolve(PymtYMLEobjFun, xStartMLE, opt);
thetaHatYMLE = t-PymtYMLESol(2).*PymtYMLESol(1);
sigmaHatYMLE = PymtYMLESol(2);
mleThetaSgmaHat(g,:) = [thetaHatYMLE sigmaHatYMLE];
%waitbar(g/(2*m));
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started