I'd like to compare the coefficients from my own replication of a statistical model in the literature with the coefficients in the literature. I thougth I could just duplicate my model, and then plug in the coefficients from the literature and print both. But I'm getting this error:
Error in if (coef.var[i] == .global.coefficient.variables[j]) { :
argument is of length zero
What is the easiest way to do this?
##fake data
var1<-rnorm(100)
var2<-rnorm(100)
df<-data.frame(var1, var2)
#My own model
model1<-lm(var1~var2, data=df)
#Duplicate my own model
model2<-model1
#Try to change the coefficients to match what appears in the literature
model2$coefficients<-c(5, 10)
#Try to report
library(stargazer)
stargazer(model1, model2,type="html")