Thanks Afamia, I appreciate the reply. This does not seem to fix the
problem, but perhaps I can play around with it and figure something out.
On Apr 17, 2008, at 12:05 PM, Afamia Kaddour wrote:
Hi Keith,
I am the least expert, but I will venture an answer. For your
ordered probit, you may want to try the following:
snctmodel <- zelig(as.factor(RES) ~ IMPORT + COST + TARGET + COOP
+ TARGET*COOP, model="oprobit", data=snct)
I wonder if we should use as.factor for the variables with more
than one category.
Afamia
>> Keith Schnakenberg <keith.schnakenberg
at gmail.com> 4/17/2008 2:44
>> PM >>>
Hello classmates,
Despite my best efforts, I still have the same two questions I had
last night in this morning. I am listing them again in and
demonstrating what I tried to do to see if anyone has any other ideas.
First, for the ordered probit model, , zelig is giving me this error
message:
snctmodel <- zelig(RES ~ IMPORT + COST +
TARGET + COOP +
TARGET*COOP, model="oprobit", data=snct)
Warning message:
In function (formula, data, weights, start, ..., subset, na.action, :
design appears to be rank-deficient, so dropping some coefs
I don't know if it's giving me wrong coefficients because of this,
but it is a problem because it leads to these two errors as well:
#SIMULATIONS
import.low <- setx(snctmodel, fn =
list(numeric = mean, ordered =
median,others = mode), IMPORT=0)
import.high <- setx(snctmodel, fn =
list(numeric = mean, ordered =
median,others = mode), IMPORT=1)
coop.low <- setx(snctmodel, fn = list(numeric
= mean, ordered =
median,others = mode), COOP=1)
coop.high <- setx(snctmodel, fn = list(numeric
= mean, ordered =
median,others = mode), COOP=2)
coopsim <- sim(snctmodel, coop.low, coop.high, 1000)
Error in x[, -1] %*%
t(sim.coef) : non-conformable arguments
importsim <- sim(snctmodel, import.low,
import.high, 1000)
Error in x[, -1] %*% t(sim.coef) : non-conformable arguments
summary(whatif(data = snctmodel, cfact = import.high))
[1] "Preprocessing
data ..."
Error in whatif(data = snctmodel, cfact = import.high) :
number of columns of 'cfact' and 'data' are not equal
I thought it didn't know the variables were ordered, so I tried
imposing as.ordered() to the variables, but this didn't help very
much. I'm out of ideas on this one because I'm really not sure what
it means for the design to be rank-deficient.
Second, I am having trouble finding the bug in my negative binomial
log likelihood function:
ll.negbin <- function(par, X, Y){
theta <- X%*%par[1:ncol(X)]
gamma <- par[(ncol(X)+1)]
sigma2 <- exp(gamma) + 1
out <- sum(lgamma((theta/(sigma2 - 1)) + 1) - lgamma(Y+1) - lgamma
(theta/(sigma2 -1)) + Y*log((sigma2-1)/sigma2) - (theta/(sigma2 - 1))
*log(sigma2))
}
That is leading to this:
opt.nb <- optim(c(0,0,0,0,0), ll.negbin, X =
X, Y = Y, method =
"BFGS", control = list(fnscale = -1), hessian = TRUE)
Error in optim(c(0, 0, 0, 0, 0), ll.negbin, X = X, Y = Y, method =
"BFGS", :
initial value in 'vmmin' is not finite
In addition: There were 28 warnings (use warnings() to see them)
#(the warnings are all "1: In fn(par, ...) : value out of range in
'lgamma'")
Apparently I've written my function such that it evaluates to -Inf or
NaN at certain points. I can get numbers sometimes depending on the
par values I get it, but changing the starting values in optim is not
much help.
I would appreciate any advice you could offer.
Thanks,
Keith
_______________________________________________
gov2001-l mailing list
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
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l