Re: Trouble with a system of equations
- To: mathgroup at smc.vnet.net
- Subject: [mg77596] Re: Trouble with a system of equations
- From: Yaroslav Bulatov <yaroslavvb at gmail.com>
- Date: Wed, 13 Jun 2007 07:42:36 -0400 (EDT)
- References: <f4lb44$fvv$1@smc.vnet.net>
On Jun 11, 10:31 pm, Ray Koopman <koop... at sfu.ca> wrote:
> On Mon, 11 Jun 2007 07:38:00 -0500 drmajor... at bigfoot.com wrote:
>
> > There's an unmatched bracket in
>
> >> m = Inverse[ Subsets[Times@@#]& /@ Tuples[{0,1},k]] ].
>
> > and I haven't found a way (so far) to correct it so that the code works.
>
> > Bobby
>
> Ah, the joys and perils of posting code without testing it first.
> Maybe someday I'll get Mathematica for my machine at home.
>
> Aside from the extra ], that must must have been teleported from
> LinearSolve[x,Log[p/(1-p)], where a ] is missing, the problem is
> that I simply copied the form of an example in the Subsets online
> documentation, with h changed to Times, not realizing that Times@@#
> would be evaluated before Subsets got to it.
>
> Here are two ways to get x:
>
> ReleaseHold@Subsets[Hold@Times@@#]& /@ Tuples[{0,1},k]
>
> or (preferably, I think)
>
> Times@@@Subsets@#& /@ Tuples[{0,1},k].
>
> With[{k = 2}, Inverse[ Times@@@Subsets@#& /@ Tuples[{0,1},k] ]]
>
> {{ 1, 0, 0, 0},
> {-1, 0, 1, 0},
> {-1, 1, 0, 0},
> { 1,-1,-1, 1}}
>
> With[{k = 3}, Inverse[ Times@@@Subsets@#& /@ Tuples[{0,1},k] ]]
>
> {{ 1, 0, 0, 0, 0, 0, 0, 0},
> {-1, 0, 0, 0, 1, 0, 0, 0},
> {-1, 0, 1, 0, 0, 0, 0, 0},
> {-1, 1, 0, 0, 0, 0, 0, 0},
> { 1, 0,-1, 0,-1, 0, 1, 0},
> { 1,-1, 0, 0,-1, 1, 0, 0},
> { 1,-1,-1, 1, 0, 0, 0, 0},
> {-1, 1, 1,-1, 1,-1,-1, 1}}
OK that works, thanks. One problem with the original system is that I
set up the estimation equations in terms of E[x_i y] (assuming uniform
distribution over x's), and not empirical odds ratios which apparently
make it much harder to solve (Andrzei's solution works fine for 2
variables, but takes too long for 3)
- Follow-Ups:
- Re: Trouble with a system of equations
- From: Yaroslav Bulatov <yaroslavvb@gmail.com>
- Re: Re: Trouble with a system of equations
- From: Andrzej Kozlowski <akoz@mimuw.edu.pl>
- Re: Trouble with a system of equations