Here is an example code:
set.seed(3) data1 = iris[sample(c(1:dim(iris)), 30), ] data2 = iris[sample(c(1:dim(iris)), 50), ] model1 = lm(Petal.Length ~ log(Petal.Width), data = data1) model2 = lm(data2$Petal.Length ~ log(data2$Petal.Width)) par(mfrow = c(1, 4)) plot(data1$Petal.Width, data1$Petal.Length) points(sort(data1$Petal.Width), predict(model1, newdata = data1[order(data1$Petal.Width), ]), col = "red", type = "l") plot(data2$Petal.Width, data2$Petal.Length) points(sort(data2$Petal.Width), predict(model1, newdata = data2[order(data2$Petal.Width), ]), col = "red", type = "l") summary(model1) summary(model2)
As in the code, I fitted two different curves from two different datasets using the simple regression method in which the explanatory variable is in logarithm form. Like in the code, the datasets have the same variables with different size.
I want to check that the two curves (model1 and model2) are statistically different or not.
How can I do it in R?
---- edited ---- I know that there are many questions about comparing regression lines, but my case is a different one from previous ones because I want to compare different models built from different data sets while other cases are to compare different models built from the same data set.
Let me state more about the context of my purpose to elaborate on the term "compare."
I made a model (the curve) for an experimental site and want to apply this model to many other sites (over the country). I acknowledge that it would not proper to apply the model to other sites where the model is not based on (the resulted curve of another site may be different from the previous one). So, I made one more curve for another study site and trying to compare the two models built from different sites.
This is why the two data sets have the same variable list. And the common points of the two data sets in the example can be ignored in term of my purpose.