Re: [R] Conditional piece-wise dependent regression

2005-08-02 Thread Arie
Thank you Dimitris  Reid, you were very helpful.

Best wishes,
Arie.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Conditional piece-wise dependent regression

2005-08-01 Thread Arie
Hi, after reading some R docs, I couldn’t figure out how can I find the 
solution for the following
problem, therefore I would ask this friendly list for an advice.

We’re making a least square approximation for an experiment described by the 
following model:

T is the time,
Y is some measured value.

From time=0 till time=U:
Y = b + p*T
From time=U and on (some effect added):
Y = b + p*T + q*(T-U)
From time=V and on (some additional effect added):
Y = b + p*T + q*(T-U) + r*(T-V)

Measured: Yi, Ti pairs.
Wanted: b, p, q, r.
b and p are the same for all time ranges;
q is the same for time=U and on.

Thanks,
Arie.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Conditional piece-wise dependent regression

2005-08-01 Thread Dimitris Rizopoulos
Since you want least squares, I think you could use lm() here, i.e.,

U - 50
V - 100
Time - 1:150
dat - data.frame(y = rnorm(150), Time, f1 = as.numeric(Time  U), f2 
= as.numeric(Time  V))
###
m - lm(y ~ Time + I(Time - U):f1 + I(Time - V):f2, data = dat)

# check also the design matrix
model.matrix(m)


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm



- Original Message - 
From: Arie [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Monday, August 01, 2005 10:17 AM
Subject: [R] Conditional piece-wise dependent regression


Hi, after reading some R docs, I couldn't figure out how can I find 
the solution for the following
problem, therefore I would ask this friendly list for an advice.

We're making a least square approximation for an experiment described 
by the following model:

T is the time,
Y is some measured value.

From time=0 till time=U:
Y = b + p*T
From time=U and on (some effect added):
Y = b + p*T + q*(T-U)
From time=V and on (some additional effect added):
Y = b + p*T + q*(T-U) + r*(T-V)

Measured: Yi, Ti pairs.
Wanted: b, p, q, r.
b and p are the same for all time ranges;
q is the same for time=U and on.

Thanks,
Arie.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Conditional piece-wise dependent regression

2005-08-01 Thread Huntsinger, Reid
In case you want to estimate U and V as well, there's a segmented regression
package (called segmented) on http://cran.r-project.org for this.

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dimitris Rizopoulos
Sent: Monday, August 01, 2005 4:40 AM
To: Arie
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Conditional piece-wise dependent regression


Since you want least squares, I think you could use lm() here, i.e.,

U - 50
V - 100
Time - 1:150
dat - data.frame(y = rnorm(150), Time, f1 = as.numeric(Time  U), f2 
= as.numeric(Time  V))
###
m - lm(y ~ Time + I(Time - U):f1 + I(Time - V):f2, data = dat)

# check also the design matrix
model.matrix(m)


I hope it helps.

Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm



- Original Message - 
From: Arie [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Monday, August 01, 2005 10:17 AM
Subject: [R] Conditional piece-wise dependent regression


Hi, after reading some R docs, I couldn't figure out how can I find 
the solution for the following
problem, therefore I would ask this friendly list for an advice.

We're making a least square approximation for an experiment described 
by the following model:

T is the time,
Y is some measured value.

From time=0 till time=U:
Y = b + p*T
From time=U and on (some effect added):
Y = b + p*T + q*(T-U)
From time=V and on (some additional effect added):
Y = b + p*T + q*(T-U) + r*(T-V)

Measured: Yi, Ti pairs.
Wanted: b, p, q, r.
b and p are the same for all time ranges;
q is the same for time=U and on.

Thanks,
Arie.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html