[R] Linear regression

Bert Gunter gunter.berton at gene.com
Mon Mar 19 21:03:50 CET 2012


Note that your equations can be written:

y = alpha*A + (1-alpha)*B,  which is equivalent to

y = (A-B) * alpha + B   , i.e. of form

y = C*alpha + B   a simple linear equation in alpha

You have two different values of alpha at which y was measured, so
just stack up all your results into a single regression setup with
these two different alphas. Except for your constraints.

But if I understand you correctly, the problem is not that C and B
must be between 0 and 1, it is that the response, y, must be (it is a
frequency). If so, this suggests that you need to set this up as a
glm, probably with a binomial link. Trivial to do, but I suspect you
don't know about glm's, which is why I said that you may be out of
your depth and seek local help.

If I'm wrong, my apologies for misunderstanding. If I'm not, I'm
sorry, but I don't wish to teach you about basic statistics on this
list. Read up on "generalized linear models," for which there are
undoubtedly a host of good web tutorials available.

Cheers,
Bert

On Mon, Mar 19, 2012 at 12:48 PM, Diviya Smith <diviya.smith at gmail.com> wrote:
> Hello Bert,
>
> This is definitely not for a homework problem. I am trying to estimate
> frequencies of mutations in different groups. The mutation frequencies can
> be modeled as a linear relation in cases of mixtures. So I have a lot of
> populations that follow the relationship -
>
> y = alpha*A + beta*B and I want to estimate A and B; given y, alpha and
> beta. A and B are both vectors of the same size as y.
>
> Can you suggest where I can find some information about your suggestion
> #4...that is exactly what I was hoping to do.
>
> Thanks,
> Diviya
>
>
>
> On Mon, Mar 19, 2012 at 3:02 PM, Bert Gunter <gunter.berton at gene.com> wrote:
>>
>> 1. Homework assignment? We don't do homework here.
>>
>> 2. If not, a mixture model of some sort?  I suggest you state the
>> context of the problem more fully. R has several packages to do
>> mixture modeling, if that's what you're trying to do.
>>
>> 3. In any case, this cannot be done with lm() (at least without tricks).
>>
>> 4. In your notation below, the "separate" regressions can be stacked
>> into a single constrained regression model.
>>
>> 5. You might do better to find local statistical help, as you may have
>> bitten off more than you can chew.
>>
>> -- Bert
>>
>> On Mon, Mar 19, 2012 at 11:29 AM, Diviya Smith <diviya.smith at gmail.com>
>> wrote:
>> > Hello there,
>> >
>> > I am new to using regression in R. I wanted to solve a simple regression
>> > problem where I have 2 equations and 2 unknowns.
>> >
>> > So lets say -
>> > y1 = alpha1*A + beta1*B
>> > y2 = alpha2*A + beta2*B
>> >
>> > y1 <- runif(100000, 0,1)
>> > y2 <- runif(100000,0,1)
>> >
>> > alpha1 <- 0.6
>> > alpha2 <- 0.75
>> >
>> > beta1 <- 1-alpha1
>> > beta2 <- 1-apha2
>> >
>> > I now want this equation to estimate the values of A and B. Both A and B
>> > are constrained to be between (0,1). I would like to use lm with these
>> > constraints and I am having a little trouble in defining the equations
>> > correctly. Any help would be most appreciated.
>> >
>> > Thank you,
>> > Diviya
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > 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.
>>
>>
>>
>> --
>>
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>>
>> Internal Contact Info:
>> Phone: 467-7374
>> Website:
>>
>> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
>
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list