[R] stata.get labels glm()
Quark at gmx.at
Quark at gmx.at
Sun Feb 27 12:00:10 CET 2011
Dear R community,
I would like to import data saved with Stata and then run a Probit model using R.
My data comes from the World Values Surveys and in the Probit model I want to control for countries.
So far I figured out that I should put "convert.factors = FALSE" when using stata.get() in order to import numeric values instead of label mappings, which is what I want for most of the variables. In a second step I would like to convert ONLY the country variable to a factor, such that glm() automatically controls for countries. With the latter point I am stuck, I managed to extract the country labels but don't know how to match this information now with my country variable 'v2'.
> wvs1981 <- stata.get("C:/wvs1981_v20090906.dta", lowernames = FALSE, convert.dates = TRUE, convert.factors = FALSE, missing.type = FALSE, convert.underscore = TRUE, warn.missing.labels = TRUE, force.single = TRUE, allow=NULL, charfactor=FALSE)
> countrylabels <- attributes(wvs1981)$stata.info$label.table$v2
> countrylabels
japan mexico south africa hungary australia tambov argentina finland south korea
13 14 15 16 17 20 22 23 24
I know that I could put the option factor() in the Probit model but in my output then '13' instead of 'Japan' appears, which is not so nice, i.e.
> myprobit<- glm(v220bin ~ v214 + v216 + factor(v2), family=binomial(link="probit"), data=wvs1981, na.action=na.pass)
Thanks a lot for your help.
Best regards,
Tobias
--
Schon gehört? GMX hat einen genialen Phishing-Filter in die
More information about the R-help
mailing list