Still not exactly sure [RSABE / ABEL]
Thank you, Helmut and d_labes, for your input.
I am not planning to via the in-built confidence interval function because I can port it directly to C when I know exactly what's going on.
Helmut, I downloaded your spreadsheet, saved the dataset as csv with tab delimiter and adjusted the code to fit your format.
Here's some code:
I am still not really there
I am not planning to via the in-built confidence interval function because I can port it directly to C when I know exactly what's going on.
Helmut, I downloaded your spreadsheet, saved the dataset as csv with tab delimiter and adjusted the code to fit your format.
Here's some code:
A=read.table("EMAset1c.csv", header=T)
Model1=lm(log(A$Data)~0+factor(A$Formulation)+
factor(A$Period)+factor(A$Sequence)+factor(A$Subject))
lnPE=(coef(Model1)[2]-coef(Model1)[1])
B=subset(A, Formulation=='R')
Model2=lm(log(B$Data)~factor(B$Period)+factor(B$Sequence)+factor(B$Subject))
s=summary(Model2)$sigma
CV=sqrt(exp(s*s)-1.0)
DF=Model2$df.residual
CritT=qt(1-0.05, DF)
nTRTR=0
nRTRT=0
for (i in min(B$Subject):max(B$Subject))
if (i %in% B$Subject) ##if the subject exists
{
C=subset(B, Subject==i)
r=subset(C, Formulation=='R')
if(length(r$Formulation)==2) ##if the subject ate pocus two times.
{
if (C$Sequence[1]=='TRTR') nTRTR=nTRTR+1
if (C$Sequence[1]=='RTRT') nRTRT=nRTRT+1
}
} ## there's prolly a more efficient way of doing it.
lnU=lnPE+s*CritT*sqrt(0.25*(1/nTRTR+1/nRTRT))
lnL=lnPE-s*CritT*sqrt(0.25*(1/nTRTR+1/nRTRT))
cat("PE=", exp(lnPE),"\n")
cat("Upper Limit=", exp(lnU),"\n")
cat("Lower Limit=", exp(lnL),"\n")
cat("CV=", CV, "\n")
cat("nTRTR , nRTRT:", nTRTR, ",", nRTRT, "\n")
I am still not really there

—
Pass or fail!
ElMaestro
Pass or fail!
ElMaestro
Complete thread:
- EMA dataset 1 trouble ElMaestro 2013-04-08 20:23
- complete (RR) only Helmut 2013-04-09 02:37
- EMA dataset 1 - programmers trouble d_labes 2013-04-09 09:01
- Still not exactly sureElMaestro 2013-04-09 10:12
- Still not exactly sure - why d_labes 2013-04-09 15:57
- My problem(s) ElMaestro 2013-04-09 16:39
- More confusion ElMaestro 2013-04-09 23:29
- Confusion help d_labes 2013-04-10 10:51
- Still not exactly sure - why d_labes 2013-04-09 15:57
- Still not exactly sureElMaestro 2013-04-09 10:12