ipf function in R
On Wed, 5 Mar 2008, Chandra Shah wrote:
Hi I have a 3 x 2 contingency table: 10 20 30 40 50 60 I want to update the frequencies to new marginal totals: 100 130 40 80 110 I want to use the ipf (iterative proportional fitting) function which is apparently in the cat package. Can somebody please advice me how to input this data and invoke ipf in R to obtain an updated contingency table?
I'd use loglin() newtab <- loglin( rowmarg%o%colmarg/sum(colmarg), margin=list(1,2), start=tab, fit=TRUE )$fit with rowmarg and colmarg set to your updated marginals. As for inputting the data, if this is all you have, type it in at the command line. See ?matrix ?c and note this:
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
HTH, Chuck
Thanks. By the way I am quite new to R. -- Dr Chandra Shah Senior Research Fellow Monash University-ACER Centre for the Economics of Education and Training Faculty of Education, Building 6, Monash University Victoria Australia 3800 Tel. +61 3 9905 2787 Fax +61 3 9905 9184 www.education.monash.edu.au/centres/ceet
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901