Thanks all. I get it!
Best.
From: gov2001-l-bounces at
lists.fas.harvard.edu [mailto:gov2001-l-bounces at
lists.fas.harvard.edu] On Behalf Of Patrick Lam
Sent: Monday, March 02, 2009 3:11 AM
To: gov2001-l at
lists.fas.harvard.edu
Subject: Re: [gov2001-l] PS4#2 & 1f
whoops, John-Paul is also right, the y-axis should be on the same scale.
On Mon, Mar 2, 2009 at 3:06 AM, Patrick Lam <plam at fas.harvard.edu<mailto:plam at
fas.harvard.edu>> wrote:
It is actually the x-axis that needs to be scaled the same. Ronald, you're right
that technically you can do the same by plotting the two curves on two different graphs
and then eyeballing them, as long as the x-axis is the same. However, since we can shift
likelihoods up and down, it's easier to compare by putting them on the same graph,
which is what the problem is asking.
On Sun, Mar 1, 2009 at 11:05 PM, John-Paul Ferguson <jpferg at mit.edu<mailto:jpferg
at mit.edu>> wrote:
2) Vertical shifts? Is it not the same as using
>par(mfrow=c(2,1)) and eyeballing the results?
If you plot the two using
par(mfrow=c(2,1)), the curvature will look almost the same, but the scale of the y-axis
will be quite different. You have to plot them on the same scale in order to compare the
curvature. Shifting one of them vertically so that their maxima have the same y-value
makes it easy to plot them on the same graph.
--John-Paul
On Sun, Mar 1, 2009 at 9:53 PM, Lai, Ronald <rolai at hbs.edu<mailto:rolai at
hbs.edu>> wrote:
All,
Since both distributions are Binomials with N=10, the log likelihood f(x) would be the
same for both. Why is it necessary to even have an indicator variable? Essentially
f(x)^d * f(x)^(1-d) = f(x).. I guess if one distr was Bin w/ N=10 and the other was
N<>10, having the indicator variable makes sense. I'll operate on the
assumption that the user of my R code can alter Ns for the two distributions.
I'm a bit confused about PS4#1f
1) I'm assuming reparameterization is not necessary for plotting so I rewrote the
f(x) to deal w/ this
2) Vertical shifts? Is it not the same as using par(mfrow=c(2,1)) and eyeballing the
results?
Feel like I'm missing something.
Best.
PS.
Sparsha, in your f(x) below, you have not defined n or g. to my knowledge, the function
also does not require an iterative process (per your for-loop)
From: gov2001-l-bounces at lists.fas.harvard.edu<mailto:gov2001-l-bounces at
lists.fas.harvard.edu> [mailto:gov2001-l-bounces at
lists.fas.harvard.edu<mailto:gov2001-l-bounces at lists.fas.harvard.edu>] On Behalf
Of sparsha saha
Sent: Friday, February 27, 2009 3:41 PM
To: gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
Subject: [gov2001-l] R hates me
is anyone getting this error message for problem 2 on this week's problem set
Error in pnorm(pa3) : element 1 is empty;
the part of the args list of '.Internal' being evaluated was:
(q, mean, sd, lower.tail, log.p)
I get this when I run my log likelihood function in R and then try to use optim on it:
binomial.second <- function(pa2, pa3, y2, n2) {
+ pies2 <- pnorm(pa2)
+ pies3 <- pnorm(pa3)
+ for (i in 1:n) {
+ blaba <- ifelse(g > 0, sum(y2 * log(pies2) + (n - y2) * log(1 - pies2)), sum(y2 *
log(pies3) + (n - y2) * log(1 - pies3)))
+ }
+ roe <- sum(blaba) / n
+ return(roe)
+ }
opt123 <- optim(par = 0.25, fn = binomial.second, method = "BFGS", control =
list(fnscale = -1), y = data, n = 10)
Error in pnorm(pa3) : element 1 is empty;
the part of the args list of '.Internal' being evaluated was:
(q, mean, sd, lower.tail, log.p)
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l at lists.fas.harvard.edu<mailto:gov2001-l at lists.fas.harvard.edu>
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science, Harvard
University
http://www.people.fas.harvard.edu/~plam
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science, Harvard
University
http://www.people.fas.harvard.edu/~plam