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)
it is 1 am so maybe it is just my brain but:
how can we have an iteration process with BFGS (equivalent to the bisection
one in principle) if we start with one point and not with a surface?
thanks!
charlotte
2009/2/24 Johnathan Boysielal <boysiel at fas.harvard.edu>
> Dear class,
>
> As it turns out, I still need a co-author for the final paper.
>
> I am a G3 in the Political Economy & Government program (Kennedy School),
> broadly interested in international and comparative political economy. If
> you are still looking for a co-author and are interested in topics along
> these or similar lines, please send me an email.
>
> I have provisionally selected some papers on the very timely topic of
> political intervention in the financial markets, but of course there is no
> shortage of interesting papers in the world..
>
> - Johnathan
>
>
> _______________________________________________
> gov2001-l mailing list
> gov2001-l at lists.fas.harvard.edu
> http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
>
>
I will be out of the office starting 02/25/2009 and will not return until
03/02/2009.
I will respond to your message when I return. In the meantime please
contact Roger Mathisen (rmathisen at unicef.org)
Hello,
A number of issues have come up on parts 3.2 and 3.3 in problem set 3 about
the question of iterations (specifically, "If so, after how many
iterations?"). Patrick and I have decided to remove this component of
questions 3.2 and 3.3 from the problem set. So, questions 3.2 and 3.3
should now read as follows:
3.2. Now use optim() to find the values (x*, y*) that maximize the joint
density. Use c(1,0.05) as your starting values and method="BFGS". Report
the value of the objective function at the maximum and (x*, y*). Does optim
work well here? Did the algorithm converge? If not, why?
3.3. Repeat 3.2 but use c(5,5) as starting values. Report the value of the
objective function at the maximum and (x*, y*). Does optim work well here?
Did the algorithm converge? If not, why?
Best,
Miya
--
Miya Woolfalk
Ph.D. Student
Harvard University
Government and Social Policy
Dear class,
As it turns out, I still need a co-author for the final paper.
I am a G3 in the Political Economy & Government program (Kennedy School),
broadly interested in international and comparative political economy. If
you are still looking for a co-author and are interested in topics along
these or similar lines, please send me an email.
I have provisionally selected some papers on the very timely topic of
political intervention in the financial markets, but of course there is no
shortage of interesting papers in the world..
- Johnathan
Hello,
Now that the course shopping period is over, lecture and section videos are
no longer accessible to non-extension school students. We are able to sign
non-extension school students up to be able to view these videos and I am
working on getting this all sorted out. Hopefully, students enrolled in
Gov 1002/2001 should have their access restored by Tuesday.
Thanks,
Miya
--
Miya Woolfalk
Ph.D. Student
Harvard University
Government and Social Policy
Can anyone explain to me how we can retrieve a number of iteration after running optim()?
> init<-c(1,0.05)
> res<-optim(init, x_y_density,method="BFGS", control=list(fnscale=-1))
res
$counts
function gradient
16 6
Is it a number of calls of the function? Or I have to add number of calls of the function and it's gradient? Or I have to look for it somewhere else?
Thanks!
Sincerely,
Olena Ageyeva
_________________________________________________________________
Access your email online and on the go with Windows Live Hotmail.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Access_022009
Hi all,
I just wanted to clear up a little uncertainty with many people about
whether they can replicate a paper with OLS. Please read point 4.2 of this:
http://gking.harvard.edu/papers/
The basic idea is that while we don't recommend replicating a paper which
uses mainly OLS, if you insist on doing it, your improvement must be
something more advanced. For example, if the authors used OLS on a binary
dependent variable, you can replicate it and use a logit model. All the
fancy add-ons to the OLS models (random effects, IV estimators, etc.) are
things that we probably will not cover and therefore you will have a hard
time improving on with any of our methods you will learn. The main point is
that unless you currently have a good idea about an improvement on an OLS
paper that uses something we learn in the class, we highly recommend not
replicating OLS.
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science,
Harvard University
http://www.people.fas.harvard.edu/~plam
Hi all,
Problem set 2 has been graded and will be handed back to you Monday after
class. Those who only submitted online already have your grades and
comments posted in the dropbox. Just a few things that generally people
need to pay attention to:
1. Probabilities are always between 0 and 1. 0.3 is a probability. 30% is
not a probability.
2. While one estimator can be more biased than another, there is no such
thing as "less unbiased". All unbiased estimators are unbiased the same
amount. There is no degree to the unbiasedness.
3. On that same note, a few people wrote that the midrange and mean
estimators were slightly biased for the uniform and normal distributions
because the means were slightly off. This is not true. The expectation of
both estimators is equal to the population mean. The "bias" that you see is
purely from simulation error (if we had infinite number of simulations, the
mean of the sampling distribution would be exactly the population mean).
4. It's generally not a good idea to name objects in R the wrong names. A
few of you named E(X^2) as "var", which is not true. It is a component of
variance, but not the actual variance, so naming it wrong can be confusing.
5. For 4d, while it is great that many of you wrote functions for the
random variable Y, it is not necessary. You can just do the operations on
the X draws themselves.
6. When you are trying to compare quantities via two graphs, it is usually
a good idea to have the graphs on the same scale for ease of comparison. If
the Y axes are different, it makes it harder to actually compare whether the
spreads are smaller/bigger, etc.
--
Patrick Lam
Department of Government and Institute for Quantitative Social Science,
Harvard University
http://www.people.fas.harvard.edu/~plam