Dear Zelig users
I am using the R package Zelig for some tobit regression with robust
standard errors.
I have got R version 2.9.2 (2009-08-24)
and Zelig Version: 3.4-5
when i do demo(robust)
It ends like this way
data(coalition)
> # Fit the model with robust standard error
> user.prompt()
Press <return> to continue:
> z.out3 <- zelig(Surv(duration, ciep12) ~ polar + numst2 + crisis,
model = "weibull", data = coalition, cluster = "invest", robust = TRUE)
*It is giving the following error
*Error in rowsum.default(resid(fit, "dfbeta"), cluster) :
'x' must be numeric
Please help where it is going wrong
Thanks and Regards
Sayan Dasgupta
Peter,
We will put it on the to-do-list.
Kosuke
--
Department of Politics
Princeton University
http://imai.princeton.edu
On Sun, 25 Oct 2009, peter jameson wrote:
> Hi Kosuke!
> I notice R has a Support Vector Machines implementation.
> Any plans to implement this in Zelig?
>
> Cheers, Peter
>
-
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/
Dear Zelig Folk,
For a few applications, I'd like to run a single simulation. I thought I
might do this by setting num=1, but if I set num to anything less than 8, I
get the following error:
> Error in qi.polr(object[[1]], simpar = simpar, x = as.matrix(x), x1 = if
> (!is.null(x1)) as.matrix(x1)) :
subscript out of bounds
Except when I set num to either 1 or 2, in which case I get the following
error:
Error in matrix(rnorm(p * n), n) : invalid 'ncol' value (too large or NA)
It's not all that important to what I'm doing, but I'm curious if anyone
knows why this happens or if there's anything that can be done about it.
Cheers, Don
Hi,
I'm trying to run matchit followed by zelig to calculate the ATT:
After running z.out <- zelig(@@@), I get the following error message:
Error in `[.data.frame`(d, , all.vars(as.expression(formula))) :
undefined columns selected
I'm not sure why I'm getting this error message--afterwards, I want to run:
x.out1 <- setx(z.out1, data = match.data(m.outf, "treat"), cond = TRUE)
s.out1 <- sim(z.out1, x = x.out1)
Any help at all would be most appreciated!
best,
Prashant
P.S. Specifically, I had run the following code:
ps <- glm(Tr ~ female + urban + father_edu + mother_edu + siblings +
hs_type_best + kuaiban + wangjie + sx_non_mil12 + I(age^2) + I(urban*age) +
I(urban*mother_edu) + I(urban*sx_non_mil12) + I(female*sx_non_mil12) +
I(urban*wangjie) + I(female*wangjie), family=binomial, data=my.data)
X = cbind(age, female, urban, father_edu, mother_edu, siblings,
hs_type_best, kuaiban, wangjie, sx_non_mil12, I(age^2), I(urban*age),
I(urban*mother_edu), I(urban*sx_non_mil12), I(female*sx_non_mil12),
I(urban*wangjie), I(female*wangjie), ps$fitted)
m.outf <- matchit(Tr ~ X, data = rdmatchAC.lk12.range10, method = "genetic",
ratio = 2, replace = TRUE, pop.size=1000, discard = "control")
z.out1 <- zelig(Y1 ~ Tr + X + gk_score, model = "ls", data =
match.data(m.outf, "control"))
x.out1 <- setx(z.out1, data = match.data(m.outf, "treat"), cond = TRUE)
s.out1 <- sim(z.out1, x = x.out1)
Even though there are only six possible values in my ologit esitmates, I get
seven values in the qi$ev:
> s.out$qi$ev
1 1 2 3 4 5 6
1 0.0037076 0.23622 0.14601 0.16821 0.18050 0.14410 0.12126
2 0.0033500 0.23162 0.11705 0.15862 0.20940 0.14789 0.13207
3 0.0020180 0.12770 0.08862 0.12422 0.18882 0.19016 0.27845
4 0.0022673 0.21746 0.12485 0.15439 0.19608 0.15260 0.15235
5 0.0031793 0.28474 0.14091 0.15632 0.18133 0.13101 0.10251
6 0.0024818 0.19614 0.11684 0.15278 0.22823 0.16162 0.14190
7 0.0039682 0.26576 0.13108 0.15688 0.19080 0.12478 0.12674
8 0.0015015 0.15490 0.09352 0.13356 0.23033 0.19183 0.19436
9 0.0027922 0.18692 0.11385 0.17334 0.20004 0.14274 0.18032
10 0.0032175 0.19282 0.12555 0.14715 0.20266 0.17849 0.15011
That's odd, isn't it? Why two columns of 1's? The same thing happens for
qi$fd.
I can send more code if need be, just curious if anyone has run into this
before.
Donald Braman
phone: 413-628-1221
http://www.culturalcognition.net/braman/http://ssrn.com/author=286206http://www.law.gwu.edu/Faculty/profile.aspx?id=10123
Dear Fabricio,
No, Zelig does not automate this. However, if you follow Thomas'
suggestion in the survey design object input to Zelig, Zelig should be
able to accommodate this since it passes all the *.survey models to
Thomas' package.
Best,
Olivia
2009/10/10 Fabrício Mendes Fialho <fabriciofialho(a)gmail.com>:
> Dear Olivia,
>
> Thanks for your message.
>
> Yes, if the sample is not stratified by religious groups (and this survey is
> not), I will not have representative samples for these subsets.
>
> However, recently I read a Thomas Lumley's paper ("Analysing Survey Data in
> R", R News 3(1), 2003) in which he states that:
>
> "Estimates on a subset of a survey require some care. Firstly, it is
> important to ensure that the correct weight, cluster and stratum information
> is kept matched to each observation. Secondly, it is not correct simply to
> analyse a subset as if it were a designed survey of its own. The correct
> analysis corresponds approximately to setting the weight to zero for
> observations not in the subset. This is not how it is implemented, since
> observations with zero weight still contribute to constraints in R functions
> such as glm, and they still take up memory. Instead, the survey.design
> object keeps track of how many clusters (PSUs) were originally present in
> each stratum and svyCprod uses this to adjust the variance."
>
> According to this statement, subset analysis (for instance, comparing blacks
> and whites, men and women, catholic and protestant, and so on) would be
> possible since we keep all cases and survey design information while running
> our analysis, just attributing zero weight to cases outside the subset of
> interest.
>
> My question would be whether or not there is a Zelig command that automatize
> this 'zero weighting process'. (but, of course, it is possible that my
> question in fact does not make sense.)
>
> Thanks for your attention.
>
> Sincerely,
> Fabricio
>
> 2009/10/9 Olivia Lau <olivia.lau(a)post.harvard.edu>
>>
>> Dear Fabricio,
>>
>> The answer depends on the original survey design. If the sample was
>> stratified by each of the religious groups, then you can subset to the
>> group or groups of interest, and analyze data from just those groups
>> using logit.survey. If the sample was stratified using other
>> background characteristics, then subsetting to the religious groups
>> *and* employing survey weights will not create a representative
>> sample. In this case, you have to refer to the survey design (which
>> should be in the documentation of the particular survey) for guidance.
>> If you know something about the alternative target populations (e.g.,
>> protestant, catholic, etc), then you could possibly reweight the data
>> after subsetting.
>>
>> Yours,
>> Olivia
>>
>> 2009/10/7 Fabrício Mendes Fialho <fabriciofialho(a)gmail.com>:
>> > Hi there,
>> >
>> > I would like to know how may I obtain analysis for
>> > subgroups/subpopulations
>> > using Zelig. For instance, let suppose I am analyzing data on political
>> > participation and religion, and I would like to estimate the effects of
>> > political sofistication on electoral outcome. My data is from a complex
>> > sample survey. Let also suppose respondents were classified in
>> > "protestant",
>> > "catholic", and "others". Considering theoretical issues, it would be
>> > interesting to estimate the effect of political sofistication and
>> > electoral
>> > outcome just for the "protestant" group.
>> >
>> > How should I proceed to obtain this coefficient only for a subgroup (for
>> > instance, "protestants")? How can I select this subgroup in my sample
>> > when I
>> > am running my analysis? For instance, I would like to run a
>> > "logit.survey"
>> > model, and I intend to include survey design information (PSU and
>> > weights)
>> > in my model. I would like to know how can I run analysis for this
>> > subgroup
>> > without just delete the other cases from my dataset since this procedure
>> > would distort the original sample design. Should I just set the weight
>> > to
>> > zero for observations outside the subset of interest? Or is there other
>> > way
>> > to proceed? And if I intend to run a "logit" model (not a
>> > "logit.survey"),
>> > what should I do?
>> >
>> > I looked for directions about this in Zelig manual, but I did not find
>> > instructions for this kind of analyses.
>> >
>> > Best regards,
>> >
>> > Fabricio
>> >
>
>
>
> --
>
> Fabrício Mendes Fialho
>
> web: sites.google.com/site/fabriciofialho/
> e-mail: fabriciofialho(a)gmail.com
>
-
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/
I'm having some trouble getting Zelig to simulate parameters from chopit
model estimates.
Zelig will reproduce the model estimates:
> z.out <- zelig(f1, data = list(self = pmra, vign = pmra), model =
"chopit")
and set the parameters to their default values:
> x.out <- setx(z.out, data = pmra)
but when I try to run the simulations using the following code:
> s.out <- sim(z.out, x = x.out)
I get this error message:
Error in UseMethod("vcov") : no applicable method for "vcov"
Any suggestions? Thanks.
--
Justin Marlowe
jmarlowe(a)washington.edu
Assistant Professor
Daniel J. Evans School of Public Affairs
Box 353055
Seattle, WA 98195-3055
-
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/
Hi there,
I would like to know how may I obtain analysis for subgroups/subpopulations
using Zelig. For instance, let suppose I am analyzing data on political
participation and religion, and I would like to estimate the effects of
political sofistication on electoral outcome. My data is from a complex
sample survey. Let also suppose respondents were classified in "protestant",
"catholic", and "others". Considering theoretical issues, it would be
interesting to estimate the effect of political sofistication and electoral
outcome just for the "protestant" group.
How should I proceed to obtain this coefficient only for a subgroup (for
instance, "protestants")? How can I select this subgroup in my sample when I
am running my analysis? For instance, I would like to run a "logit.survey"
model, and I intend to include survey design information (PSU and weights)
in my model. I would like to know how can I run analysis for this subgroup
without just delete the other cases from my dataset since this procedure
would distort the original sample design. Should I just set the weight to
zero for observations outside the subset of interest? Or is there other way
to proceed? And if I intend to run a "logit" model (not a "logit.survey"),
what should I do?
I looked for directions about this in Zelig manual, but I did not find
instructions for this kind of analyses.
Best regards,
Fabricio
Dear all,
I have a question about using Zelig on matched data. I have a matched
dataset in Stata format (I used genetic matching with MatchIt), and I'd like
to analyze it with Zelig. Can I simply load that dataset into R and run
Zelig?
Thank you,
Ana
Hi Zelig developers and users,
I am working with complex survey data; dataset is representative of a
Brazilian metropolitan data. Sample is based on a three-level
sampling: in the first stage, census tracts (CT) from the metropolitan
area were randomly selected (with chances proportional to size); then,
households were chosen from every previously selected census tract;
finally, a respondent was randomly chosen from the adult members of
the household. Initial sample design was designed for 1,270 cases, and
the total of successfully completed interviews was 1,029. (survey
response = 81%. not bad!)
Dataset I am analyzing includes (1) post-stratification weights (to
adjust proportionality due to survey non-response), (2) an “expansion
factor” (a weight that equals the sample to the population, that is,
it says approximately how many people in the population are
represented in each sample case), and (3) census tract (indicating
from which census tract each case was selected).
Due to sample design, we have several cases from the same census
tracts (99.9% of CTs provided from 5 to 20 cases; just one CT provided
only one case). This way, it seems that the most appropriated
regression models to analyze data from this sample might be the
“.survey” ones (logit.survey, normal.survey, etc).
All that explained, my question is: supposing a survey-weighted normal
model like
z.out <- zelig(Y ~ X1 + X2, model = "normal.survey", data = mydata)
which information from survey design should I include? My first
impression is that post-stratification weights (PSW) would correspond
to “weights” input, the Census Tracts number would correspond to “ids”
(since CTs are cluster from which each information was drawn). Can I
include these two information in the same regression, obtaining
something like
z.out <- zelig(Y ~ X1 + X2, model = "normal.survey", ids = ~CT,
weights = ~PSW, data = mydata)?
Or can I include only one survey design information in a model? Or
should I use other configuration?
Thanks for all help,
Fabricio M. Fialho
--
Fabrício Mendes Fialho
web: sites.google.com/site/fabriciofialho/
e-mail: fabriciofialho(a)gmail.com
-
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/