Comparison of two curves

Asked

Viewed 46 times

1

Hello I have to follow a determination of the DRC 166/2017 of Anvisa and one of the things it asks for is the comparison of two straight lines through the slope, intercept and coincidence calculation. Of the three calculations I could only do the one of coincidence, according to the shown below:

Comp=read.csv(file="C:/Users/porti/OneDrive/Script/efeito_matriz.csv",sep=";")
Comp

X1<-(Comp$"ï..X1")
X1
Y1<-(Comp$"Y1")
Y1
X2<-(Comp$"X2")
X2
Y2<-(Comp$"Y2")
Y2

x = c(X1, X2) 
y = c(Y1, Y2) 
z = factor(c(rep(1, length(X1)), rep(2, length(X2)))) 
z
C1 = lm(y~x*z) 
C2 = lm(y~x) 
anova(C1, C2) 

Does anyone have any idea how I compare the intercept and the inclination of these two curves?

  • Difficult, without data and at least its nature. Can update with part of the data or the summary(x) and summary(y)?

1 answer

1

If you do

summary(C1)

will have the similar result:

# Coefficients:
#   Estimate Std. Error t value Pr(>|t|)    
# (Intercept)  9.72936    0.58273   16.70   <2e-16 ***
#   x            2.01814    0.02864   70.47   <2e-16 ***
#   z           10.47969    0.74020   14.16   <2e-16 ***
#   x:z          0.96228    0.03382   28.45   <2e-16 ***

It indicates that the intercept for the second X2 case would be (9.72 + 10.47) and its difference is significant. The same can be done for the slope, for X2 case would be (2.02 + 0.96) also significant, this with simulated data.

You can see this on a graph:

plot(y~x, col=z)
abline(a=9.72936,b=2.01814,col=3)
abline(a=9.72936+10.47969,b=2.01814+0.96228,col=4)

inserir a descrição da imagem aqui

You can check this by doing:

X1a=c(X1,rep(0, length(X2)))
X2a=c(rep(0,length(X1)),X2)
c3=lm(y~0+z+X1a+X2a)
summary(c3)
car::linearHypothesis(c3,"1*z1 - 1*z2 = 0")
car::linearHypothesis(c3,"1*X1a - 1*X2a = 0")
  • 1

    It should include the generation of simulated data, preferably with a call to set.seed. Without it the answer, which seems to be good, is not reproducible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.