From: Ted Harding <Ted.Harding_at_manchester.ac.uk>

Date: Wed, 05 Mar 2008 10:27:08 +0000 (GMT)

-------------+---

100 130 |230

-------------+---

100 130 |230

E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861

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. Received on Wed 05 Mar 2008 - 10:38:26 GMT

Date: Wed, 05 Mar 2008 10:27:08 +0000 (GMT)

On 05-Mar-08 07:14:28, 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?
**> Thanks.
**> By the way I am quite new to R.
*

It is not clear from your description what you really want to do. Hence, not clear whether you should be using ipf() to do it!

The purpose of ipf() in the 'cat' package is very simple: You suppply a complete contingency table, and specify the order of interactions you want to include in the fit (using the "margins" parameter in ipf()); and then the value of ipf() is a table of the fitted (expected) values corresponding to a model of the type you have specified, fitted by maximum likelihood.

Your task seems to be different. If I understand your statement. it looks as though you want to find a,b,c,d such that

10+a 20+c | 40 30+b 40+d | 80 50 60 |110

-------------+---

100 130 |230

or, since there are row and column constraints on a,b,c,d:

10+a 30-a | 40 40-a 40+a | 80 50 60 |110

-------------+---

100 130 |230

so then the task would be to find a.

But now it depends on what you would mean by "find a".

You could treat 'a' as an unknown parameter, and fit it by maximum likelihood under various assumptions about the dependence between rows and columns (e.g. that the log odds-ratios have particular values).

Or perhaps (and here is where ipf() may come in) for a given choice of 'a' you could submit the resulting table to ipf() and compute chisq from the resulting fitted values and the given "observed" values; then seek the value of 'a' which minimises chisq.

However, it's not really possible to advise in more detail without being sure of what you are trying to do. Above, I am only guessing!

Best wishes,

Ted.

E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861

Date: 05-Mar-08 Time: 10:26:57 ------------------------------ XFMail ------------------------------ ______________________________________________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. Received on Wed 05 Mar 2008 - 10:38:26 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 05 Mar 2008 - 11:30:19 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*