Dear Kirill,
I think the problem is in:
ttt<-data.frame(q15,age, PUTIN_BI) # Step 1
z.out <- zelig(PUTIN_BI ~ ttt$q15, ttt$age, na.exclude(ttt), model =
"logit") # Step 2
This should be, for the first step:
ttt <- data.farme(q15 = q15, age = age, putin = PUTIN_BI)
For the second step, I'm not sure what you're trying to do, but
formulas should NEVER have $ in them! That confuses setx and sim to
no end. And you should ALWAYS name every argument passed, since the
order may vary. If you want to run a regression for putin on age and
q15, then use
z.out <- zelig(putin ~ age + q15, data = ttt, model = "logit")
Note that I have named every argument after the default formula. You
don't need to say na.exclude() yourself, as zelig() will do that
automatically.
If you are trying to use age as weights for observations (don't see
why you would want to, though):
ttt <- na.omit(ttt)
z.out <- zelig(putin ~ q15, weights = ttt$age, data = ttt, model = "logit")
You do need to do the list wise deletion yourself if you specify
weights, and weights does need a $ in it to identify the data frame.
Hope this helps, best,
Olivia
On 2/18/07, Kirill Kalinin <kkalinin(a)eu.spb.ru> wrote:
> Dear Olivia,
>
> I am a PhD student with the European University at St. Petersburg, working
> on electoral behavior issues. The dataset I am running is huge - 30000
> cases. I look forward to calculating the first differences using 'logit'
> but when running setx() I get an error message: "Error: protect():
> protection stack overflow". I was trying to decrease the size of then
> dataset, but it doesn't seem to help.
> The script is as follows:
>
> library (Zelig)
> library(foreign)
>
> Estdata <- read.spss(
> "G:/geo_c.sav",
> to.data.frame=T, use.value.labels=T)
> dim(Estdata)
> names(Estdata)
> attach(Estdata)
> q15<- as.ordered(Q15) #ordered categorical variable with 4 values (1-4)
> age<-as.ordered(AGE) #ordered categorical variable with 4 values (1-4)
> ttt<-data.frame(q15,age, PUTIN_BI)
> z.out <- zelig(PUTIN_BI ~ ttt$q15, ttt$age, na.exclude(ttt), model =
> "logit")
>
> Then I run:
> x.low <- setx(z.out, q15=1)
> x.high <- setx(z.out, q15=4)
> So I get:
> protect(): protection stack overflow
>
>
> I wonder whether I am doing something wrong, as I am new to R and Zelig, or
> this happens because of my computer limitations. In fact, everything is
> perfect with metric variables, this problem occurs just with the ordered
> categorical variables. Could you help me to resolve the issue?
>
> Thank you very much!
>
> All the Best,
> Kirill
> P.S. Happy Chinese New Year!
>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/
You can increase the number of iterations to see whether the model will
converge. To do this, include maxit = xxx where xxx is a big integer in
your zelig() statement. The error message saying "fitted probabilities
numerically or 1 occurred" means that some observations are perfectly
predicted given the covariates. For example, if there are two binary
covariates x1 and x2, and *all* observations with (x1,x2)=(0,0) have y=0,
then you will have predicted probability equal to 0 for those
observations.
Kosuke
-----------------------------------------------------
Kosuke Imai Office: Corwin Hall 041
Assistant Professor Phone: 609-258-6601
Department of Politics eFax: 973-556-1929
Princeton University Email: kimai(a)Princeton.Edu
Princeton, NJ 08544-1012 http://imai.princeton.edu
-----------------------------------------------------
On Thu, 1 Feb 2007, Saleem Shaik wrote:
> Thank you and the model provided the parameter estimates.
>
> 1)
>
> However, with the inclusion of three variables the model provides this
> error
>
> **********************************************************************
> Error in function (formula, data, weights, start, ..., subset,
> na.action, :
> attempt for find suitable starting values failed
> In addition: Warning messages:
> 1: algorithm did not converge in: glm.fit(X, y1, wt, family =
> binomial(), offset = offset)
> 2: fitted probabilities numerically 0 or 1 occurred in: glm.fit(X, y1,
> wt, family = binomial(), offset = offset)
>
> **********************************************************************
>
> The three independent variables are the spatial, temporal and residual
> variance computed from the panel data and are incorporated as the
> independent variables in the ordered logit model. Second the three
> variables are very skewed, more specifically the spatial and temporal
> variance. This might lead to the errors. However, for the correlation
> matrix of the independent variables, I do not find a correlation more
> than .50.
>
> Are there any studies addressing these issues in the estimation of
> ordered logit model or ordered probit model. If there are any studies
> or if Zelig can estimate these kinds of model please direct me to the
> same.
>
> 2) Is this error indicating lack of disk space or memory?
>> x.out <- setx(z.out, fn = NULL)
>> s.out <- sim(z.out, x = x.out)
> Error: cannot allocate vector of size 485859 Kb
>
> Regards, Saleem
>
>
> **********************************************
> Saleem Shaik, Ph.D
> 215 E Lloyd-Ricks, West Wing
> Dept of Agricultural Economics,
> Mississippi State University
> Mississippi State, MS 39762-5187
> Phone: (662) 325 7992 (Off)
> (662) 615 3886 (Res)
> Fax: (662) 325 8777
> Email: shaik(a)agecon.msstate.edu
> **********************************************
> It is neither wealth nor splendor, but
> tranquility and occupation, which gives
> happiness.-- Jefferson
>
>>>> Kosuke Imai <kimai(a)Princeton.Edu> 01/31/07 3:43 PM >>>
>
> The response variable needs to be a factor variable. So try
>
> as.factor(OPTUNITS)
>
> in the formula. I would also start with a smaller model using a smaller
>
> number of covariates.
>
> Kosuke
>
> On Wed, 31 Jan 2007, Saleem Shaik wrote:
>
>> Dear Kosuke,
>>
>> Thanks for the pointing the minor error but with a major impact of
>> unable to run the model. Sorry to bug you, but the model does not
> seem
>> to iterate or converage and provides with the following error.
>>
>>
> *************************************************************************
>>> # Ordered Logit Model OPTUNITS coded as 1,2,3,.....,9
>>> library(Zelig)
>> Loading required package: MASS
>> Loading required package: boot
>> ##
>> ## Zelig (Version 2.7-5, built: 2006-12-25)
>> ## Please refer to http://gking.harvard.edu/zelig for full
>> documentation
>> ## or help.zelig() for help with commands and models supported by
>> Zelig.
>> ##
>>> z.out <- zelig(OPTUNITS ~ FYBAR + MHAST1 + MHASS1 + MHASR1 + FABAR1
> +
>> FP65BAR + ACTUALS + D_PRAC + ST_DUM2 + ST_DUM3 + ST_DUM4 + ST_DUM5 +
>> ST_DUM6, model = "ologit", data = example.dat)
>> Error in function (formula, data, weights, start, ..., subset,
>> na.action, :
>> response must be a factor
>>
> *************************************************************************
>>
>> I have estimated this model in SAS and STATA and I am trying to
>> replicate in R. Could you provide you suggestions to be able to run
>> this model in R and I have attached the R code and SAS xport
> dataset.
>>
>> Thanks
>>
>> Saleem
>>
>>
>>
>> **********************************************
>> Saleem Shaik, Ph.D
>> 215 E Lloyd-Ricks, West Wing
>> Dept of Agricultural Economics,
>> Mississippi State University
>> Mississippi State, MS 39762-5187
>> Phone: (662) 325 7992 (Off)
>> (662) 615 3886 (Res)
>> Fax: (662) 325 8777
>> Email: shaik(a)agecon.msstate.edu
>> **********************************************
>> It is neither wealth nor splendor, but
>> tranquility and occupation, which gives
>> happiness.-- Jefferson
>>
>>>>> Kosuke Imai <kimai(a)Princeton.Edu> 01/31/07 2:34 PM >>>
>>
>> It should be
>>
>> library(Zelig)
>>
>> not
>>
>> library(zelig)
>>
>> hope this helps.
>>
>> Kosuke
>>
>> -----------------------------------------------------
>> Kosuke Imai Office: Corwin Hall 041
>> Assistant Professor Phone: 609-258-6601
>> Department of Politics eFax: 973-556-1929
>> Princeton University Email: kimai(a)Princeton.Edu
>> Princeton, NJ 08544-1012 http://imai.princeton.edu
>> -----------------------------------------------------
>>
>> On Wed, 31 Jan 2007, Saleem Shaik wrote:
>>
>>> Thank you for the reference. I tried to estimate the ordered logit
>>> model using the following commands (attached R code). In mydata
>> set
>>> the LHS variable, OPTUNITS is coded as 1,2,3,.....,9. However, I
>> faced
>>> with an error of unable to read ZELIG. Should I download any
> package
>> to
>>> run the model?
>>>
>>>> library(zelig)
>>> Error in library(zelig) : there is no package called 'zelig'
>>>> z.out <- zelig(OPTUNITS ~ FYBAR + MHAST1 + MHASS1 + MHASR1 + FABAR
>> +
>>> FP65BAR, model = "ologit", data = example.dat)
>>> Error: could not find function "zelig"
>>>
>>> I could have sent the data file but it is large. If you want me to
>>> send the data file I can send you the same in the next email.
>>>
>>> Thanks, Saleem
>>>
>>>
>>> **********************************************
>>> Saleem Shaik, Ph.D
>>> 215 E Lloyd-Ricks, West Wing
>>> Dept of Agricultural Economics,
>>> Mississippi State University
>>> Mississippi State, MS 39762-5187
>>> Phone: (662) 325 7992 (Off)
>>> (662) 615 3886 (Res)
>>> Fax: (662) 325 8777
>>> Email: shaik(a)agecon.msstate.edu
>>> **********************************************
>>> It is neither wealth nor splendor, but
>>> tranquility and occupation, which gives
>>> happiness.-- Jefferson
>>>
>>>>>> Kosuke Imai <kimai(a)Princeton.Edu> 01/31/07 12:14 PM >>>
>>>
>>> You can use Zelig for ordered logit:
>>> http://gking.harvard.edu/zelig/docs/_TT_ologit_TT__Ordinal.html
>>>
>>> If you are interested in multinomial probit (or ordered multinomial
>>> probit), then you need to use MNP:
>>> http://imai.princeton.edu/research/MNP.html (see JSS paper for an
>>> example).
>>>
>>> Kosuke
>>>
>>> -----------------------------------------------------
>>> Kosuke Imai Office: Corwin Hall 041
>>> Assistant Professor Phone: 609-258-6601
>>> Department of Politics eFax: 973-556-1929
>>> Princeton University Email: kimai(a)Princeton.Edu
>>> Princeton, NJ 08544-1012 http://imai.princeton.edu
>>> -----------------------------------------------------
>>>
>>> On Wed, 31 Jan 2007, Saleem Shaik wrote:
>>>
>>>> Dear Imai,
>>>>
>>>> Does zelig or MNP estimate the orderd logit and ordered probit
>>> model?
>>>> If so could you provide the web link of an example that estimates
>>> the
>>>> ordered logit and probit model.
>>>>
>>>> Thanks, Saleem
>>>>
>>>>
>>>> **********************************************
>>>> Saleem Shaik, Ph.D
>>>> 215 E Lloyd-Ricks, West Wing
>>>> Dept of Agricultural Economics,
>>>> Mississippi State University
>>>> Mississippi State, MS 39762-5187
>>>> Phone: (662) 325 7992 (Off)
>>>> (662) 615 3886 (Res)
>>>> Fax: (662) 325 8777
>>>> Email: shaik(a)agecon.msstate.edu
>>>> **********************************************
>>>> It is neither wealth nor splendor, but
>>>> tranquility and occupation, which gives
>>>> happiness.-- Jefferson
>>>>
>>>
>>>
>>
>>
>
> -
> Zelig Mailing List, served by Harvard-MIT Data Center
> Send messages: zelig(a)lists.gking.harvard.edu
> [un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
> Zelig program information: http://gking.harvard.edu/zelig/
>
>
-
Zelig Mailing List, served by Harvard-MIT Data Center
Send messages: zelig(a)lists.gking.harvard.edu
[un]subscribe Options: http://lists.gking.harvard.edu/?info=zelig
Zelig program information: http://gking.harvard.edu/zelig/