Use of offset in lm regression - R

前端 未结 2 1091
难免孤独
难免孤独 2021-01-05 17:51

I have this code

dens <- read.table(\'DensPiu.csv\', header = FALSE)
fl <- read.table(\'FluxPiu.csv\', header = FALSE)
mydata <- data.frame(c(dens),         


        
2条回答
  •  独厮守ぢ
    2021-01-05 18:16

    In fact, the real issue here is that you should specify offset with a vector whose length is the same as the number of rows (or the length, if data is composed as a vector) of your data. The following code will do your job as expected:

    regression <- lm(y ~ I(x-x0)-1, offset = rep(y0, length(y))
    

    Here is a good explanation for those who are interested: http://rfunction.com/archives/223

提交回复
热议问题