[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: simulated data for logistic regression... remedial algebra help?

From   Steven Joel Hirsch Samuels <>
Subject   Re: st: RE: simulated data for logistic regression... remedial algebra help?
Date   Mon, 19 Nov 2007 09:49:40 -0500

It's a quadratic.

Let w = proportion of positive tests
p = overall mortality
OR = odds ratio 1 over 2

Solve: p1/(1-p1)=OR(p2/(1-p2) Let Z2 = p2/(1-p2),
p1 = (OR x Z2)/(1+ OR x Z2) =(OR x p2)/(1-p2 + (OR x p2)) = A

Also p = w p1 + (1-w) p2,
p1 = (p -(1 -w)p2)/w =B (you left out the 1-w term in your k2 coefficient)

Equate A and B. Since the denominator in A multiplies the numerator in B, you have a quadratic equation in p2.

On Nov 18, 2007, at 11:56 PM, Daniel Waxman wrote:

Not sure if the lack of response reflects a lack of clarity in stating the
problem, or just that the solution isn't obvious to anyone.

In case it is the former, I'll restate the problem:

The goal is to create a simulated data set. To do so, I would like to
determine the probabilities of an outcome (death) given a positive or
negative test result, when the overall mortality rate, the odds ratio for
mortality as a function of that test and proportion of positive test results
in the population are known.

The problem reduces (I believe) to solving:

p2= k1-p1k2


p1 = mortality rate for a positive test
p2 = mortality rate for a negative test

k1 = constant = (overall mortality rate)/(proportion of population with a
positive test)
k2 = constant = (proportion negative test)/(proportion positive test)

Does this problem look familiar to anyone?

If my poor math skills are not failing me, I believe that I end up with p1^3
term. Does this sound right? Would it mean that there is no exact

Any other suggestions for creating simulated data with these properties?


-----Original Message-----
[] On Behalf Of Daniel Waxman
Sent: Saturday, November 17, 2007 6:44 PM
Subject: st: simulated data for logistic regression... remedial algebra

I am trying to create a series of simulated data sets for use in logistic
regression with the following properties:

Mortality (outcome) remains constant. There is a single dichotomous
independent variable whose odds ratio (coefficient) and proportion of
positives can vary between the sets. It all comes down to solving for the
intercept (`b0'), given the following relationships:

`proportion_positive’*probability_positive+(1-`proportion_positive’) *probabi

Sad to admit, but I am bumping up against the limitations of my algebra
I'd imagine this is trivial for many of you...



set obs 1000
local odds=2
local proportion_positive= .10
local mortality = .05

gen test=uniform()<`proportion_positive’


************solve for `b0' here************


gen probability_negative=invlogit(`b0’)
gen probability_positive=invlogit(log(`odds’)+`b0’)

gen died=uniform() < cond (test==0,probability_negative,probability_positive)

logistic died test




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.0/1136 - Release Date: 11/17/2007
2:55 PM

* For searches and help try:
Steven  Samuels
18 Cantine's Island
Saugerties, NY 12477
Phone: 845-246-0774
EFax: 208-498-7441

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index